@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.
- package/dist/AsgardeoReactClient.d.ts +4 -3
- package/dist/api/getAllOrganizations.d.ts +2 -2
- package/dist/cjs/index.js +2508 -2236
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +18 -7
- package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +2 -3
- package/dist/components/primitives/Logo/Logo.d.ts +55 -0
- package/dist/contexts/Branding/BrandingContext.d.ts +51 -0
- package/dist/contexts/Branding/BrandingProvider.d.ts +88 -0
- package/dist/contexts/Branding/useBrandingContext.d.ts +44 -0
- package/dist/contexts/Organization/OrganizationContext.d.ts +4 -42
- package/dist/contexts/Organization/OrganizationProvider.d.ts +10 -11
- package/dist/contexts/Organization/useOrganization.d.ts +2 -2
- package/dist/contexts/Theme/ThemeContext.d.ts +12 -0
- package/dist/contexts/Theme/ThemeProvider.d.ts +54 -2
- package/dist/contexts/Theme/types.d.ts +55 -0
- package/dist/hooks/useBranding.d.ts +127 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2143 -1869
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { AllOrganizationsApiResponse, Organization } from '@asgardeo/browser';
|
|
18
19
|
import { FC, ReactNode } from 'react';
|
|
19
|
-
|
|
20
|
+
export interface OrganizationWithSwitchAccess extends Organization {
|
|
21
|
+
canSwitch: boolean;
|
|
22
|
+
}
|
|
20
23
|
/**
|
|
21
24
|
* Props interface for the BaseOrganizationList component.
|
|
22
25
|
*/
|
|
@@ -26,9 +29,13 @@ export interface BaseOrganizationListProps {
|
|
|
26
29
|
*/
|
|
27
30
|
className?: string;
|
|
28
31
|
/**
|
|
29
|
-
* List of organizations
|
|
32
|
+
* List of organizations discoverable to the signed-in user.
|
|
33
|
+
*/
|
|
34
|
+
allOrganizations: AllOrganizationsApiResponse;
|
|
35
|
+
/**
|
|
36
|
+
* List of organizations associated to the signed-in user.
|
|
30
37
|
*/
|
|
31
|
-
|
|
38
|
+
myOrganizations: Organization[];
|
|
32
39
|
/**
|
|
33
40
|
* Error message to display
|
|
34
41
|
*/
|
|
@@ -74,13 +81,13 @@ export interface BaseOrganizationListProps {
|
|
|
74
81
|
*/
|
|
75
82
|
renderOrganization?: (organization: OrganizationWithSwitchAccess, index: number) => ReactNode;
|
|
76
83
|
/**
|
|
77
|
-
*
|
|
84
|
+
* Function called when an organization is selected/clicked
|
|
78
85
|
*/
|
|
79
|
-
|
|
86
|
+
onOrganizationSelect?: (organization: OrganizationWithSwitchAccess) => void;
|
|
80
87
|
/**
|
|
81
|
-
*
|
|
88
|
+
* Inline styles to apply to the container
|
|
82
89
|
*/
|
|
83
|
-
|
|
90
|
+
style?: React.CSSProperties;
|
|
84
91
|
/**
|
|
85
92
|
* Display mode: 'inline' for normal display, 'popup' for modal dialog
|
|
86
93
|
*/
|
|
@@ -97,6 +104,10 @@ export interface BaseOrganizationListProps {
|
|
|
97
104
|
* Title for the popup dialog (only used in popup mode)
|
|
98
105
|
*/
|
|
99
106
|
title?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Whether to show the organization status in the list
|
|
109
|
+
*/
|
|
110
|
+
showStatus?: boolean;
|
|
100
111
|
}
|
|
101
112
|
/**
|
|
102
113
|
* BaseOrganizationList component displays a list of organizations with pagination support.
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { FC } from 'react';
|
|
19
|
-
import { BaseOrganizationListProps } from './BaseOrganizationList';
|
|
20
|
-
import { OrganizationWithSwitchAccess } from '../../../contexts/Organization/OrganizationContext';
|
|
19
|
+
import { BaseOrganizationListProps, OrganizationWithSwitchAccess } from './BaseOrganizationList';
|
|
21
20
|
/**
|
|
22
21
|
* Configuration options for the OrganizationList component.
|
|
23
22
|
*/
|
|
@@ -43,7 +42,7 @@ export interface OrganizationListConfig {
|
|
|
43
42
|
* Props interface for the OrganizationList component.
|
|
44
43
|
* Uses the enhanced OrganizationContext instead of the useOrganizations hook.
|
|
45
44
|
*/
|
|
46
|
-
export interface OrganizationListProps extends Omit<BaseOrganizationListProps, '
|
|
45
|
+
export interface OrganizationListProps extends Omit<BaseOrganizationListProps, 'myOrganizations' | 'allOrganizations' | 'error' | 'fetchMore' | 'hasMore' | 'isLoading' | 'isLoadingMore' | 'myOrganizations'>, OrganizationListConfig {
|
|
47
46
|
/**
|
|
48
47
|
* Function called when an organization is selected/clicked
|
|
49
48
|
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { FC } from 'react';
|
|
19
|
+
/**
|
|
20
|
+
* Props for the Logo component.
|
|
21
|
+
*/
|
|
22
|
+
export interface LogoProps {
|
|
23
|
+
/**
|
|
24
|
+
* Custom CSS class name for the logo.
|
|
25
|
+
*/
|
|
26
|
+
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Custom logo URL to override theme logo.
|
|
29
|
+
*/
|
|
30
|
+
src?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Custom alt text for the logo.
|
|
33
|
+
*/
|
|
34
|
+
alt?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Custom title for the logo.
|
|
37
|
+
*/
|
|
38
|
+
title?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Size of the logo.
|
|
41
|
+
*/
|
|
42
|
+
size?: 'small' | 'medium' | 'large';
|
|
43
|
+
/**
|
|
44
|
+
* Custom style object.
|
|
45
|
+
*/
|
|
46
|
+
style?: React.CSSProperties;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Logo component that displays the brand logo from theme or custom source.
|
|
50
|
+
*
|
|
51
|
+
* @param props - The props for the Logo component.
|
|
52
|
+
* @returns The rendered Logo component.
|
|
53
|
+
*/
|
|
54
|
+
declare const Logo: FC<LogoProps>;
|
|
55
|
+
export default Logo;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
export interface BrandingContextValue {
|
|
20
|
+
/**
|
|
21
|
+
* The raw branding preference data
|
|
22
|
+
*/
|
|
23
|
+
brandingPreference: BrandingPreference | null;
|
|
24
|
+
/**
|
|
25
|
+
* The transformed theme object
|
|
26
|
+
*/
|
|
27
|
+
theme: Theme | null;
|
|
28
|
+
/**
|
|
29
|
+
* The active theme mode from branding preference ('light' | 'dark')
|
|
30
|
+
*/
|
|
31
|
+
activeTheme: 'light' | 'dark' | null;
|
|
32
|
+
/**
|
|
33
|
+
* Loading state
|
|
34
|
+
*/
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Error state
|
|
38
|
+
*/
|
|
39
|
+
error: Error | null;
|
|
40
|
+
/**
|
|
41
|
+
* Function to manually fetch branding preference
|
|
42
|
+
*/
|
|
43
|
+
fetchBranding: () => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Function to refetch branding preference
|
|
46
|
+
* This bypasses the single-call restriction and forces a new API call
|
|
47
|
+
*/
|
|
48
|
+
refetch: () => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
declare const BrandingContext: import("react").Context<BrandingContextValue>;
|
|
51
|
+
export default BrandingContext;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { FC, PropsWithChildren } from 'react';
|
|
19
|
+
import { BrandingPreference } from '@asgardeo/browser';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options for the BrandingProvider
|
|
22
|
+
*/
|
|
23
|
+
export interface BrandingProviderProps {
|
|
24
|
+
/**
|
|
25
|
+
* The branding preference data passed from parent (typically AsgardeoProvider)
|
|
26
|
+
*/
|
|
27
|
+
brandingPreference?: BrandingPreference | null;
|
|
28
|
+
/**
|
|
29
|
+
* Force a specific theme ('light' or 'dark')
|
|
30
|
+
* If not provided, will use the activeTheme from branding preference
|
|
31
|
+
*/
|
|
32
|
+
forceTheme?: 'light' | 'dark';
|
|
33
|
+
/**
|
|
34
|
+
* Whether the branding provider is enabled
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Loading state passed from parent
|
|
40
|
+
*/
|
|
41
|
+
isLoading?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Error state passed from parent
|
|
44
|
+
*/
|
|
45
|
+
error?: Error | null;
|
|
46
|
+
/**
|
|
47
|
+
* Function to refetch branding preference passed from parent
|
|
48
|
+
*/
|
|
49
|
+
refetch?: () => Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* BrandingProvider component that manages branding state and provides branding context to child components.
|
|
53
|
+
*
|
|
54
|
+
* This provider receives branding preferences from a parent component (typically AsgardeoProvider)
|
|
55
|
+
* and transforms them into theme objects, making them available to all child components.
|
|
56
|
+
*
|
|
57
|
+
* Features:
|
|
58
|
+
* - Receives branding preferences as props
|
|
59
|
+
* - Theme transformation from branding preferences
|
|
60
|
+
* - Loading and error states
|
|
61
|
+
* - Support for custom theme forcing
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* Basic usage (typically used within AsgardeoProvider):
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <BrandingProvider
|
|
67
|
+
* brandingPreference={brandingData}
|
|
68
|
+
* isLoading={isFetching}
|
|
69
|
+
* error={fetchError}
|
|
70
|
+
* >
|
|
71
|
+
* <App />
|
|
72
|
+
* </BrandingProvider>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* With custom theme forcing:
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <BrandingProvider
|
|
79
|
+
* brandingPreference={brandingData}
|
|
80
|
+
* forceTheme="dark"
|
|
81
|
+
* enabled={true}
|
|
82
|
+
* >
|
|
83
|
+
* <App />
|
|
84
|
+
* </BrandingProvider>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare const BrandingProvider: FC<PropsWithChildren<BrandingProviderProps>>;
|
|
88
|
+
export default BrandingProvider;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { BrandingContextValue } from './BrandingContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access the branding context.
|
|
21
|
+
* This hook provides access to branding preferences, theme data, and loading states.
|
|
22
|
+
*
|
|
23
|
+
* @returns The branding context value containing branding preference data, theme, and control functions
|
|
24
|
+
* @throws Error if used outside of a BrandingProvider
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* function MyComponent() {
|
|
29
|
+
* const { theme, activeTheme, isLoading, error } = useBrandingContext();
|
|
30
|
+
*
|
|
31
|
+
* if (isLoading) return <div>Loading branding...</div>;
|
|
32
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <div style={{ color: theme?.colors?.primary?.main }}>
|
|
36
|
+
* <p>Active theme mode: {activeTheme}</p>
|
|
37
|
+
* <p>Styled with Asgardeo branding</p>
|
|
38
|
+
* </div>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const useBrandingContext: () => BrandingContextValue;
|
|
44
|
+
export default useBrandingContext;
|
|
@@ -15,57 +15,19 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { Organization } from '@asgardeo/browser';
|
|
18
|
+
import { AllOrganizationsApiResponse, Organization } from '@asgardeo/browser';
|
|
19
19
|
import { Context } from 'react';
|
|
20
|
-
/**
|
|
21
|
-
* Interface for organizations with switch access information.
|
|
22
|
-
*/
|
|
23
|
-
export interface OrganizationWithSwitchAccess extends Organization {
|
|
24
|
-
/**
|
|
25
|
-
* Whether the user has switch access to this organization
|
|
26
|
-
*/
|
|
27
|
-
canSwitch: boolean;
|
|
28
|
-
}
|
|
29
20
|
/**
|
|
30
21
|
* Props interface of {@link OrganizationContext}
|
|
31
22
|
*/
|
|
32
23
|
export type OrganizationContextProps = {
|
|
33
24
|
currentOrganization: Organization | null;
|
|
34
25
|
error: string | null;
|
|
35
|
-
getOrganizations: () => Promise<Organization[]>;
|
|
36
26
|
isLoading: boolean;
|
|
37
|
-
|
|
38
|
-
revalidateOrganizations: () => Promise<void>;
|
|
27
|
+
myOrganizations: Organization[];
|
|
39
28
|
switchOrganization: (organization: Organization) => Promise<void>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
paginatedOrganizations: OrganizationWithSwitchAccess[];
|
|
44
|
-
/**
|
|
45
|
-
* Whether there are more organizations to load
|
|
46
|
-
*/
|
|
47
|
-
hasMore: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Whether more data is being loaded
|
|
50
|
-
*/
|
|
51
|
-
isLoadingMore: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Total number of organizations
|
|
54
|
-
*/
|
|
55
|
-
totalCount: number;
|
|
56
|
-
/**
|
|
57
|
-
* Function to fetch more organizations (pagination)
|
|
58
|
-
*/
|
|
59
|
-
fetchMore: () => Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Function to fetch paginated organizations with switch access
|
|
62
|
-
*/
|
|
63
|
-
fetchPaginatedOrganizations: (config?: {
|
|
64
|
-
filter?: string;
|
|
65
|
-
limit?: number;
|
|
66
|
-
recursive?: boolean;
|
|
67
|
-
reset?: boolean;
|
|
68
|
-
}) => Promise<void>;
|
|
29
|
+
revalidateMyOrganizations: () => Promise<Organization[]>;
|
|
30
|
+
getAllOrganizations: () => Promise<AllOrganizationsApiResponse>;
|
|
69
31
|
};
|
|
70
32
|
/**
|
|
71
33
|
* Context object for managing organization data and related operations.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { Organization } from '@asgardeo/browser';
|
|
18
|
+
import { Organization, AllOrganizationsApiResponse } from '@asgardeo/browser';
|
|
19
19
|
import { FC, PropsWithChildren } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Props interface of {@link OrganizationProvider}
|
|
@@ -30,9 +30,9 @@ export interface OrganizationProviderProps {
|
|
|
30
30
|
*/
|
|
31
31
|
currentOrganization?: Organization | null;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* List of organizations the signed-in user belongs to.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
myOrganizations?: Organization[];
|
|
36
36
|
/**
|
|
37
37
|
* Callback function called when an error occurs
|
|
38
38
|
*/
|
|
@@ -44,7 +44,12 @@ export interface OrganizationProviderProps {
|
|
|
44
44
|
/**
|
|
45
45
|
* Initial list of organizations
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
getAllOrganizations?: () => Promise<AllOrganizationsApiResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Refetch the my organizations list.
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
revalidateMyOrganizations: () => Promise<Organization[]>;
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* OrganizationProvider component that manages organization data and provides it through OrganizationContext.
|
|
@@ -54,7 +59,6 @@ export interface OrganizationProviderProps {
|
|
|
54
59
|
* - Manages current organization state
|
|
55
60
|
* - Provides functions for switching organizations and refreshing data
|
|
56
61
|
* - Handles loading states and errors
|
|
57
|
-
* - Accepts a custom getOrganizations function for flexible data fetching
|
|
58
62
|
*
|
|
59
63
|
* @example
|
|
60
64
|
* ```tsx
|
|
@@ -63,11 +67,6 @@ export interface OrganizationProviderProps {
|
|
|
63
67
|
* <App />
|
|
64
68
|
* </OrganizationProvider>
|
|
65
69
|
*
|
|
66
|
-
* // With custom getOrganizations function
|
|
67
|
-
* <OrganizationProvider getOrganizations={async () => asgardeo.getOrganizations()}>
|
|
68
|
-
* <App />
|
|
69
|
-
* </OrganizationProvider>
|
|
70
|
-
*
|
|
71
70
|
* // With custom error handling
|
|
72
71
|
* <OrganizationProvider onError={(error) => console.error('Organization error:', error)}>
|
|
73
72
|
* <App />
|
|
@@ -80,7 +79,7 @@ export interface OrganizationProviderProps {
|
|
|
80
79
|
* <App />
|
|
81
80
|
* </OrganizationProvider>
|
|
82
81
|
*
|
|
83
|
-
* // Disable auto-fetch (fetch manually using
|
|
82
|
+
* // Disable auto-fetch (fetch manually using revalidateMyOrganizations)
|
|
84
83
|
* <OrganizationProvider autoFetch={false}>
|
|
85
84
|
* <App />
|
|
86
85
|
* </OrganizationProvider>
|
|
@@ -38,7 +38,7 @@ import { OrganizationContextProps } from './OrganizationContext';
|
|
|
38
38
|
* organizations,
|
|
39
39
|
* currentOrganization,
|
|
40
40
|
* switchOrganization,
|
|
41
|
-
*
|
|
41
|
+
* revalidateMyOrganizations,
|
|
42
42
|
* getOrganizations,
|
|
43
43
|
* isLoading,
|
|
44
44
|
* error
|
|
@@ -68,7 +68,7 @@ import { OrganizationContextProps } from './OrganizationContext';
|
|
|
68
68
|
* </option>
|
|
69
69
|
* ))}
|
|
70
70
|
* </select>
|
|
71
|
-
* <button onClick={
|
|
71
|
+
* <button onClick={revalidateMyOrganizations}>
|
|
72
72
|
* Refresh Organizations
|
|
73
73
|
* </button>
|
|
74
74
|
* <button onClick={async () => {
|
|
@@ -20,6 +20,18 @@ export interface ThemeContextValue {
|
|
|
20
20
|
theme: Theme;
|
|
21
21
|
colorScheme: 'light' | 'dark';
|
|
22
22
|
toggleTheme: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether branding theme is currently loading
|
|
25
|
+
*/
|
|
26
|
+
isBrandingLoading?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Error from branding theme fetch, if any
|
|
29
|
+
*/
|
|
30
|
+
brandingError?: Error | null;
|
|
31
|
+
/**
|
|
32
|
+
* Whether branding inheritance is enabled
|
|
33
|
+
*/
|
|
34
|
+
inheritFromBranding?: boolean;
|
|
23
35
|
}
|
|
24
36
|
declare const ThemeContext: import("react").Context<ThemeContextValue>;
|
|
25
37
|
export default ThemeContext;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { FC, PropsWithChildren } from 'react';
|
|
19
|
-
import { ThemeConfig, ThemeMode, RecursivePartial, BrowserThemeDetection } from '@asgardeo/browser';
|
|
19
|
+
import { ThemeConfig, ThemeMode, RecursivePartial, BrowserThemeDetection, ThemePreferences } from '@asgardeo/browser';
|
|
20
20
|
export interface ThemeProviderProps {
|
|
21
21
|
theme?: RecursivePartial<ThemeConfig>;
|
|
22
22
|
/**
|
|
@@ -25,12 +25,64 @@ export interface ThemeProviderProps {
|
|
|
25
25
|
* - 'dark': Always use dark theme
|
|
26
26
|
* - 'system': Use system preference (prefers-color-scheme media query)
|
|
27
27
|
* - 'class': Detect theme based on CSS classes on HTML element
|
|
28
|
+
* - 'branding': Use active theme from branding preference (requires inheritFromBranding=true)
|
|
28
29
|
*/
|
|
29
|
-
mode?: ThemeMode;
|
|
30
|
+
mode?: ThemeMode | 'branding';
|
|
30
31
|
/**
|
|
31
32
|
* Configuration for theme detection when using 'class' or 'system' mode
|
|
32
33
|
*/
|
|
33
34
|
detection?: BrowserThemeDetection;
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for branding integration
|
|
37
|
+
*/
|
|
38
|
+
inheritFromBranding?: ThemePreferences['inheritFromBranding'];
|
|
34
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* ThemeProvider component that manages theme state and provides theme context to child components.
|
|
42
|
+
*
|
|
43
|
+
* This provider integrates with Asgardeo branding preferences to automatically apply
|
|
44
|
+
* organization-specific themes while allowing for custom theme overrides.
|
|
45
|
+
*
|
|
46
|
+
* Features:
|
|
47
|
+
* - Automatic theme mode detection (light/dark/system/class)
|
|
48
|
+
* - Integration with Asgardeo branding API through useBranding hook
|
|
49
|
+
* - Merging of branding themes with custom theme configurations
|
|
50
|
+
* - CSS variable injection for easy styling
|
|
51
|
+
* - Loading and error states for branding integration
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* Basic usage with branding integration:
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <ThemeProvider inheritFromBranding={true}>
|
|
57
|
+
* <App />
|
|
58
|
+
* </ThemeProvider>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* With custom theme overrides:
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <ThemeProvider
|
|
65
|
+
* theme={{
|
|
66
|
+
* colors: {
|
|
67
|
+
* primary: { main: '#custom-color' }
|
|
68
|
+
* }
|
|
69
|
+
* }}
|
|
70
|
+
* inheritFromBranding={true}
|
|
71
|
+
* >
|
|
72
|
+
* <App />
|
|
73
|
+
* </ThemeProvider>
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* With branding-driven theme mode:
|
|
78
|
+
* ```tsx
|
|
79
|
+
* <ThemeProvider
|
|
80
|
+
* mode="branding"
|
|
81
|
+
* inheritFromBranding={true}
|
|
82
|
+
* >
|
|
83
|
+
* <App />
|
|
84
|
+
* </ThemeProvider>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
35
87
|
declare const ThemeProvider: FC<PropsWithChildren<ThemeProviderProps>>;
|
|
36
88
|
export default ThemeProvider;
|
|
@@ -64,7 +64,62 @@ export interface ThemeConfig {
|
|
|
64
64
|
spacing: {
|
|
65
65
|
unit: number;
|
|
66
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* The prefix used for CSS variables.
|
|
69
|
+
* @default 'asgardeo' (from VendorConstants.VENDOR_PREFIX)
|
|
70
|
+
*/
|
|
71
|
+
cssVarPrefix?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ThemeVars {
|
|
74
|
+
colors: {
|
|
75
|
+
primary: {
|
|
76
|
+
main: string;
|
|
77
|
+
contrastText: string;
|
|
78
|
+
};
|
|
79
|
+
secondary: {
|
|
80
|
+
main: string;
|
|
81
|
+
contrastText: string;
|
|
82
|
+
};
|
|
83
|
+
background: {
|
|
84
|
+
surface: string;
|
|
85
|
+
disabled: string;
|
|
86
|
+
body: {
|
|
87
|
+
main: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
error: {
|
|
91
|
+
main: string;
|
|
92
|
+
contrastText: string;
|
|
93
|
+
};
|
|
94
|
+
success: {
|
|
95
|
+
main: string;
|
|
96
|
+
contrastText: string;
|
|
97
|
+
};
|
|
98
|
+
warning: {
|
|
99
|
+
main: string;
|
|
100
|
+
contrastText: string;
|
|
101
|
+
};
|
|
102
|
+
text: {
|
|
103
|
+
primary: string;
|
|
104
|
+
secondary: string;
|
|
105
|
+
};
|
|
106
|
+
border: string;
|
|
107
|
+
};
|
|
108
|
+
spacing: {
|
|
109
|
+
unit: string;
|
|
110
|
+
};
|
|
111
|
+
borderRadius: {
|
|
112
|
+
small: string;
|
|
113
|
+
medium: string;
|
|
114
|
+
large: string;
|
|
115
|
+
};
|
|
116
|
+
shadows: {
|
|
117
|
+
small: string;
|
|
118
|
+
medium: string;
|
|
119
|
+
large: string;
|
|
120
|
+
};
|
|
67
121
|
}
|
|
68
122
|
export interface Theme extends ThemeConfig {
|
|
69
123
|
cssVariables: Record<string, string>;
|
|
124
|
+
vars: ThemeVars;
|
|
70
125
|
}
|