@niledatabase/react 3.0.0-alpha.33 → 3.0.0-alpha.35
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +56 -43
- package/dist/index.mjs +42 -29
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,9 @@ declare const GoogleSSOButton: React__default.ForwardRefExoticComponent<ButtonPr
|
|
|
28
28
|
|
|
29
29
|
type SignUpInfo = CreateBasicUserRequest & {
|
|
30
30
|
tenantId?: string;
|
|
31
|
+
fetchURL?: string;
|
|
32
|
+
callbackUrl?: string;
|
|
33
|
+
newTenantName?: string;
|
|
31
34
|
};
|
|
32
35
|
type SignInSuccess = (response: Response, formValues: SignUpInfo) => void;
|
|
33
36
|
type AllowedAny$1 = any;
|
|
@@ -37,11 +40,12 @@ interface Props$1 {
|
|
|
37
40
|
beforeMutate?: (data: AllowedAny$1) => AllowedAny$1;
|
|
38
41
|
buttonText?: string;
|
|
39
42
|
client?: QueryClient;
|
|
43
|
+
callbackUrl?: string;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
declare function SigningUp(props: Props$1): React__default.JSX.Element;
|
|
43
47
|
|
|
44
|
-
declare function useSignUp<T extends SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
|
|
48
|
+
declare function useSignUp<T extends SignUpInfo>(params: Props$1, client?: QueryClient): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
|
|
45
49
|
|
|
46
50
|
type AllowedAny = any;
|
|
47
51
|
type LoginInfo = {
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ declare const GoogleSSOButton: React__default.ForwardRefExoticComponent<ButtonPr
|
|
|
28
28
|
|
|
29
29
|
type SignUpInfo = CreateBasicUserRequest & {
|
|
30
30
|
tenantId?: string;
|
|
31
|
+
fetchURL?: string;
|
|
32
|
+
callbackUrl?: string;
|
|
33
|
+
newTenantName?: string;
|
|
31
34
|
};
|
|
32
35
|
type SignInSuccess = (response: Response, formValues: SignUpInfo) => void;
|
|
33
36
|
type AllowedAny$1 = any;
|
|
@@ -37,11 +40,12 @@ interface Props$1 {
|
|
|
37
40
|
beforeMutate?: (data: AllowedAny$1) => AllowedAny$1;
|
|
38
41
|
buttonText?: string;
|
|
39
42
|
client?: QueryClient;
|
|
43
|
+
callbackUrl?: string;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
declare function SigningUp(props: Props$1): React__default.JSX.Element;
|
|
43
47
|
|
|
44
|
-
declare function useSignUp<T extends SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
|
|
48
|
+
declare function useSignUp<T extends SignUpInfo>(params: Props$1, client?: QueryClient): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
|
|
45
49
|
|
|
46
50
|
type AllowedAny = any;
|
|
47
51
|
type LoginInfo = {
|
package/dist/index.js
CHANGED
|
@@ -2676,10 +2676,10 @@ function GoogleLogo() {
|
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
2678
2678
|
// src/SignUpForm/SignUpForm.tsx
|
|
2679
|
-
var
|
|
2679
|
+
var import_react5 = __toESM(require("react"));
|
|
2680
2680
|
|
|
2681
2681
|
// src/SignUpForm/Form.tsx
|
|
2682
|
-
var
|
|
2682
|
+
var import_react4 = __toESM(require("react"));
|
|
2683
2683
|
var import_react_query2 = require("@tanstack/react-query");
|
|
2684
2684
|
var import_react_hook_form2 = require("react-hook-form");
|
|
2685
2685
|
|
|
@@ -2860,32 +2860,45 @@ var Password = () => {
|
|
|
2860
2860
|
|
|
2861
2861
|
// src/SignUpForm/hooks.tsx
|
|
2862
2862
|
var import_react_query = require("@tanstack/react-query");
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
const
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
searchParams
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2863
|
+
var import_react3 = require("react");
|
|
2864
|
+
function useSignUp(params, client) {
|
|
2865
|
+
const { onSuccess, onError, beforeMutate, callbackUrl } = params;
|
|
2866
|
+
const mutation = (0, import_react_query.useMutation)(
|
|
2867
|
+
{
|
|
2868
|
+
mutationFn: async (_data) => {
|
|
2869
|
+
const possibleData = beforeMutate && beforeMutate(_data);
|
|
2870
|
+
const payload = { ..._data, ...possibleData };
|
|
2871
|
+
const { tenantId, newTenantName, ...body } = payload;
|
|
2872
|
+
let fetchUrl = payload.fetchURL ?? `${window.location.origin}/api/signup`;
|
|
2873
|
+
const searchParams = new URLSearchParams();
|
|
2874
|
+
if (newTenantName) {
|
|
2875
|
+
searchParams.set("newTenantName", newTenantName);
|
|
2876
|
+
}
|
|
2877
|
+
if (tenantId) {
|
|
2878
|
+
searchParams.set("tenantId", tenantId);
|
|
2879
|
+
}
|
|
2880
|
+
if (searchParams.size > 0) {
|
|
2881
|
+
fetchUrl += `?${searchParams}`;
|
|
2882
|
+
}
|
|
2883
|
+
return await fetch(fetchUrl, {
|
|
2884
|
+
body: JSON.stringify(body),
|
|
2885
|
+
method: "POST"
|
|
2886
|
+
});
|
|
2887
|
+
},
|
|
2888
|
+
onSuccess: (data, variables) => {
|
|
2889
|
+
if (callbackUrl) {
|
|
2890
|
+
window.location.href = callbackUrl;
|
|
2891
|
+
}
|
|
2892
|
+
onSuccess && onSuccess(data, variables);
|
|
2893
|
+
},
|
|
2894
|
+
onError
|
|
2885
2895
|
},
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2896
|
+
client
|
|
2897
|
+
);
|
|
2898
|
+
(0, import_react3.useEffect)(() => {
|
|
2899
|
+
fetch("/api/auth/providers");
|
|
2900
|
+
fetch("/api/auth/csrf");
|
|
2901
|
+
}, []);
|
|
2889
2902
|
return mutation.mutate;
|
|
2890
2903
|
}
|
|
2891
2904
|
|
|
@@ -2893,12 +2906,12 @@ function useSignUp(params) {
|
|
|
2893
2906
|
var queryClient = new import_react_query2.QueryClient();
|
|
2894
2907
|
function SignUpForm(props) {
|
|
2895
2908
|
const { client } = props ?? {};
|
|
2896
|
-
return /* @__PURE__ */
|
|
2909
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react_query2.QueryClientProvider, { client: client ?? queryClient }, /* @__PURE__ */ import_react4.default.createElement(SignInForm, { ...props }));
|
|
2897
2910
|
}
|
|
2898
2911
|
function SignInForm(props) {
|
|
2899
2912
|
const signUp = useSignUp(props);
|
|
2900
2913
|
const form = (0, import_react_hook_form2.useForm)({ defaultValues: { email: "", password: "" } });
|
|
2901
|
-
return /* @__PURE__ */
|
|
2914
|
+
return /* @__PURE__ */ import_react4.default.createElement(Form, { ...form }, /* @__PURE__ */ import_react4.default.createElement(
|
|
2902
2915
|
"form",
|
|
2903
2916
|
{
|
|
2904
2917
|
onSubmit: form.handleSubmit(
|
|
@@ -2906,28 +2919,28 @@ function SignInForm(props) {
|
|
|
2906
2919
|
),
|
|
2907
2920
|
className: "space-y-8"
|
|
2908
2921
|
},
|
|
2909
|
-
/* @__PURE__ */
|
|
2910
|
-
/* @__PURE__ */
|
|
2911
|
-
/* @__PURE__ */
|
|
2922
|
+
/* @__PURE__ */ import_react4.default.createElement(Email, null),
|
|
2923
|
+
/* @__PURE__ */ import_react4.default.createElement(Password, null),
|
|
2924
|
+
/* @__PURE__ */ import_react4.default.createElement(Button, null, "Sign up")
|
|
2912
2925
|
));
|
|
2913
2926
|
}
|
|
2914
2927
|
|
|
2915
2928
|
// src/SignUpForm/SignUpForm.tsx
|
|
2916
2929
|
function SigningUp(props) {
|
|
2917
|
-
return /* @__PURE__ */
|
|
2930
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col gap-4" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "font-sans text-3xl" }, "Sign up"), /* @__PURE__ */ import_react5.default.createElement(SignUpForm, { ...props }));
|
|
2918
2931
|
}
|
|
2919
2932
|
|
|
2920
2933
|
// src/SignInForm/SignInForm.tsx
|
|
2921
|
-
var
|
|
2934
|
+
var import_react8 = __toESM(require("react"));
|
|
2922
2935
|
|
|
2923
2936
|
// src/SignInForm/Form.tsx
|
|
2924
|
-
var
|
|
2937
|
+
var import_react7 = __toESM(require("react"));
|
|
2925
2938
|
var import_react_query4 = require("@tanstack/react-query");
|
|
2926
2939
|
var import_react_hook_form3 = require("react-hook-form");
|
|
2927
2940
|
|
|
2928
2941
|
// src/SignInForm/hooks.tsx
|
|
2929
2942
|
var import_react_query3 = require("@tanstack/react-query");
|
|
2930
|
-
var
|
|
2943
|
+
var import_react6 = require("next-auth/react");
|
|
2931
2944
|
function useSignIn(params) {
|
|
2932
2945
|
const { onSuccess, onError, beforeMutate, callbackUrl } = params ?? {};
|
|
2933
2946
|
const mutation = (0, import_react_query3.useMutation)({
|
|
@@ -2935,7 +2948,7 @@ function useSignIn(params) {
|
|
|
2935
2948
|
const d = { ..._data, callbackUrl };
|
|
2936
2949
|
const possibleData = beforeMutate && beforeMutate(d);
|
|
2937
2950
|
const data = possibleData ?? d;
|
|
2938
|
-
return await (0,
|
|
2951
|
+
return await (0, import_react6.signIn)("credentials", data);
|
|
2939
2952
|
},
|
|
2940
2953
|
onSuccess,
|
|
2941
2954
|
onError
|
|
@@ -2947,12 +2960,12 @@ function useSignIn(params) {
|
|
|
2947
2960
|
var queryClient2 = new import_react_query4.QueryClient();
|
|
2948
2961
|
function SigningIn(props) {
|
|
2949
2962
|
const { client, ...remaining } = props ?? {};
|
|
2950
|
-
return /* @__PURE__ */
|
|
2963
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_query4.QueryClientProvider, { client: client ?? queryClient2 }, /* @__PURE__ */ import_react7.default.createElement(SignInForm2, { ...remaining }));
|
|
2951
2964
|
}
|
|
2952
2965
|
function SignInForm2(props) {
|
|
2953
2966
|
const signIn3 = useSignIn(props);
|
|
2954
2967
|
const form = (0, import_react_hook_form3.useForm)({ defaultValues: { email: "", password: "" } });
|
|
2955
|
-
return /* @__PURE__ */
|
|
2968
|
+
return /* @__PURE__ */ import_react7.default.createElement(Form, { ...form }, /* @__PURE__ */ import_react7.default.createElement(
|
|
2956
2969
|
"form",
|
|
2957
2970
|
{
|
|
2958
2971
|
onSubmit: form.handleSubmit(
|
|
@@ -2960,15 +2973,15 @@ function SignInForm2(props) {
|
|
|
2960
2973
|
),
|
|
2961
2974
|
className: "space-y-8"
|
|
2962
2975
|
},
|
|
2963
|
-
/* @__PURE__ */
|
|
2964
|
-
/* @__PURE__ */
|
|
2965
|
-
/* @__PURE__ */
|
|
2976
|
+
/* @__PURE__ */ import_react7.default.createElement(Email, null),
|
|
2977
|
+
/* @__PURE__ */ import_react7.default.createElement(Password, null),
|
|
2978
|
+
/* @__PURE__ */ import_react7.default.createElement(Button, { type: "submit" }, "Sign In")
|
|
2966
2979
|
));
|
|
2967
2980
|
}
|
|
2968
2981
|
|
|
2969
2982
|
// src/SignInForm/SignInForm.tsx
|
|
2970
2983
|
function SigningIn2(props) {
|
|
2971
|
-
return /* @__PURE__ */
|
|
2984
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex flex-col gap-4" }, /* @__PURE__ */ import_react8.default.createElement("h2", { className: "font-sans text-3xl" }, "Sign In"), /* @__PURE__ */ import_react8.default.createElement(SigningIn, { ...props }));
|
|
2972
2985
|
}
|
|
2973
2986
|
|
|
2974
2987
|
// src/index.ts
|
package/dist/index.mjs
CHANGED
|
@@ -2637,7 +2637,7 @@ import React7 from "react";
|
|
|
2637
2637
|
|
|
2638
2638
|
// src/SignUpForm/Form.tsx
|
|
2639
2639
|
import React6 from "react";
|
|
2640
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
2640
|
+
import { QueryClient as QueryClient2, QueryClientProvider } from "@tanstack/react-query";
|
|
2641
2641
|
import { useForm } from "react-hook-form";
|
|
2642
2642
|
|
|
2643
2643
|
// components/ui/form.tsx
|
|
@@ -2821,37 +2821,50 @@ var Password = () => {
|
|
|
2821
2821
|
|
|
2822
2822
|
// src/SignUpForm/hooks.tsx
|
|
2823
2823
|
import { useMutation } from "@tanstack/react-query";
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
searchParams
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2824
|
+
import { useEffect } from "react";
|
|
2825
|
+
function useSignUp(params, client) {
|
|
2826
|
+
const { onSuccess, onError, beforeMutate, callbackUrl } = params;
|
|
2827
|
+
const mutation = useMutation(
|
|
2828
|
+
{
|
|
2829
|
+
mutationFn: async (_data) => {
|
|
2830
|
+
const possibleData = beforeMutate && beforeMutate(_data);
|
|
2831
|
+
const payload = { ..._data, ...possibleData };
|
|
2832
|
+
const { tenantId, newTenantName, ...body } = payload;
|
|
2833
|
+
let fetchUrl = payload.fetchURL ?? `${window.location.origin}/api/signup`;
|
|
2834
|
+
const searchParams = new URLSearchParams();
|
|
2835
|
+
if (newTenantName) {
|
|
2836
|
+
searchParams.set("newTenantName", newTenantName);
|
|
2837
|
+
}
|
|
2838
|
+
if (tenantId) {
|
|
2839
|
+
searchParams.set("tenantId", tenantId);
|
|
2840
|
+
}
|
|
2841
|
+
if (searchParams.size > 0) {
|
|
2842
|
+
fetchUrl += `?${searchParams}`;
|
|
2843
|
+
}
|
|
2844
|
+
return await fetch(fetchUrl, {
|
|
2845
|
+
body: JSON.stringify(body),
|
|
2846
|
+
method: "POST"
|
|
2847
|
+
});
|
|
2848
|
+
},
|
|
2849
|
+
onSuccess: (data, variables) => {
|
|
2850
|
+
if (callbackUrl) {
|
|
2851
|
+
window.location.href = callbackUrl;
|
|
2852
|
+
}
|
|
2853
|
+
onSuccess && onSuccess(data, variables);
|
|
2854
|
+
},
|
|
2855
|
+
onError
|
|
2846
2856
|
},
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2857
|
+
client
|
|
2858
|
+
);
|
|
2859
|
+
useEffect(() => {
|
|
2860
|
+
fetch("/api/auth/providers");
|
|
2861
|
+
fetch("/api/auth/csrf");
|
|
2862
|
+
}, []);
|
|
2850
2863
|
return mutation.mutate;
|
|
2851
2864
|
}
|
|
2852
2865
|
|
|
2853
2866
|
// src/SignUpForm/Form.tsx
|
|
2854
|
-
var queryClient = new
|
|
2867
|
+
var queryClient = new QueryClient2();
|
|
2855
2868
|
function SignUpForm(props) {
|
|
2856
2869
|
const { client } = props ?? {};
|
|
2857
2870
|
return /* @__PURE__ */ React6.createElement(QueryClientProvider, { client: client ?? queryClient }, /* @__PURE__ */ React6.createElement(SignInForm, { ...props }));
|
|
@@ -2883,7 +2896,7 @@ import React9 from "react";
|
|
|
2883
2896
|
|
|
2884
2897
|
// src/SignInForm/Form.tsx
|
|
2885
2898
|
import React8 from "react";
|
|
2886
|
-
import { QueryClient as
|
|
2899
|
+
import { QueryClient as QueryClient3, QueryClientProvider as QueryClientProvider2 } from "@tanstack/react-query";
|
|
2887
2900
|
import { useForm as useForm2 } from "react-hook-form";
|
|
2888
2901
|
|
|
2889
2902
|
// src/SignInForm/hooks.tsx
|
|
@@ -2905,7 +2918,7 @@ function useSignIn(params) {
|
|
|
2905
2918
|
}
|
|
2906
2919
|
|
|
2907
2920
|
// src/SignInForm/Form.tsx
|
|
2908
|
-
var queryClient2 = new
|
|
2921
|
+
var queryClient2 = new QueryClient3();
|
|
2909
2922
|
function SigningIn(props) {
|
|
2910
2923
|
const { client, ...remaining } = props ?? {};
|
|
2911
2924
|
return /* @__PURE__ */ React8.createElement(QueryClientProvider2, { client: client ?? queryClient2 }, /* @__PURE__ */ React8.createElement(SignInForm2, { ...remaining }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niledatabase/react",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.35",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
121
|
"@hookform/resolvers": "^3.9.0",
|
|
122
|
-
"@niledatabase/browser": "^3.0.0-alpha.
|
|
122
|
+
"@niledatabase/browser": "^3.0.0-alpha.35",
|
|
123
123
|
"@radix-ui/react-label": "^2.1.0",
|
|
124
124
|
"@radix-ui/react-slot": "^1.1.0",
|
|
125
125
|
"@tanstack/react-query": "^5.23.0",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"react-hook-form": "^7.53.0",
|
|
130
130
|
"react-is": "^18.2.0"
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "3bf1ed73dc59f1a4bb0343fa35961ebefd70c905"
|
|
133
133
|
}
|