better-auth-ui 3.2.13 → 3.2.15

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.
Files changed (40) hide show
  1. package/dist/{auth-hooks-IOEvlYYv.d.cts → auth-hooks-BuniCu20.d.cts} +5 -4
  2. package/dist/{auth-hooks-IOEvlYYv.d.ts → auth-hooks-BuniCu20.d.ts} +5 -4
  3. package/dist/{auth-ui-provider-DhZfncd3.d.cts → auth-ui-provider-D3GrYvcj.d.cts} +3 -18
  4. package/dist/{auth-ui-provider-BsH3xJDw.d.ts → auth-ui-provider-mrVNJ6zj.d.ts} +3 -18
  5. package/dist/{chunk-CRAHKL2C.cjs → chunk-42PRTYAB.cjs} +11 -1
  6. package/dist/{chunk-BDFQSFBU.js → chunk-BJHZPU6H.js} +77 -77
  7. package/dist/{chunk-SV64DXGW.cjs → chunk-GB6DYT26.cjs} +79 -79
  8. package/dist/{chunk-MJPOA6PK.js → chunk-YTGCDVH4.js} +10 -0
  9. package/dist/index.cjs +609 -554
  10. package/dist/index.d.cts +81 -13
  11. package/dist/index.d.ts +81 -13
  12. package/dist/index.js +134 -79
  13. package/dist/instantdb.d.cts +1 -1
  14. package/dist/instantdb.d.ts +1 -1
  15. package/dist/metafile-cjs.json +1 -1
  16. package/dist/metafile-esm.json +1 -1
  17. package/dist/server.cjs +10 -10
  18. package/dist/server.d.cts +4 -2
  19. package/dist/server.d.ts +4 -2
  20. package/dist/server.js +1 -1
  21. package/dist/tanstack.cjs +3 -3
  22. package/dist/tanstack.d.cts +3 -3
  23. package/dist/tanstack.d.ts +3 -3
  24. package/dist/tanstack.js +2 -2
  25. package/dist/triplit.d.cts +1 -1
  26. package/dist/triplit.d.ts +1 -1
  27. package/dist/utils-CaN43O_Z.d.cts +24 -0
  28. package/dist/utils-yT5zrMzq.d.ts +24 -0
  29. package/dist/{view-paths-CHSJf5dv.d.ts → view-paths-CIL7NXLh.d.cts} +16 -1
  30. package/dist/{view-paths-CHSJf5dv.d.cts → view-paths-CIL7NXLh.d.ts} +16 -1
  31. package/package.json +5 -3
  32. package/src/components/auth/forms/email-otp-form.tsx +4 -4
  33. package/src/components/organization/organization-members-card.tsx +3 -1
  34. package/src/components/settings/account/update-name-card.tsx +2 -0
  35. package/src/components/settings/account/update-username-card.tsx +2 -0
  36. package/src/components/settings/account-settings-cards.tsx +8 -6
  37. package/src/components/settings/security/change-email-card.tsx +2 -0
  38. package/src/index.ts +28 -1
  39. package/dist/utils-C5R37WDe.d.cts +0 -3
  40. package/dist/utils-C5R37WDe.d.ts +0 -3
@@ -1,7 +1,7 @@
1
1
  import * as _better_fetch_fetch from '@better-fetch/fetch';
2
2
  import { BetterFetchError } from '@better-fetch/fetch';
3
3
  import * as better_auth from 'better-auth';
4
- import { Account, User } from 'better-auth';
4
+ import { Account, User as User$1 } from 'better-auth';
5
5
  import * as better_auth_plugins_organization from 'better-auth/plugins/organization';
6
6
  import { Member } from 'better-auth/plugins/organization';
7
7
  import * as better_auth_react from 'better-auth/react';
@@ -6902,6 +6902,7 @@ declare const authClient: {
6902
6902
  };
6903
6903
  type AuthClient = typeof authClient;
6904
6904
  type Session = AuthClient["$Infer"]["Session"]["session"];
6905
+ type User = AuthClient["$Infer"]["Session"]["user"];
6905
6906
 
6906
6907
  type ApiKey = {
6907
6908
  id: string;
@@ -6935,7 +6936,7 @@ type AuthHooks = {
6935
6936
  useSession: () => ReturnType<AnyAuthClient["useSession"]>;
6936
6937
  useListAccounts: () => AuthHook<Account[]>;
6937
6938
  useAccountInfo: (params: Parameters<AuthClient["accountInfo"]>[0]) => AuthHook<{
6938
- user: User;
6939
+ user: User$1;
6939
6940
  }>;
6940
6941
  useListDeviceSessions: () => AuthHook<AnyAuthClient["$Infer"]["Session"][]>;
6941
6942
  useListSessions: () => AuthHook<AnyAuthSession["session"][]>;
@@ -6956,11 +6957,11 @@ type AuthHooks = {
6956
6957
  useListUserInvitations: () => AuthHook<Invitation[]>;
6957
6958
  useListMembers: (params: Parameters<AuthClient["organization"]["listMembers"]>[0]) => AuthHook<{
6958
6959
  members: (Member & {
6959
- user?: Partial<User> | null;
6960
+ user?: Partial<User$1> | null;
6960
6961
  })[];
6961
6962
  total: number;
6962
6963
  }>;
6963
6964
  useIsRestoring?: () => boolean;
6964
6965
  };
6965
6966
 
6966
- export type { AnyAuthClient as A, Refetch as R, Session as S, AuthHooks as a, AuthClient as b };
6967
+ export { type AnyAuthClient as A, type Refetch as R, type Session as S, type User as U, authClient as a, type AuthClient as b, type AuthHooks as c };
@@ -1,7 +1,7 @@
1
1
  import * as _better_fetch_fetch from '@better-fetch/fetch';
2
2
  import { BetterFetchError } from '@better-fetch/fetch';
3
3
  import * as better_auth from 'better-auth';
4
- import { Account, User } from 'better-auth';
4
+ import { Account, User as User$1 } from 'better-auth';
5
5
  import * as better_auth_plugins_organization from 'better-auth/plugins/organization';
6
6
  import { Member } from 'better-auth/plugins/organization';
7
7
  import * as better_auth_react from 'better-auth/react';
@@ -6902,6 +6902,7 @@ declare const authClient: {
6902
6902
  };
6903
6903
  type AuthClient = typeof authClient;
6904
6904
  type Session = AuthClient["$Infer"]["Session"]["session"];
6905
+ type User = AuthClient["$Infer"]["Session"]["user"];
6905
6906
 
6906
6907
  type ApiKey = {
6907
6908
  id: string;
@@ -6935,7 +6936,7 @@ type AuthHooks = {
6935
6936
  useSession: () => ReturnType<AnyAuthClient["useSession"]>;
6936
6937
  useListAccounts: () => AuthHook<Account[]>;
6937
6938
  useAccountInfo: (params: Parameters<AuthClient["accountInfo"]>[0]) => AuthHook<{
6938
- user: User;
6939
+ user: User$1;
6939
6940
  }>;
6940
6941
  useListDeviceSessions: () => AuthHook<AnyAuthClient["$Infer"]["Session"][]>;
6941
6942
  useListSessions: () => AuthHook<AnyAuthSession["session"][]>;
@@ -6956,11 +6957,11 @@ type AuthHooks = {
6956
6957
  useListUserInvitations: () => AuthHook<Invitation[]>;
6957
6958
  useListMembers: (params: Parameters<AuthClient["organization"]["listMembers"]>[0]) => AuthHook<{
6958
6959
  members: (Member & {
6959
- user?: Partial<User> | null;
6960
+ user?: Partial<User$1> | null;
6960
6961
  })[];
6961
6962
  total: number;
6962
6963
  }>;
6963
6964
  useIsRestoring?: () => boolean;
6964
6965
  };
6965
6966
 
6966
- export type { AnyAuthClient as A, Refetch as R, Session as S, AuthHooks as a, AuthClient as b };
6967
+ export { type AnyAuthClient as A, type Refetch as R, type Session as S, type User as U, authClient as a, type AuthClient as b, type AuthHooks as c };
@@ -1,26 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode } from 'react';
4
- import { f as AccountViewPaths, g as OrganizationViewPaths, h as authLocalization, c as AuthViewPaths, A as AuthLocalization } from './view-paths-CHSJf5dv.cjs';
5
- import { b as AuthClient, a as AuthHooks, A as AnyAuthClient } from './auth-hooks-IOEvlYYv.cjs';
4
+ import { f as AccountViewPaths, P as PasswordValidation, g as OrganizationViewPaths, h as authLocalization, c as AuthViewPaths, A as AuthLocalization } from './view-paths-CIL7NXLh.cjs';
5
+ import { b as AuthClient, c as AuthHooks, A as AnyAuthClient } from './auth-hooks-BuniCu20.cjs';
6
6
  import { A as AuthMutators } from './auth-mutators-DdqOmQ32.cjs';
7
7
  import { SocialProvider } from 'better-auth/social-providers';
8
8
 
9
- type PasswordValidation = {
10
- /**
11
- * Maximum password length
12
- */
13
- maxLength?: number;
14
- /**
15
- * Minimum password length
16
- */
17
- minLength?: number;
18
- /**
19
- * Password validation regex
20
- */
21
- regex?: RegExp;
22
- };
23
-
24
9
  interface ProviderIconProps {
25
10
  className?: string;
26
11
  }
@@ -694,4 +679,4 @@ type AuthUIProviderProps = {
694
679
  declare const AuthUIContext: React.Context<AuthUIContextType>;
695
680
  declare const AuthUIProvider: ({ children, authClient: authClientProp, account: accountProp, avatar: avatarProp, deleteUser: deleteUserProp, social: socialProp, genericOAuth: genericOAuthProp, basePath, baseURL, captcha, redirectTo, credentials: credentialsProp, changeEmail, freshAge, hooks: hooksProp, mutators: mutatorsProp, localization: localizationProp, nameRequired, organization: organizationProp, signUp: signUpProp, toast, viewPaths: viewPathsProp, navigate, replace, Link, ...props }: AuthUIProviderProps) => react_jsx_runtime.JSX.Element;
696
681
 
697
- export { AppleIcon as A, DiscordIcon as D, type FieldType as F, GitHubIcon as G, HuggingFaceIcon as H, KickIcon as K, LinearIcon as L, MicrosoftIcon as M, NotionIcon as N, type PasswordValidation as P, RedditIcon as R, SlackIcon as S, TikTokIcon as T, VKIcon as V, XIcon as X, ZoomIcon as Z, type ProviderIconProps as a, type ProviderIcon as b, DropboxIcon as c, FacebookIcon as d, GitLabIcon as e, GoogleIcon as f, LinkedInIcon as g, RobloxIcon as h, SpotifyIcon as i, TwitchIcon as j, type AuthUIContextType as k, type AuthUIProviderProps as l, AuthUIContext as m, AuthUIProvider as n, type Provider as o, socialProviders as s };
682
+ export { AppleIcon as A, type OrganizationOptionsContext as B, type CaptchaOptions as C, DiscordIcon as D, type RenderToast as E, type FieldType as F, type GravatarOptions as G, HuggingFaceIcon as H, type SignUpOptions as I, type SocialOptions as J, KickIcon as K, LinearIcon as L, MicrosoftIcon as M, NotionIcon as N, type OrganizationLogoOptions as O, type ProviderIconProps as P, RedditIcon as R, SlackIcon as S, TikTokIcon as T, VKIcon as V, XIcon as X, ZoomIcon as Z, type ProviderIcon as a, DropboxIcon as b, FacebookIcon as c, GitHubIcon as d, GitLabIcon as e, GoogleIcon as f, LinkedInIcon as g, RobloxIcon as h, SpotifyIcon as i, TwitchIcon as j, type AuthUIContextType as k, type AuthUIProviderProps as l, AuthUIContext as m, AuthUIProvider as n, type Provider as o, type AccountOptions as p, type AccountOptionsContext as q, type AdditionalField as r, socialProviders as s, type AdditionalFields as t, type AvatarOptions as u, type CredentialsOptions as v, type DeleteUserOptions as w, type GenericOAuthOptions as x, type Link as y, type OrganizationOptions as z };
@@ -1,26 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode } from 'react';
4
- import { f as AccountViewPaths, g as OrganizationViewPaths, h as authLocalization, c as AuthViewPaths, A as AuthLocalization } from './view-paths-CHSJf5dv.js';
5
- import { b as AuthClient, a as AuthHooks, A as AnyAuthClient } from './auth-hooks-IOEvlYYv.js';
4
+ import { f as AccountViewPaths, P as PasswordValidation, g as OrganizationViewPaths, h as authLocalization, c as AuthViewPaths, A as AuthLocalization } from './view-paths-CIL7NXLh.js';
5
+ import { b as AuthClient, c as AuthHooks, A as AnyAuthClient } from './auth-hooks-BuniCu20.js';
6
6
  import { A as AuthMutators } from './auth-mutators-DdqOmQ32.js';
7
7
  import { SocialProvider } from 'better-auth/social-providers';
8
8
 
9
- type PasswordValidation = {
10
- /**
11
- * Maximum password length
12
- */
13
- maxLength?: number;
14
- /**
15
- * Minimum password length
16
- */
17
- minLength?: number;
18
- /**
19
- * Password validation regex
20
- */
21
- regex?: RegExp;
22
- };
23
-
24
9
  interface ProviderIconProps {
25
10
  className?: string;
26
11
  }
@@ -694,4 +679,4 @@ type AuthUIProviderProps = {
694
679
  declare const AuthUIContext: React.Context<AuthUIContextType>;
695
680
  declare const AuthUIProvider: ({ children, authClient: authClientProp, account: accountProp, avatar: avatarProp, deleteUser: deleteUserProp, social: socialProp, genericOAuth: genericOAuthProp, basePath, baseURL, captcha, redirectTo, credentials: credentialsProp, changeEmail, freshAge, hooks: hooksProp, mutators: mutatorsProp, localization: localizationProp, nameRequired, organization: organizationProp, signUp: signUpProp, toast, viewPaths: viewPathsProp, navigate, replace, Link, ...props }: AuthUIProviderProps) => react_jsx_runtime.JSX.Element;
696
681
 
697
- export { AppleIcon as A, DiscordIcon as D, type FieldType as F, GitHubIcon as G, HuggingFaceIcon as H, KickIcon as K, LinearIcon as L, MicrosoftIcon as M, NotionIcon as N, type PasswordValidation as P, RedditIcon as R, SlackIcon as S, TikTokIcon as T, VKIcon as V, XIcon as X, ZoomIcon as Z, type ProviderIconProps as a, type ProviderIcon as b, DropboxIcon as c, FacebookIcon as d, GitLabIcon as e, GoogleIcon as f, LinkedInIcon as g, RobloxIcon as h, SpotifyIcon as i, TwitchIcon as j, type AuthUIContextType as k, type AuthUIProviderProps as l, AuthUIContext as m, AuthUIProvider as n, type Provider as o, socialProviders as s };
682
+ export { AppleIcon as A, type OrganizationOptionsContext as B, type CaptchaOptions as C, DiscordIcon as D, type RenderToast as E, type FieldType as F, type GravatarOptions as G, HuggingFaceIcon as H, type SignUpOptions as I, type SocialOptions as J, KickIcon as K, LinearIcon as L, MicrosoftIcon as M, NotionIcon as N, type OrganizationLogoOptions as O, type ProviderIconProps as P, RedditIcon as R, SlackIcon as S, TikTokIcon as T, VKIcon as V, XIcon as X, ZoomIcon as Z, type ProviderIcon as a, DropboxIcon as b, FacebookIcon as c, GitHubIcon as d, GitLabIcon as e, GoogleIcon as f, LinkedInIcon as g, RobloxIcon as h, SpotifyIcon as i, TwitchIcon as j, type AuthUIContextType as k, type AuthUIProviderProps as l, AuthUIContext as m, AuthUIProvider as n, type Provider as o, type AccountOptions as p, type AccountOptionsContext as q, type AdditionalField as r, socialProviders as s, type AdditionalFields as t, type AvatarOptions as u, type CredentialsOptions as v, type DeleteUserOptions as w, type GenericOAuthOptions as x, type Link as y, type OrganizationOptions as z };
@@ -9,6 +9,9 @@ function isValidEmail(email) {
9
9
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
10
10
  return emailRegex.test(email);
11
11
  }
12
+ function errorCodeToCamelCase(errorCode) {
13
+ return errorCode.toLowerCase().replace(/_([a-z])/g, (_, char) => char.toUpperCase());
14
+ }
12
15
  function getLocalizedError({
13
16
  error,
14
17
  localization
@@ -36,6 +39,11 @@ function getViewByPath(viewPaths, path) {
36
39
  }
37
40
  }
38
41
  }
42
+ function getKeyByValue(object, value) {
43
+ return Object.keys(object).find(
44
+ (key) => object[key] === value
45
+ );
46
+ }
39
47
  function getPasswordSchema(passwordValidation, localization) {
40
48
  let schema = z.string().min(1, {
41
49
  message: localization == null ? void 0 : localization.PASSWORD_REQUIRED
@@ -798,4 +806,6 @@ var organizationViewPaths = {
798
806
 
799
807
 
800
808
 
801
- exports.cn = cn; exports.isValidEmail = isValidEmail; exports.getLocalizedError = getLocalizedError; exports.getSearchParam = getSearchParam; exports.getViewByPath = getViewByPath; exports.getPasswordSchema = getPasswordSchema; exports.authLocalization = authLocalization; exports.authViewPaths = authViewPaths; exports.accountViewPaths = accountViewPaths; exports.organizationViewPaths = organizationViewPaths;
809
+
810
+
811
+ exports.cn = cn; exports.isValidEmail = isValidEmail; exports.errorCodeToCamelCase = errorCodeToCamelCase; exports.getLocalizedError = getLocalizedError; exports.getSearchParam = getSearchParam; exports.getViewByPath = getViewByPath; exports.getKeyByValue = getKeyByValue; exports.getPasswordSchema = getPasswordSchema; exports.authLocalization = authLocalization; exports.authViewPaths = authViewPaths; exports.accountViewPaths = accountViewPaths; exports.organizationViewPaths = organizationViewPaths;
@@ -4,17 +4,72 @@ import {
4
4
  authViewPaths,
5
5
  getLocalizedError,
6
6
  organizationViewPaths
7
- } from "./chunk-MJPOA6PK.js";
7
+ } from "./chunk-YTGCDVH4.js";
8
8
 
9
- // src/hooks/use-auth-data.ts
10
- import {
11
- useCallback,
12
- useContext as useContext4,
13
- useEffect as useEffect5,
14
- useRef,
15
- useState as useState3,
16
- useSyncExternalStore as useSyncExternalStore2
17
- } from "react";
9
+ // src/hooks/use-hydrated.ts
10
+ import { useSyncExternalStore } from "react";
11
+ function subscribe() {
12
+ return () => {
13
+ };
14
+ }
15
+ function useIsHydrated() {
16
+ return useSyncExternalStore(
17
+ subscribe,
18
+ () => true,
19
+ () => false
20
+ );
21
+ }
22
+
23
+ // src/hooks/use-lang.ts
24
+ import { useEffect, useState } from "react";
25
+ function useLang() {
26
+ const [lang, setLang] = useState();
27
+ useEffect(() => {
28
+ const checkLang = () => {
29
+ const currentLang = document.documentElement.getAttribute("lang");
30
+ setLang(currentLang ?? void 0);
31
+ };
32
+ checkLang();
33
+ const observer = new MutationObserver((mutations) => {
34
+ for (const mutation of mutations) {
35
+ if (mutation.attributeName === "lang") {
36
+ checkLang();
37
+ }
38
+ }
39
+ });
40
+ observer.observe(document.documentElement, { attributes: true });
41
+ return () => {
42
+ observer.disconnect();
43
+ };
44
+ }, []);
45
+ return { lang };
46
+ }
47
+
48
+ // src/hooks/use-theme.ts
49
+ import { useEffect as useEffect2, useState as useState2 } from "react";
50
+ function useTheme() {
51
+ const [theme, setTheme] = useState2("light");
52
+ useEffect2(() => {
53
+ const checkTheme = () => {
54
+ var _a;
55
+ const isDark = document.documentElement.classList.contains("dark") || ((_a = document.documentElement.getAttribute("style")) == null ? void 0 : _a.includes("color-scheme: dark"));
56
+ setTheme(isDark ? "dark" : "light");
57
+ };
58
+ checkTheme();
59
+ const observer = new MutationObserver((mutations) => {
60
+ for (const mutation of mutations) {
61
+ if (mutation.attributeName === "style" || mutation.attributeName === "class") {
62
+ checkTheme();
63
+ }
64
+ }
65
+ });
66
+ observer.observe(document.documentElement, { attributes: true });
67
+ return () => {
68
+ observer.disconnect();
69
+ };
70
+ }, []);
71
+ return { theme };
72
+ }
18
73
 
19
74
  // src/lib/auth-data-cache.ts
20
75
  var AuthDataCache = class {
@@ -90,6 +145,16 @@ var AuthDataCache = class {
90
145
  };
91
146
  var authDataCache = new AuthDataCache();
92
147
 
148
+ // src/hooks/use-auth-data.ts
149
+ import {
150
+ useCallback,
151
+ useContext as useContext4,
152
+ useEffect as useEffect5,
153
+ useRef,
154
+ useState as useState3,
155
+ useSyncExternalStore as useSyncExternalStore2
156
+ } from "react";
157
+
93
158
  // src/lib/auth-ui-provider.tsx
94
159
  import { createContext, useMemo as useMemo2 } from "react";
95
160
  import { toast } from "sonner";
@@ -100,73 +165,6 @@ import {
100
165
  useGoogleReCaptcha
101
166
  } from "@wojtekmaj/react-recaptcha-v3";
102
167
  import { useContext, useEffect as useEffect3 } from "react";
103
-
104
- // src/hooks/use-hydrated.ts
105
- import { useSyncExternalStore } from "react";
106
- function subscribe() {
107
- return () => {
108
- };
109
- }
110
- function useIsHydrated() {
111
- return useSyncExternalStore(
112
- subscribe,
113
- () => true,
114
- () => false
115
- );
116
- }
117
-
118
- // src/hooks/use-lang.ts
119
- import { useEffect, useState } from "react";
120
- function useLang() {
121
- const [lang, setLang] = useState();
122
- useEffect(() => {
123
- const checkLang = () => {
124
- const currentLang = document.documentElement.getAttribute("lang");
125
- setLang(currentLang ?? void 0);
126
- };
127
- checkLang();
128
- const observer = new MutationObserver((mutations) => {
129
- for (const mutation of mutations) {
130
- if (mutation.attributeName === "lang") {
131
- checkLang();
132
- }
133
- }
134
- });
135
- observer.observe(document.documentElement, { attributes: true });
136
- return () => {
137
- observer.disconnect();
138
- };
139
- }, []);
140
- return { lang };
141
- }
142
-
143
- // src/hooks/use-theme.ts
144
- import { useEffect as useEffect2, useState as useState2 } from "react";
145
- function useTheme() {
146
- const [theme, setTheme] = useState2("light");
147
- useEffect2(() => {
148
- const checkTheme = () => {
149
- var _a;
150
- const isDark = document.documentElement.classList.contains("dark") || ((_a = document.documentElement.getAttribute("style")) == null ? void 0 : _a.includes("color-scheme: dark"));
151
- setTheme(isDark ? "dark" : "light");
152
- };
153
- checkTheme();
154
- const observer = new MutationObserver((mutations) => {
155
- for (const mutation of mutations) {
156
- if (mutation.attributeName === "style" || mutation.attributeName === "class") {
157
- checkTheme();
158
- }
159
- }
160
- });
161
- observer.observe(document.documentElement, { attributes: true });
162
- return () => {
163
- observer.disconnect();
164
- };
165
- }, []);
166
- return { theme };
167
- }
168
-
169
- // src/components/captcha/recaptcha-v3.tsx
170
168
  import { jsx, jsxs } from "react/jsx-runtime";
171
169
  function RecaptchaV3({ children }) {
172
170
  const isHydrated = useIsHydrated();
@@ -743,8 +741,10 @@ export {
743
741
  useIsHydrated,
744
742
  useLang,
745
743
  useTheme,
744
+ authDataCache,
746
745
  useAuthData,
747
746
  useCurrentOrganization,
747
+ OrganizationRefetcher,
748
748
  AuthUIContext,
749
749
  AuthUIProvider
750
750
  };
@@ -4,17 +4,72 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkCRAHKL2Ccjs = require('./chunk-CRAHKL2C.cjs');
8
-
9
- // src/hooks/use-auth-data.ts
10
-
11
-
7
+ var _chunk42PRTYABcjs = require('./chunk-42PRTYAB.cjs');
12
8
 
9
+ // src/hooks/use-hydrated.ts
10
+ var _react = require('react');
11
+ function subscribe() {
12
+ return () => {
13
+ };
14
+ }
15
+ function useIsHydrated() {
16
+ return _react.useSyncExternalStore.call(void 0,
17
+ subscribe,
18
+ () => true,
19
+ () => false
20
+ );
21
+ }
13
22
 
23
+ // src/hooks/use-lang.ts
14
24
 
25
+ function useLang() {
26
+ const [lang, setLang] = _react.useState.call(void 0, );
27
+ _react.useEffect.call(void 0, () => {
28
+ const checkLang = () => {
29
+ const currentLang = document.documentElement.getAttribute("lang");
30
+ setLang(_nullishCoalesce(currentLang, () => ( void 0)));
31
+ };
32
+ checkLang();
33
+ const observer = new MutationObserver((mutations) => {
34
+ for (const mutation of mutations) {
35
+ if (mutation.attributeName === "lang") {
36
+ checkLang();
37
+ }
38
+ }
39
+ });
40
+ observer.observe(document.documentElement, { attributes: true });
41
+ return () => {
42
+ observer.disconnect();
43
+ };
44
+ }, []);
45
+ return { lang };
46
+ }
15
47
 
48
+ // src/hooks/use-theme.ts
16
49
 
17
- var _react = require('react');
50
+ function useTheme() {
51
+ const [theme, setTheme] = _react.useState.call(void 0, "light");
52
+ _react.useEffect.call(void 0, () => {
53
+ const checkTheme = () => {
54
+ var _a;
55
+ const isDark = document.documentElement.classList.contains("dark") || ((_a = document.documentElement.getAttribute("style")) == null ? void 0 : _a.includes("color-scheme: dark"));
56
+ setTheme(isDark ? "dark" : "light");
57
+ };
58
+ checkTheme();
59
+ const observer = new MutationObserver((mutations) => {
60
+ for (const mutation of mutations) {
61
+ if (mutation.attributeName === "style" || mutation.attributeName === "class") {
62
+ checkTheme();
63
+ }
64
+ }
65
+ });
66
+ observer.observe(document.documentElement, { attributes: true });
67
+ return () => {
68
+ observer.disconnect();
69
+ };
70
+ }, []);
71
+ return { theme };
72
+ }
18
73
 
19
74
  // src/lib/auth-data-cache.ts
20
75
  var AuthDataCache = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this); }
@@ -90,83 +145,26 @@ var AuthDataCache = (_class = class {constructor() { _class.prototype.__init.cal
90
145
  }, _class);
91
146
  var authDataCache = new AuthDataCache();
92
147
 
93
- // src/lib/auth-ui-provider.tsx
148
+ // src/hooks/use-auth-data.ts
94
149
 
95
- var _sonner = require('sonner');
96
150
 
97
- // src/components/captcha/recaptcha-v3.tsx
98
151
 
99
152
 
100
153
 
101
- var _reactrecaptchav3 = require('@wojtekmaj/react-recaptcha-v3');
102
154
 
103
155
 
104
- // src/hooks/use-hydrated.ts
105
156
 
106
- function subscribe() {
107
- return () => {
108
- };
109
- }
110
- function useIsHydrated() {
111
- return _react.useSyncExternalStore.call(void 0,
112
- subscribe,
113
- () => true,
114
- () => false
115
- );
116
- }
117
157
 
118
- // src/hooks/use-lang.ts
158
+ // src/lib/auth-ui-provider.tsx
119
159
 
120
- function useLang() {
121
- const [lang, setLang] = _react.useState.call(void 0, );
122
- _react.useEffect.call(void 0, () => {
123
- const checkLang = () => {
124
- const currentLang = document.documentElement.getAttribute("lang");
125
- setLang(_nullishCoalesce(currentLang, () => ( void 0)));
126
- };
127
- checkLang();
128
- const observer = new MutationObserver((mutations) => {
129
- for (const mutation of mutations) {
130
- if (mutation.attributeName === "lang") {
131
- checkLang();
132
- }
133
- }
134
- });
135
- observer.observe(document.documentElement, { attributes: true });
136
- return () => {
137
- observer.disconnect();
138
- };
139
- }, []);
140
- return { lang };
141
- }
160
+ var _sonner = require('sonner');
142
161
 
143
- // src/hooks/use-theme.ts
162
+ // src/components/captcha/recaptcha-v3.tsx
144
163
 
145
- function useTheme() {
146
- const [theme, setTheme] = _react.useState.call(void 0, "light");
147
- _react.useEffect.call(void 0, () => {
148
- const checkTheme = () => {
149
- var _a;
150
- const isDark = document.documentElement.classList.contains("dark") || ((_a = document.documentElement.getAttribute("style")) == null ? void 0 : _a.includes("color-scheme: dark"));
151
- setTheme(isDark ? "dark" : "light");
152
- };
153
- checkTheme();
154
- const observer = new MutationObserver((mutations) => {
155
- for (const mutation of mutations) {
156
- if (mutation.attributeName === "style" || mutation.attributeName === "class") {
157
- checkTheme();
158
- }
159
- }
160
- });
161
- observer.observe(document.documentElement, { attributes: true });
162
- return () => {
163
- observer.disconnect();
164
- };
165
- }, []);
166
- return { theme };
167
- }
168
164
 
169
- // src/components/captcha/recaptcha-v3.tsx
165
+
166
+ var _reactrecaptchav3 = require('@wojtekmaj/react-recaptcha-v3');
167
+
170
168
  var _jsxruntime = require('react/jsx-runtime');
171
169
  function RecaptchaV3({ children }) {
172
170
  const isHydrated = useIsHydrated();
@@ -384,14 +382,14 @@ var AuthUIProvider = ({
384
382
  return {
385
383
  basePath: "/account",
386
384
  fields: ["image", "name"],
387
- viewPaths: _chunkCRAHKL2Ccjs.accountViewPaths
385
+ viewPaths: _chunk42PRTYABcjs.accountViewPaths
388
386
  };
389
387
  }
390
388
  const basePath2 = ((_a = accountProp.basePath) == null ? void 0 : _a.endsWith("/")) ? accountProp.basePath.slice(0, -1) : accountProp.basePath;
391
389
  return {
392
390
  basePath: _nullishCoalesce(basePath2, () => ( "/account")),
393
391
  fields: accountProp.fields || ["image", "name"],
394
- viewPaths: { ..._chunkCRAHKL2Ccjs.accountViewPaths, ...accountProp.viewPaths }
392
+ viewPaths: { ..._chunk42PRTYABcjs.accountViewPaths, ...accountProp.viewPaths }
395
393
  };
396
394
  }, [accountProp]);
397
395
  const deleteUser = _react.useMemo.call(void 0, () => {
@@ -438,7 +436,7 @@ var AuthUIProvider = ({
438
436
  if (organizationProp === true) {
439
437
  return {
440
438
  basePath: "/organization",
441
- viewPaths: _chunkCRAHKL2Ccjs.organizationViewPaths,
439
+ viewPaths: _chunk42PRTYABcjs.organizationViewPaths,
442
440
  customRoles: []
443
441
  };
444
442
  }
@@ -463,7 +461,7 @@ var AuthUIProvider = ({
463
461
  basePath: _nullishCoalesce(basePath2, () => ( "/organization")),
464
462
  customRoles: organizationProp.customRoles || [],
465
463
  viewPaths: {
466
- ..._chunkCRAHKL2Ccjs.organizationViewPaths,
464
+ ..._chunk42PRTYABcjs.organizationViewPaths,
467
465
  ...organizationProp.viewPaths
468
466
  }
469
467
  };
@@ -568,10 +566,10 @@ var AuthUIProvider = ({
568
566
  };
569
567
  }, [authClient]);
570
568
  const viewPaths = _react.useMemo.call(void 0, () => {
571
- return { ..._chunkCRAHKL2Ccjs.authViewPaths, ...viewPathsProp };
569
+ return { ..._chunk42PRTYABcjs.authViewPaths, ...viewPathsProp };
572
570
  }, [viewPathsProp]);
573
571
  const localization = _react.useMemo.call(void 0, () => {
574
- return { ..._chunkCRAHKL2Ccjs.authLocalization, ...localizationProp };
572
+ return { ..._chunk42PRTYABcjs.authLocalization, ...localizationProp };
575
573
  }, [localizationProp]);
576
574
  const hooks = _react.useMemo.call(void 0, () => {
577
575
  return { ...defaultHooks, ...hooksProp };
@@ -680,7 +678,7 @@ function useAuthData({
680
678
  setError(error2);
681
679
  toast2({
682
680
  variant: "error",
683
- message: _chunkCRAHKL2Ccjs.getLocalizedError.call(void 0, { error: error2, localization })
681
+ message: _chunk42PRTYABcjs.getLocalizedError.call(void 0, { error: error2, localization })
684
682
  });
685
683
  } else {
686
684
  setError(null);
@@ -691,7 +689,7 @@ function useAuthData({
691
689
  setError(error2);
692
690
  toast2({
693
691
  variant: "error",
694
- message: _chunkCRAHKL2Ccjs.getLocalizedError.call(void 0, { error: error2, localization })
692
+ message: _chunk42PRTYABcjs.getLocalizedError.call(void 0, { error: error2, localization })
695
693
  });
696
694
  } finally {
697
695
  authDataCache.setRefetching(stableCacheKey, false);
@@ -747,4 +745,6 @@ function useAuthData({
747
745
 
748
746
 
749
747
 
750
- exports.useIsHydrated = useIsHydrated; exports.useLang = useLang; exports.useTheme = useTheme; exports.useAuthData = useAuthData; exports.useCurrentOrganization = useCurrentOrganization; exports.AuthUIContext = AuthUIContext; exports.AuthUIProvider = AuthUIProvider;
748
+
749
+
750
+ exports.useIsHydrated = useIsHydrated; exports.useLang = useLang; exports.useTheme = useTheme; exports.authDataCache = authDataCache; exports.useAuthData = useAuthData; exports.useCurrentOrganization = useCurrentOrganization; exports.OrganizationRefetcher = OrganizationRefetcher; exports.AuthUIContext = AuthUIContext; exports.AuthUIProvider = AuthUIProvider;
@@ -9,6 +9,9 @@ function isValidEmail(email) {
9
9
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
10
10
  return emailRegex.test(email);
11
11
  }
12
+ function errorCodeToCamelCase(errorCode) {
13
+ return errorCode.toLowerCase().replace(/_([a-z])/g, (_, char) => char.toUpperCase());
14
+ }
12
15
  function getLocalizedError({
13
16
  error,
14
17
  localization
@@ -36,6 +39,11 @@ function getViewByPath(viewPaths, path) {
36
39
  }
37
40
  }
38
41
  }
42
+ function getKeyByValue(object, value) {
43
+ return Object.keys(object).find(
44
+ (key) => object[key] === value
45
+ );
46
+ }
39
47
  function getPasswordSchema(passwordValidation, localization) {
40
48
  let schema = z.string().min(1, {
41
49
  message: localization == null ? void 0 : localization.PASSWORD_REQUIRED
@@ -790,9 +798,11 @@ var organizationViewPaths = {
790
798
  export {
791
799
  cn,
792
800
  isValidEmail,
801
+ errorCodeToCamelCase,
793
802
  getLocalizedError,
794
803
  getSearchParam,
795
804
  getViewByPath,
805
+ getKeyByValue,
796
806
  getPasswordSchema,
797
807
  authLocalization,
798
808
  authViewPaths,