izen-react-starter 2.2.6 → 2.2.8

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,26 +1,67 @@
1
1
  import { ReactNode } from 'react';
2
+ /**
3
+ * Default User type - can be overridden by consuming projects
4
+ * Extend this interface or pass your own type to AuthProvider
5
+ */
2
6
  export interface User {
3
- id?: string;
4
- name?: string;
5
- email?: string;
6
- verified?: boolean;
7
7
  [key: string]: any;
8
8
  }
9
9
  export interface BackendTokens {
10
- access_token?: string;
11
- refresh_token?: string;
12
10
  [key: string]: any;
13
11
  }
14
- export interface AuthContextType {
15
- user: User | undefined;
12
+ /**
13
+ * Generic AuthContextType that accepts a custom User type
14
+ * @template TUser - The user type for this auth context
15
+ * @example
16
+ * interface MyUser {
17
+ * id: string;
18
+ * name: string;
19
+ * role: 'admin' | 'user';
20
+ * }
21
+ *
22
+ * type MyAuthContext = AuthContextType<MyUser>;
23
+ */
24
+ export interface AuthContextType<TUser = User> {
25
+ user: TUser | undefined;
16
26
  tokens: BackendTokens | undefined;
17
- setAuthData: (user: User | undefined | null, token?: BackendTokens | null | undefined) => void;
27
+ setAuthData: (user: TUser | undefined | null, token?: BackendTokens | null | undefined) => void;
18
28
  setOtherData: (data: any | undefined) => void;
19
29
  otherData: any | undefined;
20
30
  }
31
+ /**
32
+ * Props for AuthProvider
33
+ */
21
34
  export interface AuthProviderProps {
22
35
  children: ReactNode;
23
36
  }
37
+ /**
38
+ * AuthProvider - manages authentication state
39
+ * Accepts any User type through useAuth generic
40
+ *
41
+ * @example
42
+ * // In your app:
43
+ * <AuthProvider>
44
+ * <App />
45
+ * </AuthProvider>
46
+ *
47
+ * // In your components, use with your custom User type:
48
+ * interface MyUser {
49
+ * id: string;
50
+ * name: string;
51
+ * department: string;
52
+ * }
53
+ *
54
+ * const { user } = useAuth<MyUser>();
55
+ */
24
56
  export declare const AuthProvider: ({ children }: AuthProviderProps) => import("react/jsx-runtime").JSX.Element;
25
- export declare function useAuth(): AuthContextType;
57
+ /**
58
+ * Hook to use auth context
59
+ * Must be used within an AuthProvider
60
+ *
61
+ * @returns The auth context with user, tokens, and auth methods
62
+ *
63
+ * @example
64
+ * const { user, tokens, setAuthData } = useAuth();
65
+ */
66
+ export declare function useAuth<TUser extends User = User>(): AuthContextType<TUser>;
26
67
  //# sourceMappingURL=AuthProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvE,MAAM,WAAW,IAAI;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/F,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC;CAC5B;AAMD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,GAAI,cAAc,iBAAiB,4CA2C3D,CAAA;AAED,wBAAgB,OAAO,oBAMtB"}
1
+ {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvE;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,GAAG,IAAI;IAC3C,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IAChG,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC;CAC5B;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,GAAI,cAAc,iBAAiB,4CA2C3D,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,4BAMhD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "izen-react-starter",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "A React component library with UI components, layout context, and data fetching",
5
5
  "type": "module",
6
6
  "main": "./dist/react-starter.umd.cjs",