@asgardeo/react 0.13.2 → 0.13.3

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.
Files changed (22) hide show
  1. package/dist/cjs/index.js +828 -428
  2. package/dist/cjs/index.js.map +4 -4
  3. package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +7 -1
  4. package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.d.ts +79 -0
  5. package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.styles.d.ts +20 -0
  6. package/dist/components/presentation/LanguageSwitcher/LanguageSwitcher.d.ts +77 -0
  7. package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +7 -1
  8. package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +7 -1
  9. package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +7 -0
  10. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +7 -1
  11. package/dist/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.d.ts +7 -1
  12. package/dist/components/presentation/auth/InviteUser/v2/BaseInviteUser.d.ts +7 -1
  13. package/dist/components/presentation/auth/SignIn/SignIn.d.ts +5 -0
  14. package/dist/components/presentation/auth/SignIn/v2/BaseSignIn.d.ts +7 -1
  15. package/dist/components/presentation/auth/SignIn/v2/SignIn.d.ts +7 -1
  16. package/dist/components/presentation/auth/SignUp/v2/BaseSignUp.d.ts +7 -1
  17. package/dist/contexts/FlowMeta/FlowMetaContext.d.ts +5 -0
  18. package/dist/contexts/I18n/ComponentPreferencesContext.d.ts +26 -0
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.js +485 -69
  21. package/dist/index.js.map +4 -4
  22. package/package.json +3 -3
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { CreateOrganizationPayload } from '@asgardeo/browser';
18
+ import { CreateOrganizationPayload, Preferences } from '@asgardeo/browser';
19
19
  import { CSSProperties, FC, ReactNode } from 'react';
20
20
  /**
21
21
  * Interface for organization form data.
@@ -41,6 +41,12 @@ export interface BaseCreateOrganizationProps {
41
41
  onSubmit?: (payload: CreateOrganizationPayload) => void | Promise<void>;
42
42
  onSuccess?: (organization: any) => void;
43
43
  open?: boolean;
44
+ /**
45
+ * Component-level preferences to override global i18n and theme settings.
46
+ * Preferences are deep-merged with global ones, with component preferences
47
+ * taking precedence. Affects this component and all its descendants.
48
+ */
49
+ preferences?: Preferences;
44
50
  renderAdditionalFields?: () => ReactNode;
45
51
  style?: CSSProperties;
46
52
  title?: string;
@@ -0,0 +1,79 @@
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, ReactNode } from 'react';
19
+ /**
20
+ * A resolved language option with display name and emoji flag.
21
+ */
22
+ export interface LanguageOption {
23
+ /** BCP 47 language tag (e.g. "en", "fr", "en-US") */
24
+ code: string;
25
+ /** Human-readable display name resolved via Intl.DisplayNames */
26
+ displayName: string;
27
+ /** Flag emoji or globe emoji for the language */
28
+ emoji: string;
29
+ }
30
+ /**
31
+ * Render props exposed to consumers when using the render-prop pattern.
32
+ */
33
+ export interface LanguageSwitcherRenderProps {
34
+ /** The currently active language code */
35
+ currentLanguage: string;
36
+ /** Whether a language switch is in progress */
37
+ isLoading: boolean;
38
+ /** Resolved language options */
39
+ languages: LanguageOption[];
40
+ /** Call this to switch to a different language */
41
+ onLanguageChange: (language: string) => void;
42
+ }
43
+ export interface BaseLanguageSwitcherProps {
44
+ /**
45
+ * Render-props callback. When provided, the default dropdown UI is replaced with
46
+ * whatever JSX the callback returns.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <BaseLanguageSwitcher {...props}>
51
+ * {({languages, currentLanguage, onLanguageChange}) => (
52
+ * <select value={currentLanguage} onChange={e => onLanguageChange(e.target.value)}>
53
+ * {languages.map(l => <option key={l.code} value={l.code}>{l.emoji} {l.displayName}</option>)}
54
+ * </select>
55
+ * )}
56
+ * </BaseLanguageSwitcher>
57
+ * ```
58
+ */
59
+ children?: (props: LanguageSwitcherRenderProps) => ReactNode;
60
+ /** Additional CSS class applied to the root element (default UI only) */
61
+ className?: string;
62
+ /** The currently active language code */
63
+ currentLanguage: string;
64
+ /** Whether a language switch is in progress */
65
+ isLoading?: boolean;
66
+ /** Resolved language options to display */
67
+ languages: LanguageOption[];
68
+ /** Called when the user selects a language */
69
+ onLanguageChange: (language: string) => void;
70
+ }
71
+ /**
72
+ * Pure-UI language switcher dropdown.
73
+ * Accepts resolved `LanguageOption[]` (code + displayName + emoji) and delegates
74
+ * language switching to the `onLanguageChange` callback.
75
+ *
76
+ * Supports render props for full UI customisation.
77
+ */
78
+ declare const BaseLanguageSwitcher: FC<BaseLanguageSwitcherProps>;
79
+ export default BaseLanguageSwitcher;
@@ -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 { Theme } from '@asgardeo/browser';
19
+ declare const useStyles: (theme: Theme, colorScheme: string) => Record<string, string>;
20
+ export default useStyles;
@@ -0,0 +1,77 @@
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, ReactNode } from 'react';
19
+ import { LanguageOption, LanguageSwitcherRenderProps } from './BaseLanguageSwitcher';
20
+ export type { LanguageOption, LanguageSwitcherRenderProps };
21
+ export interface LanguageSwitcherProps {
22
+ /**
23
+ * Render-props callback for fully custom UI.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <LanguageSwitcher>
28
+ * {({languages, currentLanguage, onLanguageChange, isLoading}) => (
29
+ * <select
30
+ * value={currentLanguage}
31
+ * disabled={isLoading}
32
+ * onChange={e => onLanguageChange(e.target.value)}
33
+ * >
34
+ * {languages.map(l => (
35
+ * <option key={l.code} value={l.code}>{l.emoji} {l.displayName}</option>
36
+ * ))}
37
+ * </select>
38
+ * )}
39
+ * </LanguageSwitcher>
40
+ * ```
41
+ */
42
+ children?: (props: LanguageSwitcherRenderProps) => ReactNode;
43
+ /** Additional CSS class for the root element (default UI only) */
44
+ className?: string;
45
+ }
46
+ /**
47
+ * A v2 LanguageSwitcher component that reads available languages from `FlowMetaContext`
48
+ * and switches both the UI language (via `I18nContext`) and the flow metadata translations
49
+ * (by re-fetching `GET /flow/meta` with the new language).
50
+ *
51
+ * Must be rendered inside a `FlowMetaProvider`.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * // Default dropdown UI
56
+ * <LanguageSwitcher />
57
+ *
58
+ * // Custom UI with render props
59
+ * <LanguageSwitcher>
60
+ * {({languages, currentLanguage, onLanguageChange}) => (
61
+ * <div>
62
+ * {languages.map(lang => (
63
+ * <button
64
+ * key={lang.code}
65
+ * onClick={() => onLanguageChange(lang.code)}
66
+ * style={{fontWeight: lang.code === currentLanguage ? 'bold' : 'normal'}}
67
+ * >
68
+ * {lang.emoji} {lang.displayName}
69
+ * </button>
70
+ * ))}
71
+ * </div>
72
+ * )}
73
+ * </LanguageSwitcher>
74
+ * ```
75
+ */
76
+ declare const LanguageSwitcher: FC<LanguageSwitcherProps>;
77
+ export default LanguageSwitcher;
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AllOrganizationsApiResponse, Organization } from '@asgardeo/browser';
18
+ import { AllOrganizationsApiResponse, Organization, Preferences } from '@asgardeo/browser';
19
19
  import { CSSProperties, FC, ReactNode } from 'react';
20
20
  export interface OrganizationWithSwitchAccess extends Organization {
21
21
  canSwitch: boolean;
@@ -76,6 +76,12 @@ export interface BaseOrganizationListProps {
76
76
  * Whether the popup is open (only used in popup mode)
77
77
  */
78
78
  open?: boolean;
79
+ /**
80
+ * Component-level preferences to override global i18n and theme settings.
81
+ * Preferences are deep-merged with global ones, with component preferences
82
+ * taking precedence. Affects this component and all its descendants.
83
+ */
84
+ preferences?: Preferences;
79
85
  /**
80
86
  * Custom renderer for when no organizations are found
81
87
  */
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { OrganizationDetails } from '@asgardeo/browser';
18
+ import { OrganizationDetails, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactElement, ReactNode } from 'react';
20
20
  export interface BaseOrganizationProfileProps {
21
21
  /**
@@ -75,6 +75,12 @@ export interface BaseOrganizationProfileProps {
75
75
  * The organization details to display.
76
76
  */
77
77
  organization?: OrganizationDetails | null;
78
+ /**
79
+ * Component-level preferences to override global i18n and theme settings.
80
+ * Preferences are deep-merged with global ones, with component preferences
81
+ * taking precedence. Affects this component and all its descendants.
82
+ */
83
+ preferences?: Preferences;
78
84
  /**
79
85
  * Text for the save button (only used in editable mode).
80
86
  */
@@ -15,6 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
+ import { Preferences } from '@asgardeo/browser';
18
19
  import { CSSProperties, FC, ReactElement, ReactNode } from 'react';
19
20
  interface MenuItem {
20
21
  href?: string;
@@ -103,6 +104,12 @@ export interface BaseOrganizationSwitcherProps {
103
104
  * The HTML element ID where the portal should be mounted
104
105
  */
105
106
  portalId?: string;
107
+ /**
108
+ * Component-level preferences to override global i18n and theme settings.
109
+ * Preferences are deep-merged with global ones, with component preferences
110
+ * taking precedence. Affects this component and all its descendants.
111
+ */
112
+ preferences?: Preferences;
106
113
  /**
107
114
  * Custom render function for the error state.
108
115
  */
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { User } from '@asgardeo/browser';
18
+ import { User, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactElement } from 'react';
20
20
  interface ExtendedFlatSchema {
21
21
  path?: string;
@@ -57,6 +57,12 @@ export interface BaseUserProfileProps {
57
57
  onOpenChange?: (open: boolean) => void;
58
58
  onUpdate?: (payload: any) => Promise<void>;
59
59
  open?: boolean;
60
+ /**
61
+ * Component-level preferences to override global i18n and theme settings.
62
+ * Preferences are deep-merged with global ones, with component preferences
63
+ * taking precedence. Affects this component and all its descendants.
64
+ */
65
+ preferences?: Preferences;
60
66
  profile?: User;
61
67
  schemas?: Schema[];
62
68
  showFields?: string[];
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FlowMetadataResponse } from '@asgardeo/browser';
18
+ import { FlowMetadataResponse, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  import { CardProps } from '../../../../primitives/Card/Card';
21
21
  /**
@@ -162,6 +162,12 @@ export interface BaseAcceptInviteProps {
162
162
  * This makes a request to the flow/execute endpoint.
163
163
  */
164
164
  onSubmit: (payload: Record<string, any>) => Promise<AcceptInviteFlowResponse>;
165
+ /**
166
+ * Component-level preferences to override global i18n and theme settings.
167
+ * Preferences are deep-merged with global ones, with component preferences
168
+ * taking precedence. Affects this component and all its descendants.
169
+ */
170
+ preferences?: Preferences;
165
171
  /**
166
172
  * Whether to show the subtitle.
167
173
  */
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FlowMetadataResponse } from '@asgardeo/browser';
18
+ import { FlowMetadataResponse, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  import { CardProps } from '../../../../primitives/Card/Card';
21
21
  /**
@@ -154,6 +154,12 @@ export interface BaseInviteUserProps {
154
154
  * This should make an authenticated request to the flow/execute endpoint.
155
155
  */
156
156
  onSubmit: (payload: Record<string, any>) => Promise<InviteUserFlowResponse>;
157
+ /**
158
+ * Component-level preferences to override global i18n and theme settings.
159
+ * Preferences are deep-merged with global ones, with component preferences
160
+ * taking precedence. Affects this component and all its descendants.
161
+ */
162
+ preferences?: Preferences;
157
163
  /**
158
164
  * Whether to show the subtitle.
159
165
  */
@@ -15,6 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
+ import { Preferences } from '@asgardeo/browser';
18
19
  import { FC, ReactElement } from 'react';
19
20
  import { BaseSignInProps } from './BaseSignIn';
20
21
  import { SignInRenderProps } from './v2/SignIn';
@@ -27,6 +28,10 @@ export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onE
27
28
  * Render function for custom UI (render props pattern).
28
29
  */
29
30
  children?: (props: SignInRenderProps) => ReactElement;
31
+ /**
32
+ * Component-level preferences to override global i18n and theme settings.
33
+ */
34
+ preferences?: Preferences;
30
35
  };
31
36
  /**
32
37
  * A styled SignIn component that provides native authentication flow with pre-built styling.
@@ -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, FlowMetadataResponse } from '@asgardeo/browser';
18
+ import { EmbeddedSignInFlowRequestV2 as EmbeddedSignInFlowRequest, EmbeddedFlowComponentV2 as EmbeddedFlowComponent, FlowMetadataResponse, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  import { CardProps } from '../../../../primitives/Card/Card';
21
21
  /**
@@ -141,6 +141,12 @@ export interface BaseSignInProps {
141
141
  * @param authData - The authentication data returned upon successful completion.
142
142
  */
143
143
  onSuccess?: (authData: Record<string, any>) => void;
144
+ /**
145
+ * Component-level preferences to override global i18n and theme settings.
146
+ * Preferences are deep-merged with global ones, with component preferences
147
+ * taking precedence. Affects this component and all its descendants.
148
+ */
149
+ preferences?: Preferences;
144
150
  /**
145
151
  * Whether to show the logo.
146
152
  */
@@ -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, FlowMetadataResponse } from '@asgardeo/browser';
18
+ import { EmbeddedFlowComponentV2 as EmbeddedFlowComponent, EmbeddedSignInFlowRequestV2, FlowMetadataResponse, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  import { BaseSignInProps } from './BaseSignIn';
21
21
  /**
@@ -74,6 +74,12 @@ export type SignInProps = {
74
74
  * @param authData - The authentication data returned upon successful completion.
75
75
  */
76
76
  onSuccess?: (authData: Record<string, any>) => void;
77
+ /**
78
+ * Component-level preferences to override global i18n and theme settings.
79
+ * Preferences are deep-merged with global ones, with component preferences
80
+ * taking precedence. Affects this component and all its descendants.
81
+ */
82
+ preferences?: Preferences;
77
83
  /**
78
84
  * Size variant for the component.
79
85
  */
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from '@asgardeo/browser';
18
+ import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse, Preferences } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  import { CardProps } from '../../../../primitives/Card/Card';
21
21
  /**
@@ -145,6 +145,12 @@ export interface BaseSignUpProps {
145
145
  * @returns Promise resolving to the sign-up response.
146
146
  */
147
147
  onSubmit?: (payload: EmbeddedFlowExecuteRequestPayload) => Promise<EmbeddedFlowExecuteResponse>;
148
+ /**
149
+ * Component-level preferences to override global i18n and theme settings.
150
+ * Preferences are deep-merged with global ones, with component preferences
151
+ * taking precedence. Affects this component and all its descendants.
152
+ */
153
+ preferences?: Preferences;
148
154
  /**
149
155
  * Whether to redirect after sign-up.
150
156
  */
@@ -34,6 +34,11 @@ export interface FlowMetaContextValue {
34
34
  * The fetched flow metadata response, or null while loading / on error
35
35
  */
36
36
  meta: FlowMetadataResponse | null;
37
+ /**
38
+ * Fetches flow metadata for the given language and activates it in the i18n system.
39
+ * Use this to switch the UI language at runtime.
40
+ */
41
+ switchLanguage: (language: string) => Promise<void>;
37
42
  }
38
43
  declare const FlowMetaContext: Context<FlowMetaContextValue | null>;
39
44
  export default FlowMetaContext;
@@ -0,0 +1,26 @@
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 { Preferences } from '@asgardeo/browser';
19
+ import { Context } from 'react';
20
+ /**
21
+ * Context for component-level preferences overrides.
22
+ * Presentational components can provide this context to override the global i18n
23
+ * and theme settings for their entire subtree, including all nested components.
24
+ */
25
+ declare const ComponentPreferencesContext: Context<Preferences | undefined>;
26
+ export default ComponentPreferencesContext;
package/dist/index.d.ts CHANGED
@@ -127,6 +127,10 @@ export * from './components/presentation/OrganizationProfile/OrganizationProfile
127
127
  export { BaseCreateOrganization } from './components/presentation/CreateOrganization/BaseCreateOrganization';
128
128
  export type { BaseCreateOrganizationProps, OrganizationFormData, } from './components/presentation/CreateOrganization/BaseCreateOrganization';
129
129
  export { CreateOrganization } from './components/presentation/CreateOrganization/CreateOrganization';
130
+ export { default as BaseLanguageSwitcher } from './components/presentation/LanguageSwitcher/BaseLanguageSwitcher';
131
+ export type { BaseLanguageSwitcherProps, LanguageOption, LanguageSwitcherRenderProps, } from './components/presentation/LanguageSwitcher/BaseLanguageSwitcher';
132
+ export { default as LanguageSwitcher } from './components/presentation/LanguageSwitcher/LanguageSwitcher';
133
+ export type { LanguageSwitcherProps } from './components/presentation/LanguageSwitcher/LanguageSwitcher';
130
134
  export { default as Button } from './components/primitives/Button/Button';
131
135
  export * from './components/primitives/Button/Button';
132
136
  export { default as Card } from './components/primitives/Card/Card';