@mesob/auth-react 0.2.3 → 0.2.5

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 (61) hide show
  1. package/dist/components/auth/countdown.js +2 -3
  2. package/dist/components/auth/countdown.js.map +1 -1
  3. package/dist/components/auth/forgot-password.js +9 -11
  4. package/dist/components/auth/forgot-password.js.map +1 -1
  5. package/dist/components/auth/reset-password-form.js +11 -13
  6. package/dist/components/auth/reset-password-form.js.map +1 -1
  7. package/dist/components/auth/sign-in.js +9 -11
  8. package/dist/components/auth/sign-in.js.map +1 -1
  9. package/dist/components/auth/sign-up.js +8 -10
  10. package/dist/components/auth/sign-up.js.map +1 -1
  11. package/dist/components/auth/verification-form.js +9 -8
  12. package/dist/components/auth/verification-form.js.map +1 -1
  13. package/dist/components/auth/verify-email.js +12 -15
  14. package/dist/components/auth/verify-email.js.map +1 -1
  15. package/dist/components/auth/verify-phone.js +13 -14
  16. package/dist/components/auth/verify-phone.js.map +1 -1
  17. package/dist/components/error-boundary.js +1 -1
  18. package/dist/components/error-boundary.js.map +1 -1
  19. package/dist/components/iam/permissions.js +3 -4
  20. package/dist/components/iam/permissions.js.map +1 -1
  21. package/dist/components/iam/roles.js +3 -4
  22. package/dist/components/iam/roles.js.map +1 -1
  23. package/dist/components/iam/sessions.js +3 -3
  24. package/dist/components/iam/sessions.js.map +1 -1
  25. package/dist/components/iam/tenants.js +3 -4
  26. package/dist/components/iam/tenants.js.map +1 -1
  27. package/dist/components/iam/users.js +3 -4
  28. package/dist/components/iam/users.js.map +1 -1
  29. package/dist/components/profile/account.js +1 -1
  30. package/dist/components/profile/account.js.map +1 -1
  31. package/dist/components/profile/change-email-form.js +13 -15
  32. package/dist/components/profile/change-email-form.js.map +1 -1
  33. package/dist/components/profile/change-password-form.js +6 -6
  34. package/dist/components/profile/change-password-form.js.map +1 -1
  35. package/dist/components/profile/change-phone-form.js +13 -15
  36. package/dist/components/profile/change-phone-form.js.map +1 -1
  37. package/dist/components/profile/change-profile.js +3 -3
  38. package/dist/components/profile/change-profile.js.map +1 -1
  39. package/dist/components/profile/otp-verification-modal.js +10 -9
  40. package/dist/components/profile/otp-verification-modal.js.map +1 -1
  41. package/dist/components/profile/request-change-email-form.js +1 -4
  42. package/dist/components/profile/request-change-email-form.js.map +1 -1
  43. package/dist/components/profile/request-change-phone-form.js +1 -4
  44. package/dist/components/profile/request-change-phone-form.js.map +1 -1
  45. package/dist/components/profile/security.js +22 -27
  46. package/dist/components/profile/security.js.map +1 -1
  47. package/dist/components/profile/verify-change-email-form.js +10 -9
  48. package/dist/components/profile/verify-change-email-form.js.map +1 -1
  49. package/dist/components/profile/verify-change-phone-form.js +10 -9
  50. package/dist/components/profile/verify-change-phone-form.js.map +1 -1
  51. package/dist/components/shared/data-table.js +2 -2
  52. package/dist/components/shared/data-table.js.map +1 -1
  53. package/dist/components/skeletons/auth-form-skeleton.js +1 -1
  54. package/dist/components/skeletons/auth-form-skeleton.js.map +1 -1
  55. package/dist/components/skeletons/profile-skeleton.js +1 -1
  56. package/dist/components/skeletons/profile-skeleton.js.map +1 -1
  57. package/dist/components/skeletons/table-skeleton.js +1 -1
  58. package/dist/components/skeletons/table-skeleton.js.map +1 -1
  59. package/dist/index.js +84 -107
  60. package/dist/index.js.map +1 -1
  61. package/package.json +2 -2
@@ -2,10 +2,7 @@
2
2
 
3
3
  // src/components/profile/request-change-phone-form.tsx
4
4
  import { zodResolver } from "@hookform/resolvers/zod";
5
- import { Button } from "@mesob/ui/components/button";
6
- import { Input } from "@mesob/ui/components/input";
7
- import { Label } from "@mesob/ui/components/label";
8
- import { Spinner } from "@mesob/ui/components/spinner";
5
+ import { Button, Input, Label, Spinner } from "@mesob/ui/components";
9
6
  import { IconEye, IconEyeOff } from "@tabler/icons-react";
10
7
  import { useEffect, useState as useState2 } from "react";
11
8
  import { useForm } from "react-hook-form";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/profile/request-change-phone-form.tsx","../../../src/provider.tsx","../../../src/utils/cookie.ts","../../../src/utils/normalize-phone.ts"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button } from '@mesob/ui/components/button';\nimport { Input } from '@mesob/ui/components/input';\nimport { Label } from '@mesob/ui/components/label';\nimport { Spinner } from '@mesob/ui/components/spinner';\nimport { IconEye, IconEyeOff } from '@tabler/icons-react';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { z } from 'zod';\nimport { useApi, useConfig, useSession } from '../../provider';\nimport { normalizePhone } from '../../utils/normalize-phone';\n\nconst phonePasswordSchema = (phoneRegex: RegExp) =>\n z.object({\n phone: z\n .string()\n .trim()\n .min(1, { message: 'Phone number is required' })\n .refine(\n (val) => {\n const isPhone = phoneRegex.test(val);\n return isPhone;\n },\n {\n message: 'Invalid phone number',\n },\n ),\n password: z\n .string()\n .min(8, 'Password must be at least 8 characters')\n .max(128, 'Password too long'),\n });\n\ntype PhonePasswordFormData = z.infer<ReturnType<typeof phonePasswordSchema>>;\n\ntype AuthErrorLike = {\n code?: string;\n message?: string;\n name?: string;\n};\n\nfunction isAuthError(error: unknown): error is AuthErrorLike {\n return (\n typeof error === 'object' &&\n error !== null &&\n ('code' in error || 'message' in error || 'name' in error)\n );\n}\n\nfunction getErrorCode(error: AuthErrorLike): string | undefined {\n if (error.code) {\n return error.code;\n }\n if (error.message) {\n const upperMessage = error.message.toUpperCase().trim();\n const validCodes = [\n 'USER_NOT_FOUND',\n 'USER_EXISTS',\n 'INVALID_PASSWORD',\n 'VERIFICATION_EXPIRED',\n 'VERIFICATION_MISMATCH',\n 'VERIFICATION_NOT_FOUND',\n 'TOO_MANY_ATTEMPTS',\n 'UNAUTHORIZED',\n ];\n if (validCodes.includes(upperMessage)) {\n return upperMessage;\n }\n }\n return undefined;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n switch (errorCode) {\n case 'USER_EXISTS':\n return 'This phone number is already taken. Please use a different number.';\n case 'VERIFICATION_EXPIRED':\n return 'Verification code has expired. Please request a new one.';\n case 'VERIFICATION_MISMATCH':\n return 'Invalid verification code. Please try again.';\n case 'VERIFICATION_NOT_FOUND':\n return 'Verification not found. Please request a new code.';\n default:\n return error.message || 'An error occurred. Please try again.';\n }\n }\n if (error instanceof Error) {\n return error.message;\n }\n return 'An error occurred. Please try again.';\n}\n\ninterface RequestChangePhoneFormProps {\n onSuccess: (verificationId: string, phone: string) => void;\n onCancel: () => void;\n buttonText: string;\n}\n\nexport function RequestChangePhoneForm({\n onSuccess,\n onCancel,\n buttonText,\n}: RequestChangePhoneFormProps) {\n const { user } = useSession();\n const { hooks } = useApi();\n const { config } = useConfig();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isChecking, setIsChecking] = useState(true);\n const [showPassword, setShowPassword] = useState(false);\n\n const phoneRegex =\n typeof config.phoneRegex === 'string'\n ? new RegExp(config.phoneRegex)\n : config.phoneRegex || /^(\\+2519|\\+2517|2519|2517|09|07)\\d{8}$/;\n\n const getPendingAccountChangeQuery = hooks.useQuery(\n 'get',\n '/account-change/pending',\n {},\n { enabled: false },\n );\n const verifyPasswordMutation = hooks.useMutation('post', '/password/verify');\n const checkUserMutation = hooks.useMutation('post', '/check-account');\n const requestPhoneOtpMutation = hooks.useMutation(\n 'post',\n '/phone/verification/request',\n );\n\n const phonePasswordForm = useForm<PhonePasswordFormData>({\n resolver: zodResolver(phonePasswordSchema(phoneRegex)),\n defaultValues: {\n phone: '',\n password: '',\n },\n });\n\n const {\n register,\n handleSubmit,\n getValues,\n setValue,\n formState: { errors },\n } = phonePasswordForm;\n\n useEffect(() => {\n let active = true;\n const run = async () => {\n try {\n const data = await getPendingAccountChangeQuery.refetch();\n if (!active) {\n return;\n }\n const accountChange = data.data?.accountChange;\n const verificationId = data.data?.verificationId;\n if (accountChange?.changeType !== 'phone') {\n setIsChecking(false);\n return;\n }\n if (!accountChange.newPhone) {\n setIsChecking(false);\n return;\n }\n if (getValues('phone')) {\n setIsChecking(false);\n return;\n }\n setValue('phone', accountChange.newPhone, { shouldValidate: true });\n\n if (verificationId) {\n toast.message('Resuming verification…');\n onSuccess(verificationId, accountChange.newPhone);\n return;\n }\n\n setIsChecking(false);\n } catch {\n setIsChecking(false);\n }\n };\n run().catch(() => undefined);\n return () => {\n active = false;\n };\n }, [getPendingAccountChangeQuery.refetch, getValues, onSuccess, setValue]);\n\n const onPhonePasswordSubmit = async (data: PhonePasswordFormData) => {\n if (!user) {\n toast.error('User not found');\n return;\n }\n\n try {\n setIsSubmitting(true);\n\n const normalizedPhone = normalizePhone(data.phone);\n\n // Verify password first\n await verifyPasswordMutation.mutateAsync({\n body: { password: data.password },\n });\n\n // Check if phone exists\n const checkResult = await checkUserMutation.mutateAsync({\n body: { identifier: normalizedPhone },\n });\n if (checkResult.data?.exists) {\n // Check if it belongs to current user\n if (\n user?.phone?.replace(/\\s/g, '') === normalizedPhone.replace(/\\s/g, '')\n ) {\n toast.error('This is already your current phone number.');\n return;\n }\n toast.error(\n 'This phone number is already taken. Please use a different number.',\n );\n return;\n }\n\n // Request OTP\n const verification = await requestPhoneOtpMutation.mutateAsync({\n body: {\n phone: normalizedPhone,\n context: 'change-phone',\n },\n });\n\n toast.success('Verification code sent to your phone');\n onSuccess(verification.data?.verificationId ?? '', normalizedPhone);\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n if (\n errorCode === 'INVALID_PASSWORD' ||\n errorCode === 'USER_NOT_FOUND'\n ) {\n toast.error('Incorrect password. Please try again.');\n return;\n }\n }\n toast.error(errorMessage);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const isLoading = isSubmitting || isChecking;\n\n return (\n <form\n onSubmit={handleSubmit(onPhonePasswordSubmit)}\n className=\"p-4 space-y-4 border-t\"\n >\n <div className=\"space-y-4 w-full md:w-1/2\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"phone\">Phone Number</Label>\n <Input\n id=\"phone\"\n type=\"tel\"\n placeholder=\"Enter your new phone number\"\n {...register('phone')}\n disabled={isLoading}\n />\n {errors.phone && (\n <p className=\"text-sm text-destructive\">{errors.phone.message}</p>\n )}\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"password\">Password</Label>\n <div className=\"relative\">\n <Input\n id=\"password\"\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"current-password\"\n placeholder=\"Enter your password\"\n {...register('password')}\n disabled={isLoading}\n />\n <button\n type=\"button\"\n onClick={() => setShowPassword(!showPassword)}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground\"\n >\n {showPassword ? (\n <IconEyeOff className=\"h-4 w-4\" />\n ) : (\n <IconEye className=\"h-4 w-4\" />\n )}\n </button>\n </div>\n {errors.password && (\n <p className=\"text-sm text-destructive\">\n {errors.password.message}\n </p>\n )}\n </div>\n </div>\n\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={onCancel}\n disabled={isLoading}\n >\n Cancel\n </Button>\n <Button type=\"submit\" disabled={isLoading}>\n {isLoading && <Spinner className=\"mr-2 h-4 w-4\" />}\n {isChecking ? 'Checking…' : buttonText}\n </Button>\n </div>\n </form>\n );\n}\n","'use client';\n\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { deepmerge } from 'deepmerge-ts';\nimport createFetchClient from 'openapi-fetch';\nimport createClient from 'openapi-react-query';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo, useState } from 'react';\nimport type { paths } from './data/openapi';\nimport { createTranslator } from './lib/translations';\nimport {\n type AuthClientConfig,\n type AuthResponse,\n defaultAuthClientConfig,\n type Session,\n type User,\n} from './types';\nimport { getSessionCookieName } from './utils/cookie';\nimport { createCustomFetch } from './utils/custom-fetch';\n\n// biome-ignore lint/suspicious/noExplicitAny: OpenAPI hooks type\ntype OpenApiHooks = any;\n\n// --- Utility: Check if running on server ---\nfunction isServer(): boolean {\n return typeof document === 'undefined';\n}\n\n/**\n * @deprecated Cookie is httpOnly and cannot be read client-side.\n * Use `useSession().isAuthenticated` instead.\n * This function always returns false on client.\n */\nexport function hasAuthCookie(_cookieName: string): boolean {\n // Cookie is httpOnly, can't check client-side\n // Always return false - use useSession() for auth status\n return false;\n}\n\n// --- Types ---\nexport type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';\n\ntype AuthState = {\n user: User | null;\n session: Session | null;\n status: AuthStatus;\n error: Error | null;\n};\n\ntype SessionContextValue = AuthState & {\n isLoading: boolean;\n isAuthenticated: boolean;\n refresh: () => Promise<void>;\n signOut: () => Promise<void>;\n};\n\ntype ApiContextValue = {\n hooks: OpenApiHooks;\n setAuth: (auth: AuthResponse) => void;\n clearAuth: () => void;\n refresh: () => Promise<void>;\n};\n\ntype ConfigContextValue = {\n config: AuthClientConfig;\n cookieName: string;\n t: (key: string, params?: Record<string, string | number>) => string;\n};\n\nconst SessionContext = createContext<SessionContextValue | null>(null);\nconst ApiContext = createContext<ApiContextValue | null>(null);\nconst ConfigContext = createContext<ConfigContextValue | null>(null);\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// --- Hooks ---\n\n/**\n * Get session state including user, session, and auth status.\n * - `status`: 'loading' | 'authenticated' | 'unauthenticated'\n * - `isLoading`: true while fetching session\n * - `isAuthenticated`: true if user and session exist\n */\nexport function useSession(): SessionContextValue {\n const context = useContext(SessionContext);\n if (!context) {\n throw new Error('useSession must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useApi(): ApiContextValue {\n const context = useContext(ApiContext);\n if (!context) {\n throw new Error('useApi must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useConfig(): ConfigContextValue {\n const context = useContext(ConfigContext);\n if (!context) {\n throw new Error('useConfig must be used within MesobAuthProvider');\n }\n return context;\n}\n\n/**\n * @deprecated Cookie is httpOnly, can't be checked client-side.\n * Use `useSession().isAuthenticated` instead.\n */\nexport function useHasAuthCookie(): boolean {\n const { status } = useSession();\n return status === 'authenticated' || status === 'loading';\n}\n\n// --- Provider ---\n\ntype MesobAuthProviderProps = {\n config: AuthClientConfig;\n children: ReactNode;\n};\n\nexport function MesobAuthProvider({\n config,\n children,\n}: MesobAuthProviderProps) {\n const mergedConfig = useMemo(\n () =>\n deepmerge(\n { ...defaultAuthClientConfig } as Partial<AuthClientConfig>,\n config,\n ) as AuthClientConfig,\n [config],\n );\n\n const api = useMemo(\n () =>\n createFetchClient<paths>({\n baseUrl: mergedConfig.baseURL,\n fetch: createCustomFetch(mergedConfig),\n }),\n [mergedConfig],\n );\n\n const hooks = useMemo(() => createClient(api), [api]);\n const cookieName = useMemo(\n () => getSessionCookieName(mergedConfig),\n [mergedConfig],\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <AuthStateProvider\n config={mergedConfig}\n hooks={hooks}\n cookieName={cookieName}\n >\n {children}\n </AuthStateProvider>\n </QueryClientProvider>\n );\n}\n\ntype AuthStateProviderProps = {\n config: AuthClientConfig;\n hooks: OpenApiHooks;\n cookieName: string;\n children: ReactNode;\n};\n\nfunction AuthStateProvider({\n config,\n hooks,\n cookieName,\n children,\n}: AuthStateProviderProps) {\n // Manual override for sign-out / sign-in\n const [override, setOverride] = useState<AuthState | null>(null);\n\n // Always fetch session - cookie is httpOnly, can't check client-side\n // Server will read the cookie and return user/session if valid\n const {\n data: sessionData,\n isLoading,\n isFetched,\n error: sessionError,\n refetch,\n } = hooks.useQuery(\n 'get',\n '/session',\n {},\n {\n enabled: !(override || isServer()),\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n retry: false,\n gcTime: 0,\n staleTime: 0,\n },\n );\n\n // Derive state directly - no useEffect\n const user = override?.user ?? sessionData?.user ?? null;\n const session = override?.session ?? sessionData?.session ?? null;\n const error = override?.error ?? (sessionError as Error | null);\n\n // Check error status code\n const errorStatus = (() => {\n if (!sessionError) {\n return null;\n }\n const err = sessionError as { status?: number };\n return err.status ?? null;\n })();\n\n // Check if error is a network/connection error\n const isNetworkError = (() => {\n if (!sessionError) {\n return false;\n }\n const error = sessionError as Error & { cause?: unknown; data?: unknown };\n const errorMessage =\n error.message || String(error) || JSON.stringify(error);\n // Network errors: TypeError, DOMException, or fetch failures\n if (\n error instanceof TypeError ||\n error instanceof DOMException ||\n error.name === 'TypeError' ||\n errorMessage.includes('Failed to fetch') ||\n errorMessage.includes('ERR_CONNECTION_REFUSED') ||\n errorMessage.includes('NetworkError') ||\n errorMessage.includes('Network request failed') ||\n errorMessage.includes('fetch failed')\n ) {\n return true;\n }\n // Check error cause\n if (error.cause) {\n const causeStr = String(error.cause);\n if (\n causeStr.includes('Failed to fetch') ||\n causeStr.includes('ERR_CONNECTION_REFUSED') ||\n causeStr.includes('NetworkError')\n ) {\n return true;\n }\n }\n return false;\n })();\n\n // Compute status\n // biome-ignore lint: Status determination requires multiple checks\n const status: AuthStatus = (() => {\n if (override) {\n return override.status;\n }\n if (isServer()) {\n return 'loading';\n }\n if (user && session) {\n return 'authenticated';\n }\n // Check for network errors or auth errors first - allow auth page to show\n if (isNetworkError || errorStatus === 401) {\n return 'unauthenticated';\n }\n // If we have an error but it's not a network error, still check loading state\n if (sessionError && !isNetworkError && errorStatus !== 401) {\n if (errorStatus && errorStatus >= 500) {\n return 'authenticated';\n }\n // Other errors mean unauthenticated\n if (isFetched) {\n return 'unauthenticated';\n }\n }\n if (isLoading || !isFetched) {\n return 'loading';\n }\n if (isFetched && !user && !session) {\n return 'unauthenticated';\n }\n return 'unauthenticated';\n })();\n\n const signOutMutation = hooks.useMutation('post', '/sign-out');\n const t = createTranslator(config.messages || {});\n\n const setAuth = (auth: AuthResponse) => {\n setOverride({\n user: auth.user,\n session: auth.session,\n status: 'authenticated',\n error: null,\n });\n };\n\n const clearAuth = () => {\n setOverride({\n user: null,\n session: null,\n status: 'unauthenticated',\n error: null,\n });\n };\n\n const refresh = async () => {\n setOverride(null);\n await refetch();\n };\n\n const signOut = async () => {\n try {\n await signOutMutation.mutateAsync({});\n } finally {\n clearAuth();\n }\n };\n\n return (\n <ConfigContext.Provider value={{ config, cookieName, t }}>\n <ApiContext.Provider value={{ hooks, setAuth, clearAuth, refresh }}>\n <SessionContext.Provider\n value={{\n user,\n session,\n status,\n error,\n isLoading: status === 'loading',\n isAuthenticated: status === 'authenticated',\n refresh,\n signOut,\n }}\n >\n {children}\n </SessionContext.Provider>\n </ApiContext.Provider>\n </ConfigContext.Provider>\n );\n}\n","import type { AuthClientConfig } from '../types';\n\nconst isProduction =\n typeof process !== 'undefined' && process.env.NODE_ENV === 'production';\n\nexport const getSessionCookieName = (config: AuthClientConfig): string => {\n const prefix = config.cookiePrefix || '';\n const baseName = 'session_token';\n if (prefix) {\n return `${prefix}_${baseName}`;\n }\n return isProduction ? '__Host-session_token' : baseName;\n};\n","export function normalizePhone(phone: string): string {\n const cleaned = phone.trim().replace(/\\s/g, '');\n if (cleaned.startsWith('+2519') || cleaned.startsWith('+2517')) {\n return cleaned;\n }\n if (cleaned.startsWith('2519') || cleaned.startsWith('2517')) {\n return `+${cleaned}`;\n }\n if (cleaned.startsWith('09') || cleaned.startsWith('07')) {\n return `+251${cleaned.slice(1)}`;\n }\n if (\n (cleaned.startsWith('9') || cleaned.startsWith('7')) &&\n cleaned.length === 9\n ) {\n return `+251${cleaned}`;\n }\n return cleaned;\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,SAAS,kBAAkB;AACpC,SAAS,WAAW,YAAAA,iBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAS;;;ACTlB,SAAS,aAAa,2BAA2B;AACjD,SAAS,iBAAiB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,kBAAkB;AAEzB,SAAS,eAAe,Y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,WAAQ,WAAU,WAAU;AAAA;AAAA,cAEjC;AAAA,eACF;AAAA,YACC,OAAO,YACN,gBAAAA,KAAC,OAAE,WAAU,4BACV,iBAAO,SAAS,SACnB;AAAA,aAEJ;AAAA,WACF;AAAA,QAEA,qBAAC,SAAI,WAAU,0BACb;AAAA,0BAAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cACT,UAAU;AAAA,cACX;AAAA;AAAA,UAED;AAAA,UACA,qBAAC,UAAO,MAAK,UAAS,UAAU,WAC7B;AAAA,yBAAa,gBAAAA,KAAC,WAAQ,WAAU,gBAAe;AAAA,YAC/C,aAAa,mBAAc;AAAA,aAC9B;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["useState","jsx","useState"]}
1
+ {"version":3,"sources":["../../../src/components/profile/request-change-phone-form.tsx","../../../src/provider.tsx","../../../src/utils/cookie.ts","../../../src/utils/normalize-phone.ts"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button, Input, Label, Spinner } from '@mesob/ui/components';\nimport { IconEye, IconEyeOff } from '@tabler/icons-react';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { z } from 'zod';\nimport { useApi, useConfig, useSession } from '../../provider';\nimport { normalizePhone } from '../../utils/normalize-phone';\n\nconst phonePasswordSchema = (phoneRegex: RegExp) =>\n z.object({\n phone: z\n .string()\n .trim()\n .min(1, { message: 'Phone number is required' })\n .refine(\n (val) => {\n const isPhone = phoneRegex.test(val);\n return isPhone;\n },\n {\n message: 'Invalid phone number',\n },\n ),\n password: z\n .string()\n .min(8, 'Password must be at least 8 characters')\n .max(128, 'Password too long'),\n });\n\ntype PhonePasswordFormData = z.infer<ReturnType<typeof phonePasswordSchema>>;\n\ntype AuthErrorLike = {\n code?: string;\n message?: string;\n name?: string;\n};\n\nfunction isAuthError(error: unknown): error is AuthErrorLike {\n return (\n typeof error === 'object' &&\n error !== null &&\n ('code' in error || 'message' in error || 'name' in error)\n );\n}\n\nfunction getErrorCode(error: AuthErrorLike): string | undefined {\n if (error.code) {\n return error.code;\n }\n if (error.message) {\n const upperMessage = error.message.toUpperCase().trim();\n const validCodes = [\n 'USER_NOT_FOUND',\n 'USER_EXISTS',\n 'INVALID_PASSWORD',\n 'VERIFICATION_EXPIRED',\n 'VERIFICATION_MISMATCH',\n 'VERIFICATION_NOT_FOUND',\n 'TOO_MANY_ATTEMPTS',\n 'UNAUTHORIZED',\n ];\n if (validCodes.includes(upperMessage)) {\n return upperMessage;\n }\n }\n return undefined;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n switch (errorCode) {\n case 'USER_EXISTS':\n return 'This phone number is already taken. Please use a different number.';\n case 'VERIFICATION_EXPIRED':\n return 'Verification code has expired. Please request a new one.';\n case 'VERIFICATION_MISMATCH':\n return 'Invalid verification code. Please try again.';\n case 'VERIFICATION_NOT_FOUND':\n return 'Verification not found. Please request a new code.';\n default:\n return error.message || 'An error occurred. Please try again.';\n }\n }\n if (error instanceof Error) {\n return error.message;\n }\n return 'An error occurred. Please try again.';\n}\n\ninterface RequestChangePhoneFormProps {\n onSuccess: (verificationId: string, phone: string) => void;\n onCancel: () => void;\n buttonText: string;\n}\n\nexport function RequestChangePhoneForm({\n onSuccess,\n onCancel,\n buttonText,\n}: RequestChangePhoneFormProps) {\n const { user } = useSession();\n const { hooks } = useApi();\n const { config } = useConfig();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isChecking, setIsChecking] = useState(true);\n const [showPassword, setShowPassword] = useState(false);\n\n const phoneRegex =\n typeof config.phoneRegex === 'string'\n ? new RegExp(config.phoneRegex)\n : config.phoneRegex || /^(\\+2519|\\+2517|2519|2517|09|07)\\d{8}$/;\n\n const getPendingAccountChangeQuery = hooks.useQuery(\n 'get',\n '/account-change/pending',\n {},\n { enabled: false },\n );\n const verifyPasswordMutation = hooks.useMutation('post', '/password/verify');\n const checkUserMutation = hooks.useMutation('post', '/check-account');\n const requestPhoneOtpMutation = hooks.useMutation(\n 'post',\n '/phone/verification/request',\n );\n\n const phonePasswordForm = useForm<PhonePasswordFormData>({\n resolver: zodResolver(phonePasswordSchema(phoneRegex)),\n defaultValues: {\n phone: '',\n password: '',\n },\n });\n\n const {\n register,\n handleSubmit,\n getValues,\n setValue,\n formState: { errors },\n } = phonePasswordForm;\n\n useEffect(() => {\n let active = true;\n const run = async () => {\n try {\n const data = await getPendingAccountChangeQuery.refetch();\n if (!active) {\n return;\n }\n const accountChange = data.data?.accountChange;\n const verificationId = data.data?.verificationId;\n if (accountChange?.changeType !== 'phone') {\n setIsChecking(false);\n return;\n }\n if (!accountChange.newPhone) {\n setIsChecking(false);\n return;\n }\n if (getValues('phone')) {\n setIsChecking(false);\n return;\n }\n setValue('phone', accountChange.newPhone, { shouldValidate: true });\n\n if (verificationId) {\n toast.message('Resuming verification…');\n onSuccess(verificationId, accountChange.newPhone);\n return;\n }\n\n setIsChecking(false);\n } catch {\n setIsChecking(false);\n }\n };\n run().catch(() => undefined);\n return () => {\n active = false;\n };\n }, [getPendingAccountChangeQuery.refetch, getValues, onSuccess, setValue]);\n\n const onPhonePasswordSubmit = async (data: PhonePasswordFormData) => {\n if (!user) {\n toast.error('User not found');\n return;\n }\n\n try {\n setIsSubmitting(true);\n\n const normalizedPhone = normalizePhone(data.phone);\n\n // Verify password first\n await verifyPasswordMutation.mutateAsync({\n body: { password: data.password },\n });\n\n // Check if phone exists\n const checkResult = await checkUserMutation.mutateAsync({\n body: { identifier: normalizedPhone },\n });\n if (checkResult.data?.exists) {\n // Check if it belongs to current user\n if (\n user?.phone?.replace(/\\s/g, '') === normalizedPhone.replace(/\\s/g, '')\n ) {\n toast.error('This is already your current phone number.');\n return;\n }\n toast.error(\n 'This phone number is already taken. Please use a different number.',\n );\n return;\n }\n\n // Request OTP\n const verification = await requestPhoneOtpMutation.mutateAsync({\n body: {\n phone: normalizedPhone,\n context: 'change-phone',\n },\n });\n\n toast.success('Verification code sent to your phone');\n onSuccess(verification.data?.verificationId ?? '', normalizedPhone);\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n if (\n errorCode === 'INVALID_PASSWORD' ||\n errorCode === 'USER_NOT_FOUND'\n ) {\n toast.error('Incorrect password. Please try again.');\n return;\n }\n }\n toast.error(errorMessage);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const isLoading = isSubmitting || isChecking;\n\n return (\n <form\n onSubmit={handleSubmit(onPhonePasswordSubmit)}\n className=\"p-4 space-y-4 border-t\"\n >\n <div className=\"space-y-4 w-full md:w-1/2\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"phone\">Phone Number</Label>\n <Input\n id=\"phone\"\n type=\"tel\"\n placeholder=\"Enter your new phone number\"\n {...register('phone')}\n disabled={isLoading}\n />\n {errors.phone && (\n <p className=\"text-sm text-destructive\">{errors.phone.message}</p>\n )}\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"password\">Password</Label>\n <div className=\"relative\">\n <Input\n id=\"password\"\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"current-password\"\n placeholder=\"Enter your password\"\n {...register('password')}\n disabled={isLoading}\n />\n <button\n type=\"button\"\n onClick={() => setShowPassword(!showPassword)}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground\"\n >\n {showPassword ? (\n <IconEyeOff className=\"h-4 w-4\" />\n ) : (\n <IconEye className=\"h-4 w-4\" />\n )}\n </button>\n </div>\n {errors.password && (\n <p className=\"text-sm text-destructive\">\n {errors.password.message}\n </p>\n )}\n </div>\n </div>\n\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={onCancel}\n disabled={isLoading}\n >\n Cancel\n </Button>\n <Button type=\"submit\" disabled={isLoading}>\n {isLoading && <Spinner className=\"mr-2 h-4 w-4\" />}\n {isChecking ? 'Checking…' : buttonText}\n </Button>\n </div>\n </form>\n );\n}\n","'use client';\n\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { deepmerge } from 'deepmerge-ts';\nimport createFetchClient from 'openapi-fetch';\nimport createClient from 'openapi-react-query';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo, useState } from 'react';\nimport type { paths } from './data/openapi';\nimport { createTranslator } from './lib/translations';\nimport {\n type AuthClientConfig,\n type AuthResponse,\n defaultAuthClientConfig,\n type Session,\n type User,\n} from './types';\nimport { getSessionCookieName } from './utils/cookie';\nimport { createCustomFetch } from './utils/custom-fetch';\n\n// biome-ignore lint/suspicious/noExplicitAny: OpenAPI hooks type\ntype OpenApiHooks = any;\n\n// --- Utility: Check if running on server ---\nfunction isServer(): boolean {\n return typeof document === 'undefined';\n}\n\n/**\n * @deprecated Cookie is httpOnly and cannot be read client-side.\n * Use `useSession().isAuthenticated` instead.\n * This function always returns false on client.\n */\nexport function hasAuthCookie(_cookieName: string): boolean {\n // Cookie is httpOnly, can't check client-side\n // Always return false - use useSession() for auth status\n return false;\n}\n\n// --- Types ---\nexport type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';\n\ntype AuthState = {\n user: User | null;\n session: Session | null;\n status: AuthStatus;\n error: Error | null;\n};\n\ntype SessionContextValue = AuthState & {\n isLoading: boolean;\n isAuthenticated: boolean;\n refresh: () => Promise<void>;\n signOut: () => Promise<void>;\n};\n\ntype ApiContextValue = {\n hooks: OpenApiHooks;\n setAuth: (auth: AuthResponse) => void;\n clearAuth: () => void;\n refresh: () => Promise<void>;\n};\n\ntype ConfigContextValue = {\n config: AuthClientConfig;\n cookieName: string;\n t: (key: string, params?: Record<string, string | number>) => string;\n};\n\nconst SessionContext = createContext<SessionContextValue | null>(null);\nconst ApiContext = createContext<ApiContextValue | null>(null);\nconst ConfigContext = createContext<ConfigContextValue | null>(null);\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// --- Hooks ---\n\n/**\n * Get session state including user, session, and auth status.\n * - `status`: 'loading' | 'authenticated' | 'unauthenticated'\n * - `isLoading`: true while fetching session\n * - `isAuthenticated`: true if user and session exist\n */\nexport function useSession(): SessionContextValue {\n const context = useContext(SessionContext);\n if (!context) {\n throw new Error('useSession must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useApi(): ApiContextValue {\n const context = useContext(ApiContext);\n if (!context) {\n throw new Error('useApi must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useConfig(): ConfigContextValue {\n const context = useContext(ConfigContext);\n if (!context) {\n throw new Error('useConfig must be used within MesobAuthProvider');\n }\n return context;\n}\n\n/**\n * @deprecated Cookie is httpOnly, can't be checked client-side.\n * Use `useSession().isAuthenticated` instead.\n */\nexport function useHasAuthCookie(): boolean {\n const { status } = useSession();\n return status === 'authenticated' || status === 'loading';\n}\n\n// --- Provider ---\n\ntype MesobAuthProviderProps = {\n config: AuthClientConfig;\n children: ReactNode;\n};\n\nexport function MesobAuthProvider({\n config,\n children,\n}: MesobAuthProviderProps) {\n const mergedConfig = useMemo(\n () =>\n deepmerge(\n { ...defaultAuthClientConfig } as Partial<AuthClientConfig>,\n config,\n ) as AuthClientConfig,\n [config],\n );\n\n const api = useMemo(\n () =>\n createFetchClient<paths>({\n baseUrl: mergedConfig.baseURL,\n fetch: createCustomFetch(mergedConfig),\n }),\n [mergedConfig],\n );\n\n const hooks = useMemo(() => createClient(api), [api]);\n const cookieName = useMemo(\n () => getSessionCookieName(mergedConfig),\n [mergedConfig],\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <AuthStateProvider\n config={mergedConfig}\n hooks={hooks}\n cookieName={cookieName}\n >\n {children}\n </AuthStateProvider>\n </QueryClientProvider>\n );\n}\n\ntype AuthStateProviderProps = {\n config: AuthClientConfig;\n hooks: OpenApiHooks;\n cookieName: string;\n children: ReactNode;\n};\n\nfunction AuthStateProvider({\n config,\n hooks,\n cookieName,\n children,\n}: AuthStateProviderProps) {\n // Manual override for sign-out / sign-in\n const [override, setOverride] = useState<AuthState | null>(null);\n\n // Always fetch session - cookie is httpOnly, can't check client-side\n // Server will read the cookie and return user/session if valid\n const {\n data: sessionData,\n isLoading,\n isFetched,\n error: sessionError,\n refetch,\n } = hooks.useQuery(\n 'get',\n '/session',\n {},\n {\n enabled: !(override || isServer()),\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n retry: false,\n gcTime: 0,\n staleTime: 0,\n },\n );\n\n // Derive state directly - no useEffect\n const user = override?.user ?? sessionData?.user ?? null;\n const session = override?.session ?? sessionData?.session ?? null;\n const error = override?.error ?? (sessionError as Error | null);\n\n // Check error status code\n const errorStatus = (() => {\n if (!sessionError) {\n return null;\n }\n const err = sessionError as { status?: number };\n return err.status ?? null;\n })();\n\n // Check if error is a network/connection error\n const isNetworkError = (() => {\n if (!sessionError) {\n return false;\n }\n const error = sessionError as Error & { cause?: unknown; data?: unknown };\n const errorMessage =\n error.message || String(error) || JSON.stringify(error);\n // Network errors: TypeError, DOMException, or fetch failures\n if (\n error instanceof TypeError ||\n error instanceof DOMException ||\n error.name === 'TypeError' ||\n errorMessage.includes('Failed to fetch') ||\n errorMessage.includes('ERR_CONNECTION_REFUSED') ||\n errorMessage.includes('NetworkError') ||\n errorMessage.includes('Network request failed') ||\n errorMessage.includes('fetch failed')\n ) {\n return true;\n }\n // Check error cause\n if (error.cause) {\n const causeStr = String(error.cause);\n if (\n causeStr.includes('Failed to fetch') ||\n causeStr.includes('ERR_CONNECTION_REFUSED') ||\n causeStr.includes('NetworkError')\n ) {\n return true;\n }\n }\n return false;\n })();\n\n // Compute status\n // biome-ignore lint: Status determination requires multiple checks\n const status: AuthStatus = (() => {\n if (override) {\n return override.status;\n }\n if (isServer()) {\n return 'loading';\n }\n if (user && session) {\n return 'authenticated';\n }\n // Check for network errors or auth errors first - allow auth page to show\n if (isNetworkError || errorStatus === 401) {\n return 'unauthenticated';\n }\n // If we have an error but it's not a network error, still check loading state\n if (sessionError && !isNetworkError && errorStatus !== 401) {\n if (errorStatus && errorStatus >= 500) {\n return 'authenticated';\n }\n // Other errors mean unauthenticated\n if (isFetched) {\n return 'unauthenticated';\n }\n }\n if (isLoading || !isFetched) {\n return 'loading';\n }\n if (isFetched && !user && !session) {\n return 'unauthenticated';\n }\n return 'unauthenticated';\n })();\n\n const signOutMutation = hooks.useMutation('post', '/sign-out');\n const t = createTranslator(config.messages || {});\n\n const setAuth = (auth: AuthResponse) => {\n setOverride({\n user: auth.user,\n session: auth.session,\n status: 'authenticated',\n error: null,\n });\n };\n\n const clearAuth = () => {\n setOverride({\n user: null,\n session: null,\n status: 'unauthenticated',\n error: null,\n });\n };\n\n const refresh = async () => {\n setOverride(null);\n await refetch();\n };\n\n const signOut = async () => {\n try {\n await signOutMutation.mutateAsync({});\n } finally {\n clearAuth();\n }\n };\n\n return (\n <ConfigContext.Provider value={{ config, cookieName, t }}>\n <ApiContext.Provider value={{ hooks, setAuth, clearAuth, refresh }}>\n <SessionContext.Provider\n value={{\n user,\n session,\n status,\n error,\n isLoading: status === 'loading',\n isAuthenticated: status === 'authenticated',\n refresh,\n signOut,\n }}\n >\n {children}\n </SessionContext.Provider>\n </ApiContext.Provider>\n </ConfigContext.Provider>\n );\n}\n","import type { AuthClientConfig } from '../types';\n\nconst isProduction =\n typeof process !== 'undefined' && process.env.NODE_ENV === 'production';\n\nexport const getSessionCookieName = (config: AuthClientConfig): string => {\n const prefix = config.cookiePrefix || '';\n const baseName = 'session_token';\n if (prefix) {\n return `${prefix}_${baseName}`;\n }\n return isProduction ? '__Host-session_token' : baseName;\n};\n","export function normalizePhone(phone: string): string {\n const cleaned = phone.trim().replace(/\\s/g, '');\n if (cleaned.startsWith('+2519') || cleaned.startsWith('+2517')) {\n return cleaned;\n }\n if (cleaned.startsWith('2519') || cleaned.startsWith('2517')) {\n return `+${cleaned}`;\n }\n if (cleaned.startsWith('09') || cleaned.startsWith('07')) {\n return `+251${cleaned.slice(1)}`;\n }\n if (\n (cleaned.startsWith('9') || cleaned.startsWith('7')) &&\n cleaned.length === 9\n ) {\n return `+251${cleaned}`;\n }\n return cleaned;\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,OAAO,OAAO,eAAe;AAC9C,SAAS,SAAS,kBAAkB;AACpC,SAAS,WAAW,YAAAA,iBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAS;;;ACNlB,SAAS,aAAa,2BAA2B;AACjD,SAAS,iBAAiB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,kBAAkB;AAEzB,SAAS,eAAe,YAAY,SAAS,gBAAgB;;;ACL7D,IAAM,eACJ,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;;;AD4JvD;AA1FN,IAAM,iBAAiB,cAA0C,IAAI;AACrE,IAAM,aAAa,cAAsC,IAAI;AAC7D,IAAM,gBAAgB,cAAyC,IAAI;AAEnE,IAAM,cAAc,IAAI,YAAY;AAAA,EAClC,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF,CAAC;AAUM,SAAS,aAAkC;AAChD,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;AAEO,SAAS,SAA0B;AACxC,QAAM,UAAU,WAAW,UAAU;AACrC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;AAEO,SAAS,YAAgC;AAC9C,QAAM,UAAU,WAAW,aAAa;AACxC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AACA,SAAO;AACT;;;AE/GO,SAAS,eAAe,OAAuB;AACpD,QAAM,UAAU,MAAM,KAAK,EAAE,QA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,KAAC,SAAM,SAAQ,YAAW,sBAAQ;AAAA,YAClC,qBAAC,SAAI,WAAU,YACb;AAAA,8BAAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,IAAG;AAAA,kBACH,MAAM,eAAe,SAAS;AAAA,kBAC9B,cAAa;AAAA,kBACb,aAAY;AAAA,kBACX,GAAG,SAAS,UAAU;AAAA,kBACvB,UAAU;AAAA;AAAA,cACZ;AAAA,cACA,gBAAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,SAAS,MAAM,gBAAgB,CAAC,YAAY;AAAA,kBAC5C,WAAU;AAAA,kBAET,yBACC,gBAAAA,KAAC,cAAW,WAAU,WAAU,IAEhC,gBAAAA,KAAC,WAAQ,WAAU,WAAU;AAAA;AAAA,cAEjC;AAAA,eACF;AAAA,YACC,OAAO,YACN,gBAAAA,KAAC,OAAE,WAAU,4BACV,iBAAO,SAAS,SACnB;AAAA,aAEJ;AAAA,WACF;AAAA,QAEA,qBAAC,SAAI,WAAU,0BACb;AAAA,0BAAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cACT,UAAU;AAAA,cACX;AAAA;AAAA,UAED;AAAA,UACA,qBAAC,UAAO,MAAK,UAAS,UAAU,WAC7B;AAAA,yBAAa,gBAAAA,KAAC,WAAQ,WAAU,gBAAe;AAAA,YAC/C,aAAa,mBAAc;AAAA,aAC9B;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["useState","jsx","useState"]}
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/profile/change-email-form.tsx
4
- import { Button as Button4 } from "@mesob/ui/components/button";
5
4
  import {
5
+ Button as Button4,
6
6
  Collapsible,
7
7
  CollapsibleContent,
8
8
  CollapsibleTrigger
9
- } from "@mesob/ui/components/collapsible";
9
+ } from "@mesob/ui/components";
10
10
  import { IconChevronDown } from "@tabler/icons-react";
11
11
  import { useState as useState5 } from "react";
12
12
 
@@ -82,10 +82,7 @@ function useConfig() {
82
82
 
83
83
  // src/components/profile/request-change-email-form.tsx
84
84
  import { zodResolver } from "@hookform/resolvers/zod";
85
- import { Button } from "@mesob/ui/components/button";
86
- import { Input } from "@mesob/ui/components/input";
87
- import { Label } from "@mesob/ui/components/label";
88
- import { Spinner } from "@mesob/ui/components/spinner";
85
+ import { Button, Input, Label, Spinner } from "@mesob/ui/components";
89
86
  import { IconEye, IconEyeOff } from "@tabler/icons-react";
90
87
  import { useEffect, useState as useState2 } from "react";
91
88
  import { useForm } from "react-hook-form";
@@ -340,23 +337,25 @@ import {
340
337
  DialogDescription,
341
338
  DialogHeader,
342
339
  DialogTitle
343
- } from "@mesob/ui/components/dialog";
340
+ } from "@mesob/ui/components";
344
341
 
345
342
  // src/components/auth/verification-form.tsx
346
343
  import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
347
- import { Button as Button3 } from "@mesob/ui/components/button";
348
- import { Field, FieldError, FieldGroup } from "@mesob/ui/components/field";
349
344
  import {
345
+ Button as Button3,
346
+ Field,
347
+ FieldError,
348
+ FieldGroup,
350
349
  InputOTP,
351
350
  InputOTPGroup,
352
- InputOTPSlot
353
- } from "@mesob/ui/components/input-otp";
354
- import { Spinner as Spinner3 } from "@mesob/ui/components/spinner";
351
+ InputOTPSlot,
352
+ Spinner as Spinner3
353
+ } from "@mesob/ui/components";
355
354
  import { Controller, useForm as useForm2 } from "react-hook-form";
356
355
  import { z as z2 } from "zod";
357
356
 
358
357
  // src/hooks/use-translator.ts
359
- import { useMesob } from "@mesob/ui/components/mesob-context";
358
+ import { useMesob } from "@mesob/ui/providers";
360
359
  function useTranslator(namespace) {
361
360
  const mesob = useMesob();
362
361
  const { config } = useConfig();
@@ -367,8 +366,7 @@ function useTranslator(namespace) {
367
366
  }
368
367
 
369
368
  // src/components/auth/countdown.tsx
370
- import { Button as Button2 } from "@mesob/ui/components/button";
371
- import { Spinner as Spinner2 } from "@mesob/ui/components/spinner";
369
+ import { Button as Button2, Spinner as Spinner2 } from "@mesob/ui/components";
372
370
  import { useEffect as useEffect2, useState as useState3 } from "react";
373
371
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
374
372
  var Countdown = ({
@@ -718,15 +716,15 @@ function ChangeEmailForm() {
718
716
 
719
717
  // src/components/profile/change-password-form.tsx
720
718
  import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
721
- import { Button as Button5 } from "@mesob/ui/components/button";
722
719
  import {
720
+ Button as Button5,
723
721
  Collapsible as Collapsible2,
724
722
  CollapsibleContent as CollapsibleContent2,
725
- CollapsibleTrigger as CollapsibleTrigger2
726
- } from "@mesob/ui/components/collapsible";
727
- import { Input as Input2 } from "@mesob/ui/components/input";
728
- import { Label as Label2 } from "@mesob/ui/components/label";
729
- import { Spinner as Spinner4 } from "@mesob/ui/components/spinner";
723
+ CollapsibleTrigger as CollapsibleTrigger2,
724
+ Input as Input2,
725
+ Label as Label2,
726
+ Spinner as Spinner4
727
+ } from "@mesob/ui/components";
730
728
  import { IconChevronDown as IconChevronDown2, IconEye as IconEye2, IconEyeOff as IconEyeOff2 } from "@tabler/icons-react";
731
729
  import { useState as useState6 } from "react";
732
730
  import { useForm as useForm3 } from "react-hook-form";
@@ -936,21 +934,18 @@ function ChangePasswordForm() {
936
934
  }
937
935
 
938
936
  // src/components/profile/change-phone-form.tsx
939
- import { Button as Button7 } from "@mesob/ui/components/button";
940
937
  import {
938
+ Button as Button7,
941
939
  Collapsible as Collapsible3,
942
940
  CollapsibleContent as CollapsibleContent3,
943
941
  CollapsibleTrigger as CollapsibleTrigger3
944
- } from "@mesob/ui/components/collapsible";
942
+ } from "@mesob/ui/components";
945
943
  import { IconChevronDown as IconChevronDown3 } from "@tabler/icons-react";
946
944
  import { useState as useState9 } from "react";
947
945
 
948
946
  // src/components/profile/request-change-phone-form.tsx
949
947
  import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
950
- import { Button as Button6 } from "@mesob/ui/components/button";
951
- import { Input as Input3 } from "@mesob/ui/components/input";
952
- import { Label as Label3 } from "@mesob/ui/components/label";
953
- import { Spinner as Spinner5 } from "@mesob/ui/components/spinner";
948
+ import { Button as Button6, Input as Input3, Label as Label3, Spinner as Spinner5 } from "@mesob/ui/components";
954
949
  import { IconEye as IconEye3, IconEyeOff as IconEyeOff3 } from "@tabler/icons-react";
955
950
  import { useEffect as useEffect3, useState as useState7 } from "react";
956
951
  import { useForm as useForm4 } from "react-hook-form";