@better-auth-ui/heroui 1.6.2 → 1.6.3

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 (74) hide show
  1. package/dist/components/auth/auth-provider.js +12 -11
  2. package/dist/components/auth/auth.d.ts +1 -1
  3. package/dist/components/auth/error-toaster.d.ts +1 -0
  4. package/dist/components/auth/error-toaster.js +17 -0
  5. package/dist/components/auth/forgot-password.d.ts +1 -1
  6. package/dist/components/auth/forgot-password.js +3 -6
  7. package/dist/components/auth/magic-link.d.ts +1 -1
  8. package/dist/components/auth/magic-link.js +52 -64
  9. package/dist/components/auth/passkey-button.js +12 -15
  10. package/dist/components/auth/provider-button.d.ts +15 -0
  11. package/dist/components/auth/provider-button.js +29 -0
  12. package/dist/components/auth/provider-buttons.d.ts +4 -10
  13. package/dist/components/auth/provider-buttons.js +16 -23
  14. package/dist/components/auth/reset-password.d.ts +1 -1
  15. package/dist/components/auth/reset-password.js +3 -6
  16. package/dist/components/auth/sign-in.d.ts +1 -1
  17. package/dist/components/auth/sign-in.js +81 -93
  18. package/dist/components/auth/sign-up.d.ts +1 -1
  19. package/dist/components/auth/sign-up.js +99 -108
  20. package/dist/components/settings/account/appearance.d.ts +1 -1
  21. package/dist/components/settings/account/change-avatar.js +1 -1
  22. package/dist/components/settings/account/change-email.d.ts +1 -1
  23. package/dist/components/settings/account/change-email.js +1 -4
  24. package/dist/components/settings/account/manage-account.js +1 -4
  25. package/dist/components/settings/account/manage-accounts.d.ts +1 -1
  26. package/dist/components/settings/account/manage-accounts.js +16 -16
  27. package/dist/components/settings/account/user-profile.d.ts +1 -1
  28. package/dist/components/settings/account/user-profile.js +1 -4
  29. package/dist/components/settings/security/active-session.js +1 -4
  30. package/dist/components/settings/security/active-sessions.d.ts +1 -1
  31. package/dist/components/settings/security/active-sessions.js +17 -17
  32. package/dist/components/settings/security/change-password.d.ts +1 -1
  33. package/dist/components/settings/security/change-password.js +1 -4
  34. package/dist/components/settings/security/delete-user.d.ts +1 -1
  35. package/dist/components/settings/security/delete-user.js +6 -11
  36. package/dist/components/settings/security/linked-account.js +1 -7
  37. package/dist/components/settings/security/linked-accounts.d.ts +1 -1
  38. package/dist/components/settings/security/linked-accounts.js +18 -18
  39. package/dist/components/settings/security/passkey.js +19 -19
  40. package/dist/components/settings/security/passkeys.d.ts +1 -1
  41. package/dist/components/settings/security/passkeys.js +28 -28
  42. package/dist/components/user/switch-account-item.js +9 -9
  43. package/dist/components/user/switch-account-menu.js +16 -16
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +34 -33
  46. package/package.json +6 -4
  47. package/src/components/auth/auth-provider.tsx +4 -0
  48. package/src/components/auth/auth.tsx +1 -1
  49. package/src/components/auth/error-toaster.tsx +25 -0
  50. package/src/components/auth/forgot-password.tsx +1 -2
  51. package/src/components/auth/magic-link.tsx +3 -23
  52. package/src/components/auth/passkey-button.tsx +1 -2
  53. package/src/components/auth/provider-button.tsx +67 -0
  54. package/src/components/auth/provider-buttons.tsx +26 -43
  55. package/src/components/auth/reset-password.tsx +1 -2
  56. package/src/components/auth/sign-in.tsx +2 -20
  57. package/src/components/auth/sign-up.tsx +5 -20
  58. package/src/components/settings/account/appearance.tsx +1 -1
  59. package/src/components/settings/account/change-avatar.tsx +1 -3
  60. package/src/components/settings/account/change-email.tsx +2 -3
  61. package/src/components/settings/account/manage-account.tsx +1 -4
  62. package/src/components/settings/account/manage-accounts.tsx +3 -8
  63. package/src/components/settings/account/user-profile.tsx +1 -2
  64. package/src/components/settings/security/active-session.tsx +0 -1
  65. package/src/components/settings/security/active-sessions.tsx +3 -8
  66. package/src/components/settings/security/change-password.tsx +7 -4
  67. package/src/components/settings/security/delete-user.tsx +1 -4
  68. package/src/components/settings/security/linked-account.tsx +4 -14
  69. package/src/components/settings/security/linked-accounts.tsx +3 -8
  70. package/src/components/settings/security/passkey.tsx +2 -4
  71. package/src/components/settings/security/passkeys.tsx +4 -12
  72. package/src/components/user/switch-account-item.tsx +2 -4
  73. package/src/components/user/switch-account-menu.tsx +2 -7
  74. package/src/index.tsx +1 -0
@@ -3,7 +3,7 @@ import {
3
3
  useListDeviceSessions,
4
4
  useSession
5
5
  } from "@better-auth-ui/react"
6
- import { Card, type CardProps, cn, toast } from "@heroui/react"
6
+ import { Card, type CardProps, cn } from "@heroui/react"
7
7
  import { ManageAccount } from "./manage-account"
8
8
 
9
9
  export type ManageAccountsProps = {
@@ -23,16 +23,11 @@ export function ManageAccounts({
23
23
  className,
24
24
  variant,
25
25
  ...props
26
- }: ManageAccountsProps & CardProps) {
26
+ }: ManageAccountsProps & Omit<CardProps, "children">) {
27
27
  const { localization } = useAuth()
28
28
  const { data: session } = useSession()
29
29
 
30
- const { data: deviceSessions, isPending } = useListDeviceSessions({
31
- throwOnError: (error) => {
32
- if (error.error) toast.danger(error.error.message)
33
- return false
34
- }
35
- })
30
+ const { data: deviceSessions, isPending } = useListDeviceSessions()
36
31
 
37
32
  const otherSessions = deviceSessions?.filter(
38
33
  (deviceSession) => deviceSession.session.id !== session?.session.id
@@ -40,7 +40,7 @@ export function UserProfile({
40
40
  className,
41
41
  variant,
42
42
  ...props
43
- }: UserProfileProps & CardProps) {
43
+ }: UserProfileProps & Omit<CardProps, "children">) {
44
44
  const { localization, username: usernameConfig } = useAuth()
45
45
  const { data: session } = useSession()
46
46
 
@@ -84,7 +84,6 @@ export function UserProfile({
84
84
  }
85
85
 
86
86
  const { mutate: updateUser, isPending } = useUpdateUser({
87
- onError: (error) => toast.danger(error.error?.message || error.message),
88
87
  onSuccess: () => toast.success(localization.settings.profileUpdatedSuccess)
89
88
  })
90
89
 
@@ -50,7 +50,6 @@ export function ActiveSession({ activeSession }: ActiveSessionProps) {
50
50
  const { data: session } = useSession({ refetchOnMount: false })
51
51
 
52
52
  const { mutate: revokeSession, isPending: isRevoking } = useRevokeSession({
53
- onError: (error) => toast.danger(error.error?.message || error.message),
54
53
  onSuccess: () => toast.success(localization.settings.revokeSessionSuccess)
55
54
  })
56
55
 
@@ -1,5 +1,5 @@
1
1
  import { useAuth, useListSessions, useSession } from "@better-auth-ui/react"
2
- import { Card, type CardProps, cn, Skeleton, toast } from "@heroui/react"
2
+ import { Card, type CardProps, cn, Skeleton } from "@heroui/react"
3
3
  import { ActiveSession } from "./active-session"
4
4
 
5
5
  export type ActiveSessionsProps = {
@@ -19,16 +19,11 @@ export function ActiveSessions({
19
19
  className,
20
20
  variant,
21
21
  ...props
22
- }: ActiveSessionsProps & CardProps) {
22
+ }: ActiveSessionsProps & Omit<CardProps, "children">) {
23
23
  const { localization } = useAuth()
24
24
  const { data: session } = useSession()
25
25
 
26
- const { data: sessions, isPending } = useListSessions({
27
- throwOnError: (error) => {
28
- if (error.error) toast.danger(error.error.message)
29
- return false
30
- }
31
- })
26
+ const { data: sessions, isPending } = useListSessions()
32
27
 
33
28
  const activeSessions = sessions?.toSorted((activeSession) =>
34
29
  activeSession.id === session?.session.id ? -1 : 1
@@ -42,7 +42,7 @@ export function ChangePassword({
42
42
  className,
43
43
  variant,
44
44
  ...props
45
- }: ChangePasswordProps & CardProps) {
45
+ }: ChangePasswordProps & Omit<CardProps, "children">) {
46
46
  const { emailAndPassword, localization } = useAuth()
47
47
  const { data: session } = useSession()
48
48
  const { data: accounts, isPending: isAccountsPending } = useListAccounts()
@@ -67,12 +67,15 @@ export function ChangePassword({
67
67
  )
68
68
  }
69
69
 
70
- function SetPassword({ className, variant, ...props }: CardProps) {
70
+ function SetPassword({
71
+ className,
72
+ variant,
73
+ ...props
74
+ }: Omit<CardProps, "children">) {
71
75
  const { localization } = useAuth()
72
76
  const { data: session } = useSession()
73
77
 
74
78
  const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset({
75
- onError: (error) => toast.danger(error.error?.message || error.message),
76
79
  onSuccess: () => toast.success(localization.auth.passwordResetEmailSent)
77
80
  })
78
81
 
@@ -125,7 +128,7 @@ function ChangePasswordForm({
125
128
  emailAndPassword: ReturnType<typeof useAuth>["emailAndPassword"]
126
129
  localization: ReturnType<typeof useAuth>["localization"]
127
130
  session: ReturnType<typeof useSession>["data"]
128
- } & CardProps) {
131
+ } & Omit<CardProps, "children">) {
129
132
  const [currentPassword, setCurrentPassword] = useState("")
130
133
  const [newPassword, setNewPassword] = useState("")
131
134
  const [confirmPassword, setConfirmPassword] = useState("")
@@ -28,7 +28,7 @@ export function DeleteUser({
28
28
  className,
29
29
  variant,
30
30
  ...props
31
- }: DeleteUserProps & CardProps) {
31
+ }: DeleteUserProps & Omit<CardProps, "children">) {
32
32
  const {
33
33
  basePaths,
34
34
  deleteUser: deleteUserConfig,
@@ -76,9 +76,6 @@ export function DeleteUser({
76
76
  replace: true
77
77
  })
78
78
  }
79
- },
80
- onError: (error) => {
81
- toast.danger(error.error?.message || error.message)
82
79
  }
83
80
  })
84
81
  }
@@ -28,23 +28,13 @@ export type LinkedAccountProps = {
28
28
  export function LinkedAccount({ account, provider }: LinkedAccountProps) {
29
29
  const { baseURL, localization } = useAuth()
30
30
 
31
- const { data: accountInfo, isPending: isLoadingInfo } = useAccountInfo(
32
- account?.accountId,
33
- {
34
- enabled: !!account,
35
- throwOnError: (error) => {
36
- if (error.error) toast.danger(error.error.message)
37
- return false
38
- }
39
- }
40
- )
41
-
42
- const { mutate: linkSocial, isPending: isLinking } = useLinkSocial({
43
- onError: (error) => toast.danger(error.error?.message || error.message)
31
+ const { data: accountInfo, isPending: isLoadingInfo } = useAccountInfo({
32
+ query: { accountId: account?.accountId }
44
33
  })
45
34
 
35
+ const { mutate: linkSocial, isPending: isLinking } = useLinkSocial()
36
+
46
37
  const { mutate: unlinkAccount, isPending: isUnlinking } = useUnlinkAccount({
47
- onError: (error) => toast.danger(error.error?.message || error.message),
48
38
  onSuccess: () => toast.success(localization.settings.accountUnlinked)
49
39
  })
50
40
 
@@ -1,5 +1,5 @@
1
1
  import { useAuth, useListAccounts } from "@better-auth-ui/react"
2
- import { Card, type CardProps, cn, Skeleton, toast } from "@heroui/react"
2
+ import { Card, type CardProps, cn, Skeleton } from "@heroui/react"
3
3
  import { LinkedAccount } from "./linked-account"
4
4
 
5
5
  export type LinkedAccountsProps = {
@@ -20,15 +20,10 @@ export function LinkedAccounts({
20
20
  className,
21
21
  variant,
22
22
  ...props
23
- }: LinkedAccountsProps & CardProps) {
23
+ }: LinkedAccountsProps & Omit<CardProps, "children">) {
24
24
  const { localization, socialProviders } = useAuth()
25
25
 
26
- const { data: accounts, isPending } = useListAccounts({
27
- throwOnError: (error) => {
28
- if (error.error) toast.danger(error.error.message)
29
- return false
30
- }
31
- })
26
+ const { data: accounts, isPending } = useListAccounts()
32
27
 
33
28
  const linkedAccounts = accounts?.filter(
34
29
  (account) => account.providerId !== "credential"
@@ -1,6 +1,6 @@
1
1
  import { useAuth, useDeletePasskey } from "@better-auth-ui/react"
2
2
  import { Fingerprint, Xmark } from "@gravity-ui/icons"
3
- import { Button, Spinner, toast } from "@heroui/react"
3
+ import { Button, Spinner } from "@heroui/react"
4
4
 
5
5
  export type PasskeyProps = {
6
6
  passkey: {
@@ -13,9 +13,7 @@ export type PasskeyProps = {
13
13
  export function Passkey({ passkey }: PasskeyProps) {
14
14
  const { localization } = useAuth()
15
15
 
16
- const { mutate: deletePasskey, isPending } = useDeletePasskey({
17
- onError: (error) => toast.danger(error.error?.message || error.message)
18
- })
16
+ const { mutate: deletePasskey, isPending } = useDeletePasskey()
19
17
 
20
18
  return (
21
19
  <div className="flex items-center gap-3">
@@ -9,8 +9,7 @@ import {
9
9
  type CardProps,
10
10
  cn,
11
11
  Skeleton,
12
- Spinner,
13
- toast
12
+ Spinner
14
13
  } from "@heroui/react"
15
14
 
16
15
  import { Passkey } from "./passkey"
@@ -24,19 +23,12 @@ export function Passkeys({
24
23
  className,
25
24
  variant,
26
25
  ...props
27
- }: PasskeysProps & CardProps) {
26
+ }: PasskeysProps & Omit<CardProps, "children">) {
28
27
  const { localization } = useAuth()
29
28
 
30
- const { data: passkeys, isPending } = useListUserPasskeys({
31
- throwOnError: (error) => {
32
- if (error.error) toast.danger(error.error.message)
33
- return false
34
- }
35
- })
29
+ const { data: passkeys, isPending } = useListUserPasskeys()
36
30
 
37
- const { mutate: addPasskey, isPending: isAdding } = useAddPasskey({
38
- onError: (error) => toast.danger(error.error?.message || error.message)
39
- })
31
+ const { mutate: addPasskey, isPending: isAdding } = useAddPasskey()
40
32
 
41
33
  return (
42
34
  <div>
@@ -1,5 +1,5 @@
1
1
  import { useSetActiveSession } from "@better-auth-ui/react"
2
- import { Dropdown, Spinner, toast } from "@heroui/react"
2
+ import { Dropdown, Spinner } from "@heroui/react"
3
3
  import type { Session, User } from "better-auth"
4
4
  import { UserView } from "./user-view"
5
5
 
@@ -19,9 +19,7 @@ export type SwitchAccountItemProps = {
19
19
  * @returns The switch account dropdown item as a JSX element
20
20
  */
21
21
  export function SwitchAccountItem({ deviceSession }: SwitchAccountItemProps) {
22
- const { mutate: setActiveSession, isPending } = useSetActiveSession({
23
- onError: (error) => toast.danger(error.error?.message || error.message)
24
- })
22
+ const { mutate: setActiveSession, isPending } = useSetActiveSession()
25
23
 
26
24
  return (
27
25
  <Dropdown.Item
@@ -4,7 +4,7 @@ import {
4
4
  useSession
5
5
  } from "@better-auth-ui/react"
6
6
  import { Check, CirclePlus } from "@gravity-ui/icons"
7
- import { Dropdown, Label, Separator, toast } from "@heroui/react"
7
+ import { Dropdown, Label, Separator } from "@heroui/react"
8
8
 
9
9
  import { SwitchAccountItem } from "./switch-account-item"
10
10
  import { UserView } from "./user-view"
@@ -21,12 +21,7 @@ import { UserView } from "./user-view"
21
21
  export function SwitchAccountMenu() {
22
22
  const { basePaths, viewPaths, localization } = useAuth()
23
23
  const { data: session } = useSession()
24
- const { data: deviceSessions, isPending } = useListDeviceSessions({
25
- throwOnError: (error) => {
26
- if (error.error) toast.danger(error.error.message)
27
- return false
28
- }
29
- })
24
+ const { data: deviceSessions, isPending } = useListDeviceSessions()
30
25
 
31
26
  return (
32
27
  <Dropdown.Popover className="min-w-40 md:min-w-56 max-w-[48svw]">
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ export * from "./components/auth/forgot-password"
6
6
  export * from "./components/auth/magic-link"
7
7
  export * from "./components/auth/magic-link-button"
8
8
  export * from "./components/auth/passkey-button"
9
+ export * from "./components/auth/provider-button"
9
10
  export * from "./components/auth/provider-buttons"
10
11
  export * from "./components/auth/reset-password"
11
12
  export * from "./components/auth/sign-in"