@asgardeo/react 0.12.0 → 0.13.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.
- package/dist/api/createOrganization.d.ts +5 -1
- package/dist/api/getAllOrganizations.d.ts +5 -1
- package/dist/api/getMeOrganizations.d.ts +5 -1
- package/dist/api/getOrganization.d.ts +5 -1
- package/dist/api/getSchemas.d.ts +5 -1
- package/dist/api/getScim2Me.d.ts +5 -1
- package/dist/api/updateMeProfile.d.ts +5 -1
- package/dist/api/updateOrganization.d.ts +5 -1
- package/dist/cjs/index.js +2603 -2087
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +5 -1
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +5 -1
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +5 -1
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +3 -0
- package/dist/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.d.ts +5 -0
- package/dist/components/presentation/auth/AuthOptionFactory.d.ts +14 -1
- package/dist/components/presentation/auth/InviteUser/v2/BaseInviteUser.d.ts +5 -0
- package/dist/components/presentation/auth/SignIn/v2/BaseSignIn.d.ts +5 -1
- package/dist/components/presentation/auth/SignIn/v2/SignIn.d.ts +5 -1
- package/dist/{utils/v2/resolveTranslation.d.ts → components/primitives/Icons/ArrowLeftRight.d.ts} +11 -9
- package/dist/components/primitives/Icons/flowIconRegistry.d.ts +28 -0
- package/dist/components/primitives/Icons/index.d.ts +1 -0
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +23 -1
- package/dist/contexts/FlowMeta/FlowMetaContext.d.ts +39 -0
- package/dist/contexts/FlowMeta/FlowMetaProvider.d.ts +50 -0
- package/dist/contexts/FlowMeta/useFlowMeta.d.ts +20 -0
- package/dist/contexts/I18n/I18nContext.d.ts +5 -0
- package/dist/contexts/Theme/ThemeProvider.d.ts +36 -39
- package/dist/contexts/Theme/v1/ThemeProvider.d.ts +88 -0
- package/dist/contexts/Theme/v2/ThemeProvider.d.ts +57 -0
- package/dist/index.js +2056 -1540
- package/dist/index.js.map +4 -4
- package/dist/utils/applyThemeToDOM.d.ts +24 -0
- package/dist/utils/normalizeThemeConfig.d.ts +30 -0
- package/dist/utils/v2/buildThemeConfigFromFlowMeta.d.ts +33 -0
- package/dist/utils/v2/flowTransformer.d.ts +3 -3
- package/dist/utils/v2/resolveTranslationsInArray.d.ts +4 -2
- package/dist/utils/v2/resolveTranslationsInObject.d.ts +5 -3
- package/package.json +6 -5
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { WithPreferences } from '@asgardeo/browser';
|
|
18
|
+
import { FlowMetadataResponse, WithPreferences } from '@asgardeo/browser';
|
|
19
19
|
import { ButtonHTMLAttributes, ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Common props shared by all {@link BaseSignInButton} components.
|
|
@@ -25,6 +25,10 @@ export interface CommonBaseSignInButtonProps {
|
|
|
25
25
|
* Loading state during sign-in process
|
|
26
26
|
*/
|
|
27
27
|
isLoading?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
30
|
+
*/
|
|
31
|
+
meta?: FlowMetadataResponse | null;
|
|
28
32
|
/**
|
|
29
33
|
* Function to initiate the sign-in process
|
|
30
34
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { WithPreferences } from '@asgardeo/browser';
|
|
18
|
+
import { FlowMetadataResponse, WithPreferences } from '@asgardeo/browser';
|
|
19
19
|
import { ForwardRefExoticComponent, ButtonHTMLAttributes, ReactNode, RefAttributes } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Common props shared by all {@link BaseSignOutButton} components.
|
|
@@ -25,6 +25,10 @@ export interface CommonBaseSignOutButtonProps {
|
|
|
25
25
|
* Loading state during sign-out process
|
|
26
26
|
*/
|
|
27
27
|
isLoading?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
30
|
+
*/
|
|
31
|
+
meta?: FlowMetadataResponse | null;
|
|
28
32
|
/**
|
|
29
33
|
* Function to initiate the sign-out process
|
|
30
34
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { WithPreferences } from '@asgardeo/browser';
|
|
18
|
+
import { FlowMetadataResponse, WithPreferences } from '@asgardeo/browser';
|
|
19
19
|
import { ForwardRefExoticComponent, ButtonHTMLAttributes, ReactNode, RefAttributes } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Common props shared by all {@link BaseSignUpButton} components.
|
|
@@ -25,6 +25,10 @@ export interface CommonBaseSignUpButtonProps {
|
|
|
25
25
|
* Loading state during sign-up process
|
|
26
26
|
*/
|
|
27
27
|
isLoading?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
30
|
+
*/
|
|
31
|
+
meta?: FlowMetadataResponse | null;
|
|
28
32
|
/**
|
|
29
33
|
* Function to initiate the sign-up process
|
|
30
34
|
*/
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { FlowMetadataResponse } from '@asgardeo/browser';
|
|
18
19
|
import { FC, ReactNode } from 'react';
|
|
19
20
|
import { BaseUserDropdownProps } from './BaseUserDropdown';
|
|
20
21
|
/**
|
|
@@ -27,6 +28,8 @@ export interface UserDropdownRenderProps {
|
|
|
27
28
|
isLoading: boolean;
|
|
28
29
|
/** Whether the profile dialog is currently open */
|
|
29
30
|
isProfileOpen: boolean;
|
|
31
|
+
/** Flow metadata returned by the platform (v2 only). `null` while loading or unavailable. */
|
|
32
|
+
meta: FlowMetadataResponse | null;
|
|
30
33
|
/** Function to open the user profile dialog */
|
|
31
34
|
openProfile: () => void;
|
|
32
35
|
/** Function to sign out the user */
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { FlowMetadataResponse } from '@asgardeo/browser';
|
|
18
19
|
import { FC, ReactNode } from 'react';
|
|
19
20
|
import { CardProps } from '../../../../primitives/Card/Card';
|
|
20
21
|
/**
|
|
@@ -98,6 +99,10 @@ export interface BaseAcceptInviteRenderProps {
|
|
|
98
99
|
* Whether the invite token is being validated.
|
|
99
100
|
*/
|
|
100
101
|
isValidatingToken: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
104
|
+
*/
|
|
105
|
+
meta: FlowMetadataResponse | null;
|
|
101
106
|
/**
|
|
102
107
|
* Subtitle for the current step.
|
|
103
108
|
*/
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { EmbeddedFlowComponentV2 as EmbeddedFlowComponent } from '@asgardeo/browser';
|
|
18
|
+
import { FlowMetadataResponse, EmbeddedFlowComponentV2 as EmbeddedFlowComponent } from '@asgardeo/browser';
|
|
19
19
|
import { ReactElement } from 'react';
|
|
20
|
+
import { UseTranslation } from '../../../hooks/useTranslation';
|
|
20
21
|
export type AuthType = 'signin' | 'signup';
|
|
21
22
|
/**
|
|
22
23
|
* Processes an array of components and renders them as React elements for sign-in.
|
|
@@ -24,9 +25,13 @@ export type AuthType = 'signin' | 'signup';
|
|
|
24
25
|
export declare const renderSignInComponents: (components: EmbeddedFlowComponent[], formValues: Record<string, string>, touchedFields: Record<string, boolean>, formErrors: Record<string, string>, isLoading: boolean, isFormValid: boolean, onInputChange: (name: string, value: string) => void, options?: {
|
|
25
26
|
buttonClassName?: string;
|
|
26
27
|
inputClassName?: string;
|
|
28
|
+
/** Flow metadata for resolving {{meta(...)}} expressions at render time */
|
|
29
|
+
meta?: FlowMetadataResponse | null;
|
|
27
30
|
onInputBlur?: (name: string) => void;
|
|
28
31
|
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>, skipValidation?: boolean) => void;
|
|
29
32
|
size?: "small" | "medium" | "large";
|
|
33
|
+
/** Translation function for resolving {{t(...)}} expressions at render time */
|
|
34
|
+
t?: UseTranslation["t"];
|
|
30
35
|
variant?: any;
|
|
31
36
|
}) => ReactElement[];
|
|
32
37
|
/**
|
|
@@ -35,9 +40,13 @@ export declare const renderSignInComponents: (components: EmbeddedFlowComponent[
|
|
|
35
40
|
export declare const renderSignUpComponents: (components: EmbeddedFlowComponent[], formValues: Record<string, string>, touchedFields: Record<string, boolean>, formErrors: Record<string, string>, isLoading: boolean, isFormValid: boolean, onInputChange: (name: string, value: string) => void, options?: {
|
|
36
41
|
buttonClassName?: string;
|
|
37
42
|
inputClassName?: string;
|
|
43
|
+
/** Flow metadata for resolving {{meta(...)}} expressions at render time */
|
|
44
|
+
meta?: FlowMetadataResponse | null;
|
|
38
45
|
onInputBlur?: (name: string) => void;
|
|
39
46
|
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>, skipValidation?: boolean) => void;
|
|
40
47
|
size?: "small" | "medium" | "large";
|
|
48
|
+
/** Translation function for resolving {{t(...)}} expressions at render time */
|
|
49
|
+
t?: UseTranslation["t"];
|
|
41
50
|
variant?: any;
|
|
42
51
|
}) => ReactElement[];
|
|
43
52
|
/**
|
|
@@ -47,8 +56,12 @@ export declare const renderSignUpComponents: (components: EmbeddedFlowComponent[
|
|
|
47
56
|
export declare const renderInviteUserComponents: (components: EmbeddedFlowComponent[], formValues: Record<string, string>, touchedFields: Record<string, boolean>, formErrors: Record<string, string>, isLoading: boolean, isFormValid: boolean, onInputChange: (name: string, value: string) => void, options?: {
|
|
48
57
|
buttonClassName?: string;
|
|
49
58
|
inputClassName?: string;
|
|
59
|
+
/** Flow metadata for resolving {{meta(...)}} expressions at render time */
|
|
60
|
+
meta?: FlowMetadataResponse | null;
|
|
50
61
|
onInputBlur?: (name: string) => void;
|
|
51
62
|
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>, skipValidation?: boolean) => void;
|
|
52
63
|
size?: "small" | "medium" | "large";
|
|
64
|
+
/** Translation function for resolving {{t(...)}} expressions at render time */
|
|
65
|
+
t?: UseTranslation["t"];
|
|
53
66
|
variant?: any;
|
|
54
67
|
}) => ReactElement[];
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { FlowMetadataResponse } from '@asgardeo/browser';
|
|
18
19
|
import { FC, ReactNode } from 'react';
|
|
19
20
|
import { CardProps } from '../../../../primitives/Card/Card';
|
|
20
21
|
/**
|
|
@@ -89,6 +90,10 @@ export interface BaseInviteUserRenderProps {
|
|
|
89
90
|
* Whether the form is valid.
|
|
90
91
|
*/
|
|
91
92
|
isValid: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
95
|
+
*/
|
|
96
|
+
meta: FlowMetadataResponse | null;
|
|
92
97
|
/**
|
|
93
98
|
* Reset the flow to invite another user.
|
|
94
99
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { EmbeddedSignInFlowRequestV2 as EmbeddedSignInFlowRequest, EmbeddedFlowComponentV2 as EmbeddedFlowComponent } from '@asgardeo/browser';
|
|
18
|
+
import { EmbeddedSignInFlowRequestV2 as EmbeddedSignInFlowRequest, EmbeddedFlowComponentV2 as EmbeddedFlowComponent, FlowMetadataResponse } from '@asgardeo/browser';
|
|
19
19
|
import { FC, ReactNode } from 'react';
|
|
20
20
|
import { CardProps } from '../../../../primitives/Card/Card';
|
|
21
21
|
/**
|
|
@@ -57,6 +57,10 @@ export interface BaseSignInRenderProps {
|
|
|
57
57
|
message: string;
|
|
58
58
|
type: string;
|
|
59
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
62
|
+
*/
|
|
63
|
+
meta: FlowMetadataResponse | null;
|
|
60
64
|
/**
|
|
61
65
|
* Flow subtitle
|
|
62
66
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { EmbeddedFlowComponentV2 as EmbeddedFlowComponent, EmbeddedSignInFlowRequestV2 } from '@asgardeo/browser';
|
|
18
|
+
import { EmbeddedFlowComponentV2 as EmbeddedFlowComponent, EmbeddedSignInFlowRequestV2, FlowMetadataResponse } from '@asgardeo/browser';
|
|
19
19
|
import { FC, ReactNode } from 'react';
|
|
20
20
|
import { BaseSignInProps } from './BaseSignIn';
|
|
21
21
|
/**
|
|
@@ -42,6 +42,10 @@ export interface SignInRenderProps {
|
|
|
42
42
|
* Loading state indicator
|
|
43
43
|
*/
|
|
44
44
|
isLoading: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Flow metadata returned by the platform (v2 only). `null` while loading or unavailable.
|
|
47
|
+
*/
|
|
48
|
+
meta: FlowMetadataResponse | null;
|
|
45
49
|
/**
|
|
46
50
|
* Function to submit authentication data (primary)
|
|
47
51
|
*/
|
package/dist/{utils/v2/resolveTranslation.d.ts → components/primitives/Icons/ArrowLeftRight.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { FC } from 'react';
|
|
19
|
+
export interface ArrowLeftRightProps {
|
|
20
|
+
/** Color of the icon stroke */
|
|
21
|
+
color?: string;
|
|
22
|
+
/** Icon size in pixels */
|
|
23
|
+
size?: number;
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
|
-
*
|
|
21
|
-
* If the text is not a translation string, returns the original text.
|
|
22
|
-
* @param text - The text to resolve (could be a translation string or regular text)
|
|
23
|
-
* @param t - The translation function from useTranslation
|
|
24
|
-
* @returns The resolved text
|
|
26
|
+
* ArrowLeftRight Icon component (lucide-compatible).
|
|
25
27
|
*/
|
|
26
|
-
|
|
27
|
-
export default
|
|
28
|
+
declare const ArrowLeftRight: FC<ArrowLeftRightProps>;
|
|
29
|
+
export default ArrowLeftRight;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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
|
+
export interface FlowIconProps {
|
|
20
|
+
color?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Registry of icon components keyed by their lucide-compatible name.
|
|
25
|
+
* Add new icons here as needed by flow definitions.
|
|
26
|
+
*/
|
|
27
|
+
declare const flowIconRegistry: Record<string, FC<FlowIconProps>>;
|
|
28
|
+
export default flowIconRegistry;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
export { default as ArrowLeftRight } from './ArrowLeftRight';
|
|
18
19
|
export { default as CircleAlert } from './CircleAlert';
|
|
19
20
|
export { default as CircleCheck } from './CircleCheck';
|
|
20
21
|
export { default as Eye } from './Eye';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions, TokenExchangeRequestConfig, TokenResponse } from '@asgardeo/browser';
|
|
18
|
+
import { FlowMetadataResponse, HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions, TokenExchangeRequestConfig, TokenResponse } from '@asgardeo/browser';
|
|
19
19
|
import { Context } from 'react';
|
|
20
20
|
import AsgardeoReactClient from '../../AsgardeoReactClient';
|
|
21
21
|
import { AsgardeoReactConfig } from '../../models/config';
|
|
@@ -73,6 +73,10 @@ export type AsgardeoContextProps = {
|
|
|
73
73
|
*/
|
|
74
74
|
requestAll: (requestConfigs?: HttpRequestConfig[]) => Promise<HttpResponse<any>[]>;
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Instance ID for multi-instance support.
|
|
78
|
+
*/
|
|
79
|
+
instanceId: number;
|
|
76
80
|
isInitialized: boolean;
|
|
77
81
|
/**
|
|
78
82
|
* Flag indicating whether the SDK is working in the background.
|
|
@@ -82,6 +86,11 @@ export type AsgardeoContextProps = {
|
|
|
82
86
|
* Flag indicating whether the user is signed in or not.
|
|
83
87
|
*/
|
|
84
88
|
isSignedIn: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Flow metadata returned by `GET /flow/meta` (v2 platform only).
|
|
91
|
+
* `null` while loading or when `resolveFromMeta` is disabled.
|
|
92
|
+
*/
|
|
93
|
+
meta: FlowMetadataResponse | null;
|
|
85
94
|
organization: Organization;
|
|
86
95
|
organizationHandle: string | undefined;
|
|
87
96
|
/**
|
|
@@ -94,6 +103,19 @@ export type AsgardeoContextProps = {
|
|
|
94
103
|
* @returns Promise resolving to boolean indicating success.
|
|
95
104
|
*/
|
|
96
105
|
reInitialize: (config: Partial<AsgardeoReactConfig>) => Promise<boolean>;
|
|
106
|
+
/**
|
|
107
|
+
* Resolves `{{ t(key) }}` and `{{ meta(path) }}` template expressions in a string,
|
|
108
|
+
* using the current i18n translation function and flow metadata from context.
|
|
109
|
+
*
|
|
110
|
+
* Useful in render-props patterns where consumers need to expand template strings
|
|
111
|
+
* that come from the server (e.g. component labels, placeholders, headings).
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* const {resolveVars} = useAsgardeo();
|
|
115
|
+
* resolveVars('{{ t(signin.heading.label) }}') // → 'Sign In'
|
|
116
|
+
* resolveVars('Login to {{ meta(application.name) }}') // → 'Login to My App'
|
|
117
|
+
*/
|
|
118
|
+
resolveVars: (text: string | undefined) => string;
|
|
97
119
|
/**
|
|
98
120
|
* Sign-in function to initiate the authentication process.
|
|
99
121
|
* @remark This is the programmatic version of the `SignInButton` component.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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 { FlowMetadataResponse } from '@asgardeo/browser';
|
|
19
|
+
import { Context } from 'react';
|
|
20
|
+
export interface FlowMetaContextValue {
|
|
21
|
+
/**
|
|
22
|
+
* Error from the flow meta fetch, if any
|
|
23
|
+
*/
|
|
24
|
+
error: Error | null;
|
|
25
|
+
/**
|
|
26
|
+
* Manually re-fetch flow metadata
|
|
27
|
+
*/
|
|
28
|
+
fetchFlowMeta: () => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether flow metadata is currently being fetched
|
|
31
|
+
*/
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The fetched flow metadata response, or null while loading / on error
|
|
35
|
+
*/
|
|
36
|
+
meta: FlowMetadataResponse | null;
|
|
37
|
+
}
|
|
38
|
+
declare const FlowMetaContext: Context<FlowMetaContextValue | null>;
|
|
39
|
+
export default FlowMetaContext;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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
|
+
export interface FlowMetaProviderProps {
|
|
20
|
+
/**
|
|
21
|
+
* When false the provider skips fetching and provides null meta.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* FlowMetaProvider fetches flow metadata from the `GET /flow/meta` endpoint
|
|
28
|
+
* (v2 API) and makes it available to child components through `FlowMetaContext`.
|
|
29
|
+
*
|
|
30
|
+
* It is designed to be used in v2 embedded-flow scenarios and integrates with
|
|
31
|
+
* `ThemeProvider` so that theme settings (colors, direction, typography, …)
|
|
32
|
+
* from the server-side design configuration are applied automatically.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <FlowMetaProvider
|
|
37
|
+
* config={{
|
|
38
|
+
* baseUrl: 'https://localhost:8090',
|
|
39
|
+
* type: FlowMetaType.App,
|
|
40
|
+
* id: 'your-app-id',
|
|
41
|
+
* }}
|
|
42
|
+
* >
|
|
43
|
+
* <ThemeProvider>
|
|
44
|
+
* <App />
|
|
45
|
+
* </ThemeProvider>
|
|
46
|
+
* </FlowMetaProvider>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare const FlowMetaProvider: FC<PropsWithChildren<FlowMetaProviderProps>>;
|
|
50
|
+
export default FlowMetaProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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 { FlowMetaContextValue } from './FlowMetaContext';
|
|
19
|
+
declare const useFlowMeta: () => FlowMetaContextValue;
|
|
20
|
+
export default useFlowMeta;
|
|
@@ -30,6 +30,11 @@ export interface I18nContextValue {
|
|
|
30
30
|
* The fallback language code
|
|
31
31
|
*/
|
|
32
32
|
fallbackLanguage: string;
|
|
33
|
+
/**
|
|
34
|
+
* Injects additional bundles into the i18n system (e.g., from flow metadata).
|
|
35
|
+
* Injected bundles take precedence over defaults but are overridden by prop-provided bundles.
|
|
36
|
+
*/
|
|
37
|
+
injectBundles: (bundles: Record<string, I18nBundle>) => void;
|
|
33
38
|
/**
|
|
34
39
|
* Function to change the current language
|
|
35
40
|
*/
|
|
@@ -15,71 +15,68 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { BrowserThemeDetection, RecursivePartial, ThemeConfig, ThemeMode, ThemePreferences } from '@asgardeo/browser';
|
|
19
19
|
import { FC, PropsWithChildren } from 'react';
|
|
20
20
|
export interface ThemeProviderProps {
|
|
21
21
|
/**
|
|
22
|
-
* Configuration for theme detection when using 'class' or 'system' mode
|
|
22
|
+
* Configuration for theme detection when using 'class' or 'system' mode.
|
|
23
23
|
*/
|
|
24
24
|
detection?: BrowserThemeDetection;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Whether to inherit the theme from the Asgardeo branding preference.
|
|
27
|
+
* @default true
|
|
27
28
|
*/
|
|
28
29
|
inheritFromBranding?: ThemePreferences['inheritFromBranding'];
|
|
29
30
|
/**
|
|
30
|
-
* The theme mode to use for automatic detection
|
|
31
|
-
* - 'light'
|
|
32
|
-
* - '
|
|
33
|
-
* - '
|
|
34
|
-
* - '
|
|
35
|
-
* - 'branding': Use active theme from branding preference (requires inheritFromBranding=true)
|
|
31
|
+
* The theme mode to use for automatic detection.
|
|
32
|
+
* - `'light'` | `'dark'`: Fixed color scheme.
|
|
33
|
+
* - `'system'`: Follows the OS preference.
|
|
34
|
+
* - `'class'`: Detects theme from CSS classes on the `<html>` element.
|
|
35
|
+
* - `'branding'`: Follows the active theme from the branding preference.
|
|
36
36
|
*/
|
|
37
37
|
mode?: ThemeMode | 'branding';
|
|
38
|
+
/**
|
|
39
|
+
* Optional partial theme overrides applied on top of the resolved theme.
|
|
40
|
+
* User-supplied values always take the highest precedence.
|
|
41
|
+
*/
|
|
38
42
|
theme?: RecursivePartial<ThemeConfig>;
|
|
39
43
|
}
|
|
40
44
|
/**
|
|
41
|
-
* ThemeProvider
|
|
45
|
+
* ThemeProvider is the single entry-point for theme management in `@asgardeo/react`.
|
|
42
46
|
*
|
|
43
|
-
*
|
|
44
|
-
* organization-specific themes while allowing for custom theme overrides.
|
|
47
|
+
* It transparently switches between two internal implementations:
|
|
45
48
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
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
|
|
49
|
+
* **v1** (`ThemeProvider` classic): Sources colors from the Asgardeo Branding API.
|
|
50
|
+
* Used automatically when no `FlowMetaProvider` is present in the component tree.
|
|
52
51
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
52
|
+
* **v2** (`FlowMetaThemeProvider`): Sources colors from the `GET /flow/meta` endpoint
|
|
53
|
+
* via `FlowMetaProvider`. Used automatically when a `FlowMetaProvider` is present
|
|
54
|
+
* in the tree — or when `version="v2"` is set explicitly.
|
|
55
|
+
*
|
|
56
|
+
* The active version can also be pinned explicitly via the `version` prop.
|
|
57
|
+
* All components that consume `useTheme()` continue to work regardless of which
|
|
58
|
+
* version is active.
|
|
60
59
|
*
|
|
61
60
|
* @example
|
|
62
|
-
*
|
|
61
|
+
* Auto-detection (recommended):
|
|
63
62
|
* ```tsx
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
63
|
+
* // v2 mode – FlowMetaProvider is present
|
|
64
|
+
* <FlowMetaProvider config={{ baseUrl, type: FlowMetaType.App, id: appId }}>
|
|
65
|
+
* <ThemeProvider>
|
|
66
|
+
* <App />
|
|
67
|
+
* </ThemeProvider>
|
|
68
|
+
* </FlowMetaProvider>
|
|
69
|
+
*
|
|
70
|
+
* // v1 mode – no FlowMetaProvider
|
|
71
|
+
* <ThemeProvider>
|
|
72
72
|
* <App />
|
|
73
73
|
* </ThemeProvider>
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
76
|
* @example
|
|
77
|
-
*
|
|
77
|
+
* Explicit version pinning:
|
|
78
78
|
* ```tsx
|
|
79
|
-
* <ThemeProvider
|
|
80
|
-
* mode="branding"
|
|
81
|
-
* inheritFromBranding={true}
|
|
82
|
-
* >
|
|
79
|
+
* <ThemeProvider version="v2">
|
|
83
80
|
* <App />
|
|
84
81
|
* </ThemeProvider>
|
|
85
82
|
* ```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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 { ThemeConfig, ThemeMode, RecursivePartial, BrowserThemeDetection, ThemePreferences } from '@asgardeo/browser';
|
|
19
|
+
import { FC, PropsWithChildren } from 'react';
|
|
20
|
+
export interface ThemeProviderProps {
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for theme detection when using 'class' or 'system' mode
|
|
23
|
+
*/
|
|
24
|
+
detection?: BrowserThemeDetection;
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for branding integration
|
|
27
|
+
*/
|
|
28
|
+
inheritFromBranding?: ThemePreferences['inheritFromBranding'];
|
|
29
|
+
/**
|
|
30
|
+
* The theme mode to use for automatic detection
|
|
31
|
+
* - 'light': Always use light theme
|
|
32
|
+
* - 'dark': Always use dark theme
|
|
33
|
+
* - 'system': Use system preference (prefers-color-scheme media query)
|
|
34
|
+
* - 'class': Detect theme based on CSS classes on HTML element
|
|
35
|
+
* - 'branding': Use active theme from branding preference (requires inheritFromBranding=true)
|
|
36
|
+
*/
|
|
37
|
+
mode?: ThemeMode | 'branding';
|
|
38
|
+
theme?: RecursivePartial<ThemeConfig>;
|
|
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
|
+
*/
|
|
87
|
+
declare const ThemeProvider: FC<PropsWithChildren<ThemeProviderProps>>;
|
|
88
|
+
export default ThemeProvider;
|