@niledatabase/react 3.0.0-alpha.25 → 3.0.0-alpha.27

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 CHANGED
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import React__default from 'react';
3
3
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
4
4
  import { VariantProps } from 'class-variance-authority';
5
- import * as _niledatabase_browser from '@niledatabase/browser';
6
5
  import { CreateBasicUserRequest } from '@niledatabase/browser';
7
6
  import * as _tanstack_react_query from '@tanstack/react-query';
8
7
  import { QueryClient } from '@tanstack/react-query';
@@ -27,7 +26,9 @@ declare const GoogleSSOButton: React__default.ForwardRefExoticComponent<ButtonPr
27
26
  callbackUrl: string;
28
27
  } & React__default.RefAttributes<HTMLButtonElement>>;
29
28
 
30
- type SignUpInfo = CreateBasicUserRequest;
29
+ type SignUpInfo = CreateBasicUserRequest & {
30
+ tenantId?: string;
31
+ };
31
32
  type SignInSuccess = (response: Response, formValues: SignUpInfo) => void;
32
33
  type AllowedAny$1 = any;
33
34
  interface Props$1 {
@@ -40,7 +41,7 @@ interface Props$1 {
40
41
 
41
42
  declare function SigningUp(props: Props$1): React__default.JSX.Element;
42
43
 
43
- declare function useSignUp<T = SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, _niledatabase_browser.CreateBasicUserRequest, unknown>;
44
+ declare function useSignUp<T extends SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
44
45
 
45
46
  type AllowedAny = any;
46
47
  type LoginInfo = {
@@ -60,4 +61,7 @@ declare function SigningIn(props: Props): React__default.JSX.Element;
60
61
 
61
62
  declare function useSignIn(params?: Props): _tanstack_react_query.UseMutateFunction<next_auth_react.SignInResponse | undefined, Error, LoginInfo, any>;
62
63
 
63
- export { GoogleSSOButton as Google, SigningIn as SignInForm, SigningUp as SignUpForm, useSignIn, useSignUp };
64
+ declare const Email: () => React.JSX.Element;
65
+ declare const Password: () => React.JSX.Element;
66
+
67
+ export { Email, GoogleSSOButton as Google, Password, SigningIn as SignInForm, SigningUp as SignUpForm, useSignIn, useSignUp };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import React__default from 'react';
3
3
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
4
4
  import { VariantProps } from 'class-variance-authority';
5
- import * as _niledatabase_browser from '@niledatabase/browser';
6
5
  import { CreateBasicUserRequest } from '@niledatabase/browser';
7
6
  import * as _tanstack_react_query from '@tanstack/react-query';
8
7
  import { QueryClient } from '@tanstack/react-query';
@@ -27,7 +26,9 @@ declare const GoogleSSOButton: React__default.ForwardRefExoticComponent<ButtonPr
27
26
  callbackUrl: string;
28
27
  } & React__default.RefAttributes<HTMLButtonElement>>;
29
28
 
30
- type SignUpInfo = CreateBasicUserRequest;
29
+ type SignUpInfo = CreateBasicUserRequest & {
30
+ tenantId?: string;
31
+ };
31
32
  type SignInSuccess = (response: Response, formValues: SignUpInfo) => void;
32
33
  type AllowedAny$1 = any;
33
34
  interface Props$1 {
@@ -40,7 +41,7 @@ interface Props$1 {
40
41
 
41
42
  declare function SigningUp(props: Props$1): React__default.JSX.Element;
42
43
 
43
- declare function useSignUp<T = SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, _niledatabase_browser.CreateBasicUserRequest, unknown>;
44
+ declare function useSignUp<T extends SignUpInfo>(params: Props$1): _tanstack_react_query.UseMutateFunction<Response, Error, SignUpInfo, unknown>;
44
45
 
45
46
  type AllowedAny = any;
46
47
  type LoginInfo = {
@@ -60,4 +61,7 @@ declare function SigningIn(props: Props): React__default.JSX.Element;
60
61
 
61
62
  declare function useSignIn(params?: Props): _tanstack_react_query.UseMutateFunction<next_auth_react.SignInResponse | undefined, Error, LoginInfo, any>;
62
63
 
63
- export { GoogleSSOButton as Google, SigningIn as SignInForm, SigningUp as SignUpForm, useSignIn, useSignUp };
64
+ declare const Email: () => React.JSX.Element;
65
+ declare const Password: () => React.JSX.Element;
66
+
67
+ export { Email, GoogleSSOButton as Google, Password, SigningIn as SignInForm, SigningUp as SignUpForm, useSignIn, useSignUp };
package/dist/index.js CHANGED
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var src_exports = {};
33
33
  __export(src_exports, {
34
+ Email: () => Email,
34
35
  Google: () => GoogleLoginButton_default,
36
+ Password: () => Password,
35
37
  SignInForm: () => SigningIn2,
36
38
  SignUpForm: () => SigningUp,
37
39
  useSignIn: () => useSignIn,
@@ -2682,7 +2684,7 @@ var import_react_query2 = require("@tanstack/react-query");
2682
2684
  var import_react_hook_form2 = require("react-hook-form");
2683
2685
 
2684
2686
  // components/ui/form.tsx
2685
- var React4 = __toESM(require("react"));
2687
+ var React5 = __toESM(require("react"));
2686
2688
  var import_react_slot3 = require("@radix-ui/react-slot");
2687
2689
  var import_react_hook_form = require("react-hook-form");
2688
2690
 
@@ -2702,17 +2704,37 @@ var Label = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
2702
2704
  ));
2703
2705
  Label.displayName = LabelPrimitive.Root.displayName;
2704
2706
 
2707
+ // components/ui/input.tsx
2708
+ var React4 = __toESM(require("react"));
2709
+ var Input = React4.forwardRef(
2710
+ ({ className, type, ...props }, ref) => {
2711
+ return /* @__PURE__ */ React4.createElement(
2712
+ "input",
2713
+ {
2714
+ type,
2715
+ className: cn(
2716
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2717
+ className
2718
+ ),
2719
+ ref,
2720
+ ...props
2721
+ }
2722
+ );
2723
+ }
2724
+ );
2725
+ Input.displayName = "Input";
2726
+
2705
2727
  // components/ui/form.tsx
2706
2728
  var Form = import_react_hook_form.FormProvider;
2707
- var FormFieldContext = React4.createContext(
2729
+ var FormFieldContext = React5.createContext(
2708
2730
  {}
2709
2731
  );
2710
2732
  var FormField = ({ ...props }) => {
2711
- return /* @__PURE__ */ React4.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React4.createElement(import_react_hook_form.Controller, { ...props }));
2733
+ return /* @__PURE__ */ React5.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React5.createElement(import_react_hook_form.Controller, { ...props }));
2712
2734
  };
2713
2735
  var useFormField = () => {
2714
- const fieldContext = React4.useContext(FormFieldContext);
2715
- const itemContext = React4.useContext(FormItemContext);
2736
+ const fieldContext = React5.useContext(FormFieldContext);
2737
+ const itemContext = React5.useContext(FormItemContext);
2716
2738
  const { getFieldState, formState } = (0, import_react_hook_form.useFormContext)();
2717
2739
  const fieldState = getFieldState(fieldContext.name, formState);
2718
2740
  if (!fieldContext) {
@@ -2728,17 +2750,17 @@ var useFormField = () => {
2728
2750
  ...fieldState
2729
2751
  };
2730
2752
  };
2731
- var FormItemContext = React4.createContext(
2753
+ var FormItemContext = React5.createContext(
2732
2754
  {}
2733
2755
  );
2734
- var FormItem = React4.forwardRef(({ className, ...props }, ref) => {
2735
- const id = React4.useId();
2736
- return /* @__PURE__ */ React4.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React4.createElement("div", { ref, className: cn("space-y-2", className), ...props }));
2756
+ var FormItem = React5.forwardRef(({ className, ...props }, ref) => {
2757
+ const id = React5.useId();
2758
+ return /* @__PURE__ */ React5.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React5.createElement("div", { ref, className: cn("space-y-2", className), ...props }));
2737
2759
  });
2738
2760
  FormItem.displayName = "FormItem";
2739
- var FormLabel = React4.forwardRef(({ className, ...props }, ref) => {
2761
+ var FormLabel = React5.forwardRef(({ className, ...props }, ref) => {
2740
2762
  const { error, formItemId } = useFormField();
2741
- return /* @__PURE__ */ React4.createElement(
2763
+ return /* @__PURE__ */ React5.createElement(
2742
2764
  Label,
2743
2765
  {
2744
2766
  ref,
@@ -2749,9 +2771,9 @@ var FormLabel = React4.forwardRef(({ className, ...props }, ref) => {
2749
2771
  );
2750
2772
  });
2751
2773
  FormLabel.displayName = "FormLabel";
2752
- var FormControl = React4.forwardRef(({ ...props }, ref) => {
2774
+ var FormControl = React5.forwardRef(({ ...props }, ref) => {
2753
2775
  const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
2754
- return /* @__PURE__ */ React4.createElement(
2776
+ return /* @__PURE__ */ React5.createElement(
2755
2777
  import_react_slot3.Slot,
2756
2778
  {
2757
2779
  ref,
@@ -2763,9 +2785,9 @@ var FormControl = React4.forwardRef(({ ...props }, ref) => {
2763
2785
  );
2764
2786
  });
2765
2787
  FormControl.displayName = "FormControl";
2766
- var FormDescription = React4.forwardRef(({ className, ...props }, ref) => {
2788
+ var FormDescription = React5.forwardRef(({ className, ...props }, ref) => {
2767
2789
  const { formDescriptionId } = useFormField();
2768
- return /* @__PURE__ */ React4.createElement(
2790
+ return /* @__PURE__ */ React5.createElement(
2769
2791
  "p",
2770
2792
  {
2771
2793
  ref,
@@ -2776,13 +2798,13 @@ var FormDescription = React4.forwardRef(({ className, ...props }, ref) => {
2776
2798
  );
2777
2799
  });
2778
2800
  FormDescription.displayName = "FormDescription";
2779
- var FormMessage = React4.forwardRef(({ className, children, ...props }, ref) => {
2801
+ var FormMessage = React5.forwardRef(({ className, children, ...props }, ref) => {
2780
2802
  const { error, formMessageId } = useFormField();
2781
2803
  const body = error ? String(error?.message) : children;
2782
2804
  if (!body) {
2783
2805
  return null;
2784
2806
  }
2785
- return /* @__PURE__ */ React4.createElement(
2807
+ return /* @__PURE__ */ React5.createElement(
2786
2808
  "p",
2787
2809
  {
2788
2810
  ref,
@@ -2794,26 +2816,47 @@ var FormMessage = React4.forwardRef(({ className, children, ...props }, ref) =>
2794
2816
  );
2795
2817
  });
2796
2818
  FormMessage.displayName = "FormMessage";
2797
-
2798
- // components/ui/input.tsx
2799
- var React5 = __toESM(require("react"));
2800
- var Input = React5.forwardRef(
2801
- ({ className, type, ...props }, ref) => {
2802
- return /* @__PURE__ */ React5.createElement(
2803
- "input",
2804
- {
2805
- type,
2806
- className: cn(
2807
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2808
- className
2809
- ),
2810
- ref,
2811
- ...props
2819
+ var Email = () => {
2820
+ const form = (0, import_react_hook_form.useFormContext)();
2821
+ return /* @__PURE__ */ React5.createElement(
2822
+ FormField,
2823
+ {
2824
+ control: form.control,
2825
+ name: "email",
2826
+ render: ({ field }) => {
2827
+ return /* @__PURE__ */ React5.createElement(FormItem, null, /* @__PURE__ */ React5.createElement(FormLabel, null, "Email"), /* @__PURE__ */ React5.createElement(FormControl, null, /* @__PURE__ */ React5.createElement(
2828
+ Input,
2829
+ {
2830
+ placeholder: "Email",
2831
+ ...field,
2832
+ autoComplete: "current-email"
2833
+ }
2834
+ )), /* @__PURE__ */ React5.createElement(FormDescription, null, "Your email address"), /* @__PURE__ */ React5.createElement(FormMessage, null));
2812
2835
  }
2813
- );
2814
- }
2815
- );
2816
- Input.displayName = "Input";
2836
+ }
2837
+ );
2838
+ };
2839
+ var Password = () => {
2840
+ const form = (0, import_react_hook_form.useFormContext)();
2841
+ return /* @__PURE__ */ React5.createElement(
2842
+ FormField,
2843
+ {
2844
+ control: form.control,
2845
+ name: "password",
2846
+ render: ({ field }) => {
2847
+ return /* @__PURE__ */ React5.createElement(FormItem, null, /* @__PURE__ */ React5.createElement(FormLabel, null, "Password"), /* @__PURE__ */ React5.createElement(FormControl, null, /* @__PURE__ */ React5.createElement(
2848
+ Input,
2849
+ {
2850
+ placeholder: "Password",
2851
+ ...field,
2852
+ type: "password",
2853
+ autoComplete: "current-password"
2854
+ }
2855
+ )), /* @__PURE__ */ React5.createElement(FormDescription, null, "The desired password"), /* @__PURE__ */ React5.createElement(FormMessage, null));
2856
+ }
2857
+ }
2858
+ );
2859
+ };
2817
2860
 
2818
2861
  // src/SignUpForm/hooks.tsx
2819
2862
  var import_react_query = require("@tanstack/react-query");
@@ -2823,8 +2866,20 @@ function useSignUp(params) {
2823
2866
  mutationFn: async (_data) => {
2824
2867
  const possibleData = beforeMutate && beforeMutate(_data);
2825
2868
  const payload = { ..._data, ...possibleData };
2826
- return await fetch(`${window.location.origin}/api/users`, {
2827
- body: JSON.stringify(payload),
2869
+ const { tenantId, newTenantName, ...body } = payload;
2870
+ let fetchUrl = `${window.location.origin}/api/users`;
2871
+ const searchParams = new URLSearchParams();
2872
+ if (newTenantName) {
2873
+ searchParams.set("newTenantName", newTenantName);
2874
+ }
2875
+ if (tenantId) {
2876
+ searchParams.set("tenantId", tenantId);
2877
+ }
2878
+ if (searchParams.size > 0) {
2879
+ fetchUrl += `?${searchParams}`;
2880
+ }
2881
+ return await fetch(fetchUrl, {
2882
+ body: JSON.stringify(body),
2828
2883
  method: "POST"
2829
2884
  });
2830
2885
  },
@@ -2851,41 +2906,8 @@ function SignInForm(props) {
2851
2906
  ),
2852
2907
  className: "space-y-8"
2853
2908
  },
2854
- /* @__PURE__ */ import_react3.default.createElement(
2855
- FormField,
2856
- {
2857
- control: form.control,
2858
- name: "email",
2859
- render: ({ field }) => {
2860
- return /* @__PURE__ */ import_react3.default.createElement(FormItem, null, /* @__PURE__ */ import_react3.default.createElement(FormLabel, null, "Email"), /* @__PURE__ */ import_react3.default.createElement(FormControl, null, /* @__PURE__ */ import_react3.default.createElement(
2861
- Input,
2862
- {
2863
- placeholder: "Email",
2864
- ...field,
2865
- autoComplete: "current-email"
2866
- }
2867
- )), /* @__PURE__ */ import_react3.default.createElement(FormDescription, null, "Your email address."), /* @__PURE__ */ import_react3.default.createElement(FormMessage, null));
2868
- }
2869
- }
2870
- ),
2871
- /* @__PURE__ */ import_react3.default.createElement(
2872
- FormField,
2873
- {
2874
- control: form.control,
2875
- name: "password",
2876
- render: ({ field }) => {
2877
- return /* @__PURE__ */ import_react3.default.createElement(FormItem, null, /* @__PURE__ */ import_react3.default.createElement(FormLabel, null, "Password"), /* @__PURE__ */ import_react3.default.createElement(FormControl, null, /* @__PURE__ */ import_react3.default.createElement(
2878
- Input,
2879
- {
2880
- placeholder: "Password",
2881
- ...field,
2882
- type: "password",
2883
- autoComplete: "current-password"
2884
- }
2885
- )), /* @__PURE__ */ import_react3.default.createElement(FormDescription, null, "Your password."), /* @__PURE__ */ import_react3.default.createElement(FormMessage, null));
2886
- }
2887
- }
2888
- ),
2909
+ /* @__PURE__ */ import_react3.default.createElement(Email, null),
2910
+ /* @__PURE__ */ import_react3.default.createElement(Password, null),
2889
2911
  /* @__PURE__ */ import_react3.default.createElement(Button, null, "Sign up")
2890
2912
  ));
2891
2913
  }
@@ -2938,41 +2960,8 @@ function SignInForm2(props) {
2938
2960
  ),
2939
2961
  className: "space-y-8"
2940
2962
  },
2941
- /* @__PURE__ */ import_react6.default.createElement(
2942
- FormField,
2943
- {
2944
- control: form.control,
2945
- name: "email",
2946
- render: ({ field }) => {
2947
- return /* @__PURE__ */ import_react6.default.createElement(FormItem, null, /* @__PURE__ */ import_react6.default.createElement(FormLabel, null, "Email"), /* @__PURE__ */ import_react6.default.createElement(FormControl, null, /* @__PURE__ */ import_react6.default.createElement(
2948
- Input,
2949
- {
2950
- placeholder: "Email",
2951
- ...field,
2952
- autoComplete: "current-email"
2953
- }
2954
- )), /* @__PURE__ */ import_react6.default.createElement(FormDescription, null, "The email of a user."), /* @__PURE__ */ import_react6.default.createElement(FormMessage, null));
2955
- }
2956
- }
2957
- ),
2958
- /* @__PURE__ */ import_react6.default.createElement(
2959
- FormField,
2960
- {
2961
- control: form.control,
2962
- name: "password",
2963
- render: ({ field }) => {
2964
- return /* @__PURE__ */ import_react6.default.createElement(FormItem, null, /* @__PURE__ */ import_react6.default.createElement(FormLabel, null, "Password"), /* @__PURE__ */ import_react6.default.createElement(FormControl, null, /* @__PURE__ */ import_react6.default.createElement(
2965
- Input,
2966
- {
2967
- placeholder: "Password",
2968
- ...field,
2969
- type: "password",
2970
- autoComplete: "current-password"
2971
- }
2972
- )), /* @__PURE__ */ import_react6.default.createElement(FormDescription, null, "The desired password."), /* @__PURE__ */ import_react6.default.createElement(FormMessage, null));
2973
- }
2974
- }
2975
- ),
2963
+ /* @__PURE__ */ import_react6.default.createElement(Email, null),
2964
+ /* @__PURE__ */ import_react6.default.createElement(Password, null),
2976
2965
  /* @__PURE__ */ import_react6.default.createElement(Button, { type: "submit" }, "Sign In")
2977
2966
  ));
2978
2967
  }
@@ -2986,7 +2975,9 @@ function SigningIn2(props) {
2986
2975
  __reExport(src_exports, require("next-auth/react"), module.exports);
2987
2976
  // Annotate the CommonJS export names for ESM import in node:
2988
2977
  0 && (module.exports = {
2978
+ Email,
2989
2979
  Google,
2980
+ Password,
2990
2981
  SignInForm,
2991
2982
  SignUpForm,
2992
2983
  useSignIn,
package/dist/index.mjs CHANGED
@@ -2641,7 +2641,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2641
2641
  import { useForm } from "react-hook-form";
2642
2642
 
2643
2643
  // components/ui/form.tsx
2644
- import * as React4 from "react";
2644
+ import * as React5 from "react";
2645
2645
  import { Slot as Slot3 } from "@radix-ui/react-slot";
2646
2646
  import {
2647
2647
  Controller,
@@ -2665,17 +2665,37 @@ var Label = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
2665
2665
  ));
2666
2666
  Label.displayName = LabelPrimitive.Root.displayName;
2667
2667
 
2668
+ // components/ui/input.tsx
2669
+ import * as React4 from "react";
2670
+ var Input = React4.forwardRef(
2671
+ ({ className, type, ...props }, ref) => {
2672
+ return /* @__PURE__ */ React4.createElement(
2673
+ "input",
2674
+ {
2675
+ type,
2676
+ className: cn(
2677
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2678
+ className
2679
+ ),
2680
+ ref,
2681
+ ...props
2682
+ }
2683
+ );
2684
+ }
2685
+ );
2686
+ Input.displayName = "Input";
2687
+
2668
2688
  // components/ui/form.tsx
2669
2689
  var Form = FormProvider;
2670
- var FormFieldContext = React4.createContext(
2690
+ var FormFieldContext = React5.createContext(
2671
2691
  {}
2672
2692
  );
2673
2693
  var FormField = ({ ...props }) => {
2674
- return /* @__PURE__ */ React4.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React4.createElement(Controller, { ...props }));
2694
+ return /* @__PURE__ */ React5.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React5.createElement(Controller, { ...props }));
2675
2695
  };
2676
2696
  var useFormField = () => {
2677
- const fieldContext = React4.useContext(FormFieldContext);
2678
- const itemContext = React4.useContext(FormItemContext);
2697
+ const fieldContext = React5.useContext(FormFieldContext);
2698
+ const itemContext = React5.useContext(FormItemContext);
2679
2699
  const { getFieldState, formState } = useFormContext();
2680
2700
  const fieldState = getFieldState(fieldContext.name, formState);
2681
2701
  if (!fieldContext) {
@@ -2691,17 +2711,17 @@ var useFormField = () => {
2691
2711
  ...fieldState
2692
2712
  };
2693
2713
  };
2694
- var FormItemContext = React4.createContext(
2714
+ var FormItemContext = React5.createContext(
2695
2715
  {}
2696
2716
  );
2697
- var FormItem = React4.forwardRef(({ className, ...props }, ref) => {
2698
- const id = React4.useId();
2699
- return /* @__PURE__ */ React4.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React4.createElement("div", { ref, className: cn("space-y-2", className), ...props }));
2717
+ var FormItem = React5.forwardRef(({ className, ...props }, ref) => {
2718
+ const id = React5.useId();
2719
+ return /* @__PURE__ */ React5.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React5.createElement("div", { ref, className: cn("space-y-2", className), ...props }));
2700
2720
  });
2701
2721
  FormItem.displayName = "FormItem";
2702
- var FormLabel = React4.forwardRef(({ className, ...props }, ref) => {
2722
+ var FormLabel = React5.forwardRef(({ className, ...props }, ref) => {
2703
2723
  const { error, formItemId } = useFormField();
2704
- return /* @__PURE__ */ React4.createElement(
2724
+ return /* @__PURE__ */ React5.createElement(
2705
2725
  Label,
2706
2726
  {
2707
2727
  ref,
@@ -2712,9 +2732,9 @@ var FormLabel = React4.forwardRef(({ className, ...props }, ref) => {
2712
2732
  );
2713
2733
  });
2714
2734
  FormLabel.displayName = "FormLabel";
2715
- var FormControl = React4.forwardRef(({ ...props }, ref) => {
2735
+ var FormControl = React5.forwardRef(({ ...props }, ref) => {
2716
2736
  const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
2717
- return /* @__PURE__ */ React4.createElement(
2737
+ return /* @__PURE__ */ React5.createElement(
2718
2738
  Slot3,
2719
2739
  {
2720
2740
  ref,
@@ -2726,9 +2746,9 @@ var FormControl = React4.forwardRef(({ ...props }, ref) => {
2726
2746
  );
2727
2747
  });
2728
2748
  FormControl.displayName = "FormControl";
2729
- var FormDescription = React4.forwardRef(({ className, ...props }, ref) => {
2749
+ var FormDescription = React5.forwardRef(({ className, ...props }, ref) => {
2730
2750
  const { formDescriptionId } = useFormField();
2731
- return /* @__PURE__ */ React4.createElement(
2751
+ return /* @__PURE__ */ React5.createElement(
2732
2752
  "p",
2733
2753
  {
2734
2754
  ref,
@@ -2739,13 +2759,13 @@ var FormDescription = React4.forwardRef(({ className, ...props }, ref) => {
2739
2759
  );
2740
2760
  });
2741
2761
  FormDescription.displayName = "FormDescription";
2742
- var FormMessage = React4.forwardRef(({ className, children, ...props }, ref) => {
2762
+ var FormMessage = React5.forwardRef(({ className, children, ...props }, ref) => {
2743
2763
  const { error, formMessageId } = useFormField();
2744
2764
  const body = error ? String(error?.message) : children;
2745
2765
  if (!body) {
2746
2766
  return null;
2747
2767
  }
2748
- return /* @__PURE__ */ React4.createElement(
2768
+ return /* @__PURE__ */ React5.createElement(
2749
2769
  "p",
2750
2770
  {
2751
2771
  ref,
@@ -2757,26 +2777,47 @@ var FormMessage = React4.forwardRef(({ className, children, ...props }, ref) =>
2757
2777
  );
2758
2778
  });
2759
2779
  FormMessage.displayName = "FormMessage";
2760
-
2761
- // components/ui/input.tsx
2762
- import * as React5 from "react";
2763
- var Input = React5.forwardRef(
2764
- ({ className, type, ...props }, ref) => {
2765
- return /* @__PURE__ */ React5.createElement(
2766
- "input",
2767
- {
2768
- type,
2769
- className: cn(
2770
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2771
- className
2772
- ),
2773
- ref,
2774
- ...props
2780
+ var Email = () => {
2781
+ const form = useFormContext();
2782
+ return /* @__PURE__ */ React5.createElement(
2783
+ FormField,
2784
+ {
2785
+ control: form.control,
2786
+ name: "email",
2787
+ render: ({ field }) => {
2788
+ return /* @__PURE__ */ React5.createElement(FormItem, null, /* @__PURE__ */ React5.createElement(FormLabel, null, "Email"), /* @__PURE__ */ React5.createElement(FormControl, null, /* @__PURE__ */ React5.createElement(
2789
+ Input,
2790
+ {
2791
+ placeholder: "Email",
2792
+ ...field,
2793
+ autoComplete: "current-email"
2794
+ }
2795
+ )), /* @__PURE__ */ React5.createElement(FormDescription, null, "Your email address"), /* @__PURE__ */ React5.createElement(FormMessage, null));
2775
2796
  }
2776
- );
2777
- }
2778
- );
2779
- Input.displayName = "Input";
2797
+ }
2798
+ );
2799
+ };
2800
+ var Password = () => {
2801
+ const form = useFormContext();
2802
+ return /* @__PURE__ */ React5.createElement(
2803
+ FormField,
2804
+ {
2805
+ control: form.control,
2806
+ name: "password",
2807
+ render: ({ field }) => {
2808
+ return /* @__PURE__ */ React5.createElement(FormItem, null, /* @__PURE__ */ React5.createElement(FormLabel, null, "Password"), /* @__PURE__ */ React5.createElement(FormControl, null, /* @__PURE__ */ React5.createElement(
2809
+ Input,
2810
+ {
2811
+ placeholder: "Password",
2812
+ ...field,
2813
+ type: "password",
2814
+ autoComplete: "current-password"
2815
+ }
2816
+ )), /* @__PURE__ */ React5.createElement(FormDescription, null, "The desired password"), /* @__PURE__ */ React5.createElement(FormMessage, null));
2817
+ }
2818
+ }
2819
+ );
2820
+ };
2780
2821
 
2781
2822
  // src/SignUpForm/hooks.tsx
2782
2823
  import { useMutation } from "@tanstack/react-query";
@@ -2786,8 +2827,20 @@ function useSignUp(params) {
2786
2827
  mutationFn: async (_data) => {
2787
2828
  const possibleData = beforeMutate && beforeMutate(_data);
2788
2829
  const payload = { ..._data, ...possibleData };
2789
- return await fetch(`${window.location.origin}/api/users`, {
2790
- body: JSON.stringify(payload),
2830
+ const { tenantId, newTenantName, ...body } = payload;
2831
+ let fetchUrl = `${window.location.origin}/api/users`;
2832
+ const searchParams = new URLSearchParams();
2833
+ if (newTenantName) {
2834
+ searchParams.set("newTenantName", newTenantName);
2835
+ }
2836
+ if (tenantId) {
2837
+ searchParams.set("tenantId", tenantId);
2838
+ }
2839
+ if (searchParams.size > 0) {
2840
+ fetchUrl += `?${searchParams}`;
2841
+ }
2842
+ return await fetch(fetchUrl, {
2843
+ body: JSON.stringify(body),
2791
2844
  method: "POST"
2792
2845
  });
2793
2846
  },
@@ -2814,41 +2867,8 @@ function SignInForm(props) {
2814
2867
  ),
2815
2868
  className: "space-y-8"
2816
2869
  },
2817
- /* @__PURE__ */ React6.createElement(
2818
- FormField,
2819
- {
2820
- control: form.control,
2821
- name: "email",
2822
- render: ({ field }) => {
2823
- return /* @__PURE__ */ React6.createElement(FormItem, null, /* @__PURE__ */ React6.createElement(FormLabel, null, "Email"), /* @__PURE__ */ React6.createElement(FormControl, null, /* @__PURE__ */ React6.createElement(
2824
- Input,
2825
- {
2826
- placeholder: "Email",
2827
- ...field,
2828
- autoComplete: "current-email"
2829
- }
2830
- )), /* @__PURE__ */ React6.createElement(FormDescription, null, "Your email address."), /* @__PURE__ */ React6.createElement(FormMessage, null));
2831
- }
2832
- }
2833
- ),
2834
- /* @__PURE__ */ React6.createElement(
2835
- FormField,
2836
- {
2837
- control: form.control,
2838
- name: "password",
2839
- render: ({ field }) => {
2840
- return /* @__PURE__ */ React6.createElement(FormItem, null, /* @__PURE__ */ React6.createElement(FormLabel, null, "Password"), /* @__PURE__ */ React6.createElement(FormControl, null, /* @__PURE__ */ React6.createElement(
2841
- Input,
2842
- {
2843
- placeholder: "Password",
2844
- ...field,
2845
- type: "password",
2846
- autoComplete: "current-password"
2847
- }
2848
- )), /* @__PURE__ */ React6.createElement(FormDescription, null, "Your password."), /* @__PURE__ */ React6.createElement(FormMessage, null));
2849
- }
2850
- }
2851
- ),
2870
+ /* @__PURE__ */ React6.createElement(Email, null),
2871
+ /* @__PURE__ */ React6.createElement(Password, null),
2852
2872
  /* @__PURE__ */ React6.createElement(Button, null, "Sign up")
2853
2873
  ));
2854
2874
  }
@@ -2901,41 +2921,8 @@ function SignInForm2(props) {
2901
2921
  ),
2902
2922
  className: "space-y-8"
2903
2923
  },
2904
- /* @__PURE__ */ React8.createElement(
2905
- FormField,
2906
- {
2907
- control: form.control,
2908
- name: "email",
2909
- render: ({ field }) => {
2910
- return /* @__PURE__ */ React8.createElement(FormItem, null, /* @__PURE__ */ React8.createElement(FormLabel, null, "Email"), /* @__PURE__ */ React8.createElement(FormControl, null, /* @__PURE__ */ React8.createElement(
2911
- Input,
2912
- {
2913
- placeholder: "Email",
2914
- ...field,
2915
- autoComplete: "current-email"
2916
- }
2917
- )), /* @__PURE__ */ React8.createElement(FormDescription, null, "The email of a user."), /* @__PURE__ */ React8.createElement(FormMessage, null));
2918
- }
2919
- }
2920
- ),
2921
- /* @__PURE__ */ React8.createElement(
2922
- FormField,
2923
- {
2924
- control: form.control,
2925
- name: "password",
2926
- render: ({ field }) => {
2927
- return /* @__PURE__ */ React8.createElement(FormItem, null, /* @__PURE__ */ React8.createElement(FormLabel, null, "Password"), /* @__PURE__ */ React8.createElement(FormControl, null, /* @__PURE__ */ React8.createElement(
2928
- Input,
2929
- {
2930
- placeholder: "Password",
2931
- ...field,
2932
- type: "password",
2933
- autoComplete: "current-password"
2934
- }
2935
- )), /* @__PURE__ */ React8.createElement(FormDescription, null, "The desired password."), /* @__PURE__ */ React8.createElement(FormMessage, null));
2936
- }
2937
- }
2938
- ),
2924
+ /* @__PURE__ */ React8.createElement(Email, null),
2925
+ /* @__PURE__ */ React8.createElement(Password, null),
2939
2926
  /* @__PURE__ */ React8.createElement(Button, { type: "submit" }, "Sign In")
2940
2927
  ));
2941
2928
  }
@@ -2948,7 +2935,9 @@ function SigningIn2(props) {
2948
2935
  // src/index.ts
2949
2936
  export * from "next-auth/react";
2950
2937
  export {
2938
+ Email,
2951
2939
  GoogleLoginButton_default as Google,
2940
+ Password,
2952
2941
  SigningIn2 as SignInForm,
2953
2942
  SigningUp as SignUpForm,
2954
2943
  useSignIn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niledatabase/react",
3
- "version": "3.0.0-alpha.25",
3
+ "version": "3.0.0-alpha.27",
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.25",
122
+ "@niledatabase/browser": "^3.0.0-alpha.27",
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": "e1efd27d3fe15003fd3599274e3461c566b125d9"
132
+ "gitHead": "ce5a43c0d003ceb130211b8f4d5e0c422820e964"
133
133
  }