@asgardeo/react 0.5.4 → 0.5.6

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.
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { BrandingPreference, Theme } from '@asgardeo/browser';
19
+ /**
20
+ * Configuration options for the useBranding hook
21
+ * @deprecated Use BrandingProvider instead for better performance and consistency
22
+ */
23
+ export interface UseBrandingConfig {
24
+ /**
25
+ * @deprecated This configuration is now handled by BrandingProvider
26
+ */
27
+ locale?: string;
28
+ /**
29
+ * @deprecated This configuration is now handled by BrandingProvider
30
+ */
31
+ name?: string;
32
+ /**
33
+ * @deprecated This configuration is now handled by BrandingProvider
34
+ */
35
+ type?: string;
36
+ /**
37
+ * @deprecated This configuration is now handled by BrandingProvider
38
+ */
39
+ forceTheme?: 'light' | 'dark';
40
+ /**
41
+ * @deprecated This configuration is now handled by BrandingProvider
42
+ */
43
+ autoFetch?: boolean;
44
+ /**
45
+ * @deprecated This configuration is now handled by BrandingProvider
46
+ */
47
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
48
+ }
49
+ /**
50
+ * Return type of the useBranding hook
51
+ */
52
+ export interface UseBrandingReturn {
53
+ /**
54
+ * The raw branding preference data
55
+ */
56
+ brandingPreference: BrandingPreference | null;
57
+ /**
58
+ * The transformed theme object
59
+ */
60
+ theme: Theme | null;
61
+ /**
62
+ * The active theme mode from branding preference ('light' | 'dark')
63
+ */
64
+ activeTheme: 'light' | 'dark' | null;
65
+ /**
66
+ * Loading state
67
+ */
68
+ isLoading: boolean;
69
+ /**
70
+ * Error state
71
+ */
72
+ error: Error | null;
73
+ /**
74
+ * Function to manually fetch branding preference
75
+ */
76
+ fetchBranding: () => Promise<void>;
77
+ /**
78
+ * Function to refetch branding preference
79
+ * This bypasses the single-call restriction and forces a new API call
80
+ */
81
+ refetch: () => Promise<void>;
82
+ }
83
+ /**
84
+ * React hook for accessing branding preferences from the BrandingProvider context.
85
+ * This hook provides access to branding preferences, theme data, and loading states.
86
+ *
87
+ * @deprecated Consider using useBrandingContext directly for better performance.
88
+ * This hook is maintained for backward compatibility.
89
+ *
90
+ * @param config - Configuration options (deprecated, use BrandingProvider props instead)
91
+ * @returns Object containing branding preference data, theme, loading state, error, and refetch function
92
+ *
93
+ * @example
94
+ * Basic usage:
95
+ * ```tsx
96
+ * function MyComponent() {
97
+ * const { theme, activeTheme, isLoading, error } = useBranding();
98
+ *
99
+ * if (isLoading) return <div>Loading branding...</div>;
100
+ * if (error) return <div>Error: {error.message}</div>;
101
+ *
102
+ * return (
103
+ * <div style={{ color: theme?.colors?.primary?.main }}>
104
+ * <p>Active theme mode: {activeTheme}</p>
105
+ * <p>Styled with Asgardeo branding</p>
106
+ * </div>
107
+ * );
108
+ * }
109
+ * ```
110
+ *
111
+ * @example
112
+ * For new implementations, use BrandingProvider with useBrandingContext:
113
+ * ```tsx
114
+ * // In your root component
115
+ * <BrandingProvider baseUrl="https://api.asgardeo.io/t/your-org">
116
+ * <App />
117
+ * </BrandingProvider>
118
+ *
119
+ * // In your component
120
+ * function MyComponent() {
121
+ * const { theme, activeTheme, isLoading, error } = useBrandingContext();
122
+ * // ... rest of your component
123
+ * }
124
+ * ```
125
+ */
126
+ export declare const useBranding: (config?: UseBrandingConfig) => UseBrandingReturn;
127
+ export default useBranding;
package/dist/index.d.ts CHANGED
@@ -51,12 +51,20 @@ export { default as ThemeProvider } from './contexts/Theme/ThemeProvider';
51
51
  export * from './contexts/Theme/ThemeProvider';
52
52
  export { default as useTheme } from './contexts/Theme/useTheme';
53
53
  export * from './contexts/Theme/useTheme';
54
+ export { default as BrandingContext } from './contexts/Branding/BrandingContext';
55
+ export * from './contexts/Branding/BrandingContext';
56
+ export { default as BrandingProvider } from './contexts/Branding/BrandingProvider';
57
+ export * from './contexts/Branding/BrandingProvider';
58
+ export { default as useBrandingContext } from './contexts/Branding/useBrandingContext';
59
+ export * from './contexts/Branding/useBrandingContext';
54
60
  export { default as useBrowserUrl } from './hooks/useBrowserUrl';
55
61
  export * from './hooks/useBrowserUrl';
56
62
  export { default as useTranslation } from './hooks/useTranslation';
57
63
  export * from './hooks/useTranslation';
58
64
  export { default as useForm } from './hooks/useForm';
59
65
  export * from './hooks/useForm';
66
+ export { default as useBranding } from './hooks/useBranding';
67
+ export * from './hooks/useBranding';
60
68
  export { default as BaseSignInButton } from './components/actions/SignInButton/BaseSignInButton';
61
69
  export * from './components/actions/SignInButton/BaseSignInButton';
62
70
  export { default as SignInButton } from './components/actions/SignInButton/SignInButton';
@@ -159,6 +167,8 @@ export { default as Typography } from './components/primitives/Typography/Typogr
159
167
  export * from './components/primitives/Typography/Typography';
160
168
  export { default as Divider } from './components/primitives/Divider/Divider';
161
169
  export * from './components/primitives/Divider/Divider';
170
+ export { default as Logo } from './components/primitives/Logo/Logo';
171
+ export * from './components/primitives/Logo/Logo';
162
172
  export { default as Spinner } from './components/primitives/Spinner/Spinner';
163
173
  export * from './components/primitives/Spinner/Spinner';
164
174
  export { default as Eye } from './components/primitives/Icons/Eye';