@sonamu-kit/react-components 0.2.0 → 0.2.2

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.
@@ -1,2 +1,2 @@
1
- export { type SonamuContextValue, SonamuProvider, useSonamuBaseContext, } from './sonamu-context';
2
- export type { Dictionary, SDReturnType, SonamuAuth, SonamuFile } from './types';
1
+ export { type SonamuAuthClient, type SonamuContextValue, SonamuProvider, useSonamuBaseContext, } from './sonamu-context';
2
+ export type { Dictionary, SDReturnType, SonamuFile } from './types';
@@ -1,21 +1,26 @@
1
+ import { BetterAuthClientOptions } from 'better-auth/client';
2
+ import { createAuthClient } from 'better-auth/react';
1
3
  import { ReactNode } from 'react';
2
- import { Dictionary, SDReturnType, SonamuAuth, SonamuFile } from './types';
3
- export interface SonamuContextValue<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any> {
4
+ import { Dictionary, SDReturnType, SonamuFile } from './types';
5
+ /** createAuthClient의 반환 타입을 옵션으로부터 추론하는 유틸리티 타입 */
6
+ export type SonamuAuthClient<O extends BetterAuthClientOptions> = ReturnType<typeof createAuthClient<O>>;
7
+ export interface SonamuContextValue<D extends Dictionary = Dictionary, O extends BetterAuthClientOptions = BetterAuthClientOptions> {
4
8
  uploader?: (files: File[]) => Promise<SonamuFile[]>;
5
- auth?: SonamuAuth<TUser, TLoginParams>;
9
+ auth?: SonamuAuthClient<O>;
6
10
  SD?: <K extends keyof D>(key: K) => SDReturnType<D, K>;
7
11
  }
8
- export interface SonamuProviderProps<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any> extends SonamuContextValue<D, TUser, TLoginParams> {
12
+ export interface SonamuProviderProps<D extends Dictionary = Dictionary, O extends BetterAuthClientOptions = BetterAuthClientOptions> extends SonamuContextValue<D, O> {
9
13
  children: ReactNode;
14
+ authOptions?: O;
10
15
  }
11
- export declare function SonamuProvider<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any>({ children, ...value }: SonamuProviderProps<D, TUser, TLoginParams>): import("react/jsx-runtime").JSX.Element;
16
+ export declare function SonamuProvider<D extends Dictionary = Dictionary, O extends BetterAuthClientOptions = BetterAuthClientOptions>({ children, authOptions, ...value }: SonamuProviderProps<D, O>): import("react/jsx-runtime").JSX.Element;
12
17
  /**
13
18
  * 타입이 지정된 useSonamuContext를 만들기 위한 베이스 훅
14
19
  *
15
20
  * @example
16
21
  * // contexts/sonamu-provider.tsx
17
22
  * export function useSonamuContext() {
18
- * return useSonamuBaseContext<MergedDictionary, UserSubsetSS, UserLoginParams>();
23
+ * return useSonamuBaseContext<MergedDictionary>();
19
24
  * }
20
25
  */
21
- export declare function useSonamuBaseContext<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any>(): Required<SonamuContextValue<D, TUser, TLoginParams>>;
26
+ export declare function useSonamuBaseContext<D extends Dictionary = Dictionary, O extends BetterAuthClientOptions = BetterAuthClientOptions>(): Required<SonamuContextValue<D, O>>;
@@ -8,13 +8,6 @@ export type SonamuFile = {
8
8
  mime_type: string;
9
9
  size: number;
10
10
  };
11
- export type SonamuAuth<TUser = any, TLoginParams = any> = {
12
- user: TUser | null;
13
- loading: boolean;
14
- login: (params: TLoginParams) => void;
15
- logout: () => void;
16
- refetch: () => void;
17
- };
18
11
  export type Dictionary = Record<string, string | ((...args: any[]) => string)>;
19
12
  /**
20
13
  * SD 반환 타입 - 제네릭으로 키에 따라 정확한 타입 반환