@asgardeo/react 0.3.0 → 0.5.0
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/README.md +5 -1
- package/dist/AsgardeoReactClient.d.ts +12 -4
- package/dist/__temp__/api.d.ts +26 -21
- package/dist/__temp__/models.d.ts +14 -22
- package/dist/api/scim2/createOrganization.d.ts +74 -0
- package/dist/api/scim2/getAllOrganizations.d.ts +56 -0
- package/dist/api/scim2/getMeOrganizations.d.ts +52 -0
- package/dist/api/scim2/getOrganization.d.ts +61 -0
- package/dist/api/scim2/updateOrganization.d.ts +74 -0
- package/dist/cjs/index.js +9863 -1190
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +7 -6
- package/dist/components/actions/SignInButton/SignInButton.d.ts +21 -2
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +7 -6
- package/dist/components/actions/SignOutButton/SignOutButton.d.ts +22 -1
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +6 -5
- package/dist/components/actions/SignUpButton/SignUpButton.d.ts +21 -0
- package/dist/components/control/AsgardeoLoading.d.ts +45 -0
- package/dist/components/factories/FieldFactory.d.ts +107 -0
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +53 -0
- package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +67 -0
- package/dist/components/presentation/Organization/BaseOrganization.d.ts +66 -0
- package/dist/components/presentation/Organization/Organization.d.ts +66 -0
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +117 -0
- package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +93 -0
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +153 -0
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +119 -0
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +141 -0
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +70 -0
- package/dist/components/presentation/SignIn/BaseSignIn.d.ts +114 -0
- package/dist/components/presentation/SignIn/SignIn.d.ts +63 -0
- package/dist/components/presentation/SignIn/options/EmailOtp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/FacebookButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GitHubButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GoogleButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/IdentifierFirst.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/LinkedInButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/MicrosoftButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/MultiOptionButton.d.ts +26 -0
- package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +76 -0
- package/dist/components/presentation/SignIn/options/SignInWithEthereumButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/SmsOtp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/SocialButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/Totp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/UsernamePassword.d.ts +25 -0
- package/dist/components/presentation/SignIn/types.d.ts +124 -0
- package/dist/components/presentation/SignUp/BaseSignUp.d.ts +126 -0
- package/dist/components/presentation/SignUp/SignUp.d.ts +55 -0
- package/dist/components/presentation/SignUp/options/CheckboxInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/DateInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/DividerComponent.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/EmailInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/FormContainer.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/GoogleButton.d.ts +25 -0
- package/dist/components/presentation/SignUp/options/ImageComponent.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/NumberInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/PasswordInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/SignUpOptionFactory.d.ts +100 -0
- package/dist/components/presentation/SignUp/options/SocialButton.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/SubmitButton.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/TelephoneInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/TextInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/Typography.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/index.d.ts +26 -0
- package/dist/components/presentation/User/BaseUser.d.ts +66 -0
- package/dist/components/presentation/{User.d.ts → User/User.d.ts} +9 -4
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +34 -22
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +60 -4
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +34 -11
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
- package/dist/components/primitives/Alert/Alert.d.ts +74 -0
- package/dist/components/primitives/Avatar/Avatar.d.ts +21 -8
- package/dist/components/primitives/Button/Button.d.ts +83 -0
- package/dist/components/primitives/Card/Card.d.ts +132 -0
- package/dist/components/primitives/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/primitives/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/primitives/Divider/Divider.d.ts +58 -0
- package/dist/components/primitives/FormControl/FormControl.d.ts +50 -0
- package/dist/components/primitives/Icons/Building.d.ts +40 -0
- package/dist/components/primitives/Icons/BuildingAlt.d.ts +40 -0
- package/dist/components/primitives/Icons/Check.d.ts +40 -0
- package/dist/components/primitives/Icons/ChevronDown.d.ts +40 -0
- package/dist/components/primitives/Icons/CircleAlert.d.ts +23 -0
- package/dist/components/primitives/Icons/CircleCheck.d.ts +23 -0
- package/dist/components/primitives/Icons/Eye.d.ts +23 -0
- package/dist/components/primitives/Icons/EyeOff.d.ts +23 -0
- package/dist/components/primitives/Icons/Info.d.ts +23 -0
- package/dist/components/primitives/Icons/LogOut.d.ts +23 -0
- package/dist/components/primitives/Icons/Plus.d.ts +23 -0
- package/dist/components/primitives/Icons/Settings.d.ts +0 -0
- package/dist/components/primitives/Icons/TriangleAlert.d.ts +23 -0
- package/dist/components/primitives/Icons/User.d.ts +23 -0
- package/dist/components/primitives/Icons/X.d.ts +23 -0
- package/dist/components/primitives/Icons/index.d.ts +27 -0
- package/dist/components/primitives/InputLabel/InputLabel.d.ts +46 -0
- package/dist/components/primitives/KeyValueInput/KeyValueInput.d.ts +123 -0
- package/dist/components/primitives/KeyValueInput/index.d.ts +0 -0
- package/dist/components/primitives/OtpField/OtpField.d.ts +86 -0
- package/dist/components/primitives/PasswordField/PasswordField.d.ts +31 -0
- package/dist/components/primitives/Popover/Popover.d.ts +73 -36
- package/dist/components/primitives/Select/Select.d.ts +1 -1
- package/dist/components/primitives/Spinner/Spinner.d.ts +54 -0
- package/dist/components/primitives/TextField/TextField.d.ts +18 -2
- package/dist/components/primitives/Typography/Typography.d.ts +81 -0
- package/dist/contexts/{AsgardeoContext.d.ts → Asgardeo/AsgardeoContext.d.ts} +3 -1
- package/dist/{providers → contexts/Asgardeo}/AsgardeoProvider.d.ts +1 -1
- package/dist/{hooks → contexts/Asgardeo}/useAsgardeo.d.ts +1 -1
- package/dist/contexts/Flow/FlowContext.d.ts +73 -0
- package/dist/contexts/Flow/FlowProvider.d.ts +46 -0
- package/dist/contexts/Flow/useFlow.d.ts +48 -0
- package/dist/contexts/I18n/I18nContext.d.ts +42 -0
- package/dist/contexts/I18n/I18nProvider.d.ts +31 -0
- package/dist/contexts/I18n/useI18n.d.ts +27 -0
- package/dist/contexts/Organization/OrganizationContext.d.ts +74 -0
- package/dist/contexts/Organization/OrganizationProvider.d.ts +90 -0
- package/dist/contexts/Organization/useOrganization.d.ts +104 -0
- package/dist/{theme → contexts/Theme}/ThemeProvider.d.ts +2 -1
- package/dist/{theme → contexts/Theme}/types.d.ts +38 -9
- package/dist/{theme → contexts/Theme}/useTheme.d.ts +2 -1
- package/dist/contexts/User/UserContext.d.ts +33 -0
- package/dist/contexts/User/UserProvider.d.ts +56 -0
- package/dist/contexts/User/useUser.d.ts +94 -0
- package/dist/hooks/useForm.d.ts +192 -0
- package/dist/hooks/useTranslation.d.ts +52 -0
- package/dist/index.d.ts +133 -9
- package/dist/index.js +9949 -1203
- package/dist/index.js.map +4 -4
- package/dist/utils/getMappedUserProfileValue.d.ts +33 -1
- package/package.json +6 -5
- package/dist/utils/getUserProfile.d.ts +0 -59
- /package/dist/{theme → contexts/Theme}/ThemeContext.d.ts +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Types of authentication flows/steps that can be displayed.
|
|
20
|
+
*/
|
|
21
|
+
export type FlowStep = {
|
|
22
|
+
id: string;
|
|
23
|
+
type: 'signin' | 'signup' | 'organization-signin' | 'forgot-password' | 'reset-password' | 'verify-email' | 'mfa';
|
|
24
|
+
title: string;
|
|
25
|
+
subtitle?: string;
|
|
26
|
+
canGoBack?: boolean;
|
|
27
|
+
metadata?: Record<string, any>;
|
|
28
|
+
} | null;
|
|
29
|
+
/**
|
|
30
|
+
* Message types for displaying in authentication flows.
|
|
31
|
+
*/
|
|
32
|
+
export interface FlowMessage {
|
|
33
|
+
id?: string;
|
|
34
|
+
type: 'success' | 'error' | 'warning' | 'info';
|
|
35
|
+
message: string;
|
|
36
|
+
dismissible?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Context value for managing authentication flow UI state.
|
|
40
|
+
*/
|
|
41
|
+
export interface FlowContextValue {
|
|
42
|
+
currentStep: FlowStep;
|
|
43
|
+
setCurrentStep: (step: FlowStep) => void;
|
|
44
|
+
title: string;
|
|
45
|
+
setTitle: (title: string) => void;
|
|
46
|
+
subtitle?: string;
|
|
47
|
+
setSubtitle: (subtitle?: string) => void;
|
|
48
|
+
messages: FlowMessage[];
|
|
49
|
+
addMessage: (message: FlowMessage) => void;
|
|
50
|
+
removeMessage: (messageId: string) => void;
|
|
51
|
+
clearMessages: () => void;
|
|
52
|
+
error: string | null;
|
|
53
|
+
setError: (error: string | null) => void;
|
|
54
|
+
isLoading: boolean;
|
|
55
|
+
setIsLoading: (loading: boolean) => void;
|
|
56
|
+
showBackButton: boolean;
|
|
57
|
+
setShowBackButton: (show: boolean) => void;
|
|
58
|
+
onGoBack?: () => void;
|
|
59
|
+
setOnGoBack: (callback?: () => void) => void;
|
|
60
|
+
reset: () => void;
|
|
61
|
+
navigateToFlow: (flowType: NonNullable<FlowStep>['type'], options?: {
|
|
62
|
+
title?: string;
|
|
63
|
+
subtitle?: string;
|
|
64
|
+
metadata?: Record<string, any>;
|
|
65
|
+
}) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Context for managing authentication flow UI state.
|
|
69
|
+
* This context handles titles, messages, navigation, and loading states
|
|
70
|
+
* for authentication flows like SignIn, SignUp, organization signin, etc.
|
|
71
|
+
*/
|
|
72
|
+
declare const FlowContext: import("react").Context<FlowContextValue>;
|
|
73
|
+
export default FlowContext;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { FlowStep } from './FlowContext';
|
|
20
|
+
/**
|
|
21
|
+
* Props for the FlowProvider component.
|
|
22
|
+
*/
|
|
23
|
+
export interface FlowProviderProps {
|
|
24
|
+
/**
|
|
25
|
+
* Initial step to start with.
|
|
26
|
+
*/
|
|
27
|
+
initialStep?: FlowStep;
|
|
28
|
+
/**
|
|
29
|
+
* Initial title.
|
|
30
|
+
*/
|
|
31
|
+
initialTitle?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Initial subtitle.
|
|
34
|
+
*/
|
|
35
|
+
initialSubtitle?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Callback when flow type changes.
|
|
38
|
+
*/
|
|
39
|
+
onFlowChange?: (step: FlowStep) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Provider component for flow context.
|
|
43
|
+
* Manages shared UI state for authentication flows including titles, messages, and navigation.
|
|
44
|
+
*/
|
|
45
|
+
declare const FlowProvider: FC<PropsWithChildren<FlowProviderProps>>;
|
|
46
|
+
export default FlowProvider;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { FlowContextValue } from './FlowContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access the flow context.
|
|
21
|
+
* Must be used within a FlowProvider.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const MyAuthComponent = () => {
|
|
26
|
+
* const { title, setTitle, addMessage, isLoading } = useFlow();
|
|
27
|
+
*
|
|
28
|
+
* const handleSuccess = () => {
|
|
29
|
+
* addMessage({
|
|
30
|
+
* type: 'success',
|
|
31
|
+
* message: 'Authentication successful!'
|
|
32
|
+
* });
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* return (
|
|
36
|
+
* <div>
|
|
37
|
+
* <h1>{title}</h1>
|
|
38
|
+
* {isLoading && <p>Loading...</p>}
|
|
39
|
+
* </div>
|
|
40
|
+
* );
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @returns The flow context value
|
|
45
|
+
* @throws Error if used outside of FlowProvider
|
|
46
|
+
*/
|
|
47
|
+
declare const useFlow: () => FlowContextValue;
|
|
48
|
+
export default useFlow;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { I18nBundle } from '@asgardeo/browser';
|
|
19
|
+
export interface I18nContextValue {
|
|
20
|
+
/**
|
|
21
|
+
* The current language code (e.g., 'en-US', 'fr-FR')
|
|
22
|
+
*/
|
|
23
|
+
currentLanguage: string;
|
|
24
|
+
/**
|
|
25
|
+
* The fallback language code
|
|
26
|
+
*/
|
|
27
|
+
fallbackLanguage: string;
|
|
28
|
+
/**
|
|
29
|
+
* All available i18n bundles (default + user provided)
|
|
30
|
+
*/
|
|
31
|
+
bundles: Record<string, I18nBundle>;
|
|
32
|
+
/**
|
|
33
|
+
* Function to change the current language
|
|
34
|
+
*/
|
|
35
|
+
setLanguage: (language: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Function to get a translation by key with optional parameters
|
|
38
|
+
*/
|
|
39
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
40
|
+
}
|
|
41
|
+
declare const I18nContext: import("react").Context<I18nContextValue>;
|
|
42
|
+
export default I18nContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { I18nPreferences } from '@asgardeo/browser';
|
|
20
|
+
export interface I18nProviderProps {
|
|
21
|
+
/**
|
|
22
|
+
* The i18n preferences from the AsgardeoProvider
|
|
23
|
+
*/
|
|
24
|
+
preferences?: I18nPreferences;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* I18nProvider component that manages internationalization state and provides
|
|
28
|
+
* translation functions to child components.
|
|
29
|
+
*/
|
|
30
|
+
declare const I18nProvider: FC<PropsWithChildren<I18nProviderProps>>;
|
|
31
|
+
export default I18nProvider;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { I18nContextValue } from './I18nContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook for accessing the I18n context directly.
|
|
21
|
+
* Provides access to the full i18n context including bundles and all utilities.
|
|
22
|
+
*
|
|
23
|
+
* @returns The complete I18n context value
|
|
24
|
+
* @throws Error if used outside of I18nProvider context
|
|
25
|
+
*/
|
|
26
|
+
declare const useI18n: () => I18nContextValue;
|
|
27
|
+
export default useI18n;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { Organization } from '@asgardeo/browser';
|
|
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
|
+
/**
|
|
30
|
+
* Props interface of {@link OrganizationContext}
|
|
31
|
+
*/
|
|
32
|
+
export type OrganizationContextProps = {
|
|
33
|
+
currentOrganization: Organization | null;
|
|
34
|
+
error: string | null;
|
|
35
|
+
getOrganizations: () => Promise<Organization[]>;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
organizations: Organization[] | null;
|
|
38
|
+
revalidateOrganizations: () => Promise<void>;
|
|
39
|
+
switchOrganization: (organization: Organization) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Paginated organizations with switch access information
|
|
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>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Context object for managing organization data and related operations.
|
|
72
|
+
*/
|
|
73
|
+
declare const OrganizationContext: Context<OrganizationContextProps | null>;
|
|
74
|
+
export default OrganizationContext;
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { Organization } from '@asgardeo/browser';
|
|
19
|
+
import { FC, PropsWithChildren } from 'react';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface of {@link OrganizationProvider}
|
|
22
|
+
*/
|
|
23
|
+
export interface OrganizationProviderProps {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to automatically fetch organizations on mount
|
|
26
|
+
*/
|
|
27
|
+
autoFetch?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Initial current organization
|
|
30
|
+
*/
|
|
31
|
+
currentOrganization?: Organization | null;
|
|
32
|
+
/**
|
|
33
|
+
* Function to fetch organizations
|
|
34
|
+
*/
|
|
35
|
+
getOrganizations: () => Promise<Organization[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Callback function called when an error occurs
|
|
38
|
+
*/
|
|
39
|
+
onError?: (error: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Callback function called when switching organizations
|
|
42
|
+
*/
|
|
43
|
+
onOrganizationSwitch?: (organization: Organization) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Initial list of organizations
|
|
46
|
+
*/
|
|
47
|
+
organizations?: Organization[] | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* OrganizationProvider component that manages organization data and provides it through OrganizationContext.
|
|
51
|
+
*
|
|
52
|
+
* This provider:
|
|
53
|
+
* - Fetches organization data from the organizations endpoint
|
|
54
|
+
* - Manages current organization state
|
|
55
|
+
* - Provides functions for switching organizations and refreshing data
|
|
56
|
+
* - Handles loading states and errors
|
|
57
|
+
* - Accepts a custom getOrganizations function for flexible data fetching
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Basic usage with auto-fetch (uses internal API)
|
|
62
|
+
* <OrganizationProvider>
|
|
63
|
+
* <App />
|
|
64
|
+
* </OrganizationProvider>
|
|
65
|
+
*
|
|
66
|
+
* // With custom getOrganizations function
|
|
67
|
+
* <OrganizationProvider getOrganizations={async () => asgardeo.getOrganizations()}>
|
|
68
|
+
* <App />
|
|
69
|
+
* </OrganizationProvider>
|
|
70
|
+
*
|
|
71
|
+
* // With custom error handling
|
|
72
|
+
* <OrganizationProvider onError={(error) => console.error('Organization error:', error)}>
|
|
73
|
+
* <App />
|
|
74
|
+
* </OrganizationProvider>
|
|
75
|
+
*
|
|
76
|
+
* // With custom organization switch handler
|
|
77
|
+
* <OrganizationProvider
|
|
78
|
+
* onOrganizationSwitch={(org) => console.log('Switched to:', org.name)}
|
|
79
|
+
* >
|
|
80
|
+
* <App />
|
|
81
|
+
* </OrganizationProvider>
|
|
82
|
+
*
|
|
83
|
+
* // Disable auto-fetch (fetch manually using revalidateOrganizations)
|
|
84
|
+
* <OrganizationProvider autoFetch={false}>
|
|
85
|
+
* <App />
|
|
86
|
+
* </OrganizationProvider>
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare const OrganizationProvider: FC<PropsWithChildren<OrganizationProviderProps>>;
|
|
90
|
+
export default OrganizationProvider;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { OrganizationContextProps } from './OrganizationContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access the Organization context.
|
|
21
|
+
*
|
|
22
|
+
* This hook provides access to organization data including:
|
|
23
|
+
* - List of organizations the user belongs to
|
|
24
|
+
* - Current organization
|
|
25
|
+
* - Functions to switch organizations and refresh data
|
|
26
|
+
* - Function to fetch organizations programmatically
|
|
27
|
+
* - Loading states and error handling
|
|
28
|
+
*
|
|
29
|
+
* @returns {OrganizationContextProps} The organization context value containing all organization-related data and functions
|
|
30
|
+
* @throws {Error} Throws an error if used outside of OrganizationProvider
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* import {useOrganization} from '@asgardeo/react';
|
|
35
|
+
*
|
|
36
|
+
* function OrganizationSelector() {
|
|
37
|
+
* const {
|
|
38
|
+
* organizations,
|
|
39
|
+
* currentOrganization,
|
|
40
|
+
* switchOrganization,
|
|
41
|
+
* revalidateOrganizations,
|
|
42
|
+
* getOrganizations,
|
|
43
|
+
* isLoading,
|
|
44
|
+
* error
|
|
45
|
+
* } = useOrganization();
|
|
46
|
+
*
|
|
47
|
+
* if (isLoading) {
|
|
48
|
+
* return <div>Loading organizations...</div>;
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* if (error) {
|
|
52
|
+
* return <div>Error: {error}</div>;
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <div>
|
|
57
|
+
* <h2>Current: {currentOrganization?.name}</h2>
|
|
58
|
+
* <select
|
|
59
|
+
* value={currentOrganization?.id || ''}
|
|
60
|
+
* onChange={(e) => {
|
|
61
|
+
* const org = organizations?.find(o => o.id === e.target.value);
|
|
62
|
+
* if (org) switchOrganization(org);
|
|
63
|
+
* }}
|
|
64
|
+
* >
|
|
65
|
+
* {organizations?.map(org => (
|
|
66
|
+
* <option key={org.id} value={org.id}>
|
|
67
|
+
* {org.name}
|
|
68
|
+
* </option>
|
|
69
|
+
* ))}
|
|
70
|
+
* </select>
|
|
71
|
+
* <button onClick={revalidateOrganizations}>
|
|
72
|
+
* Refresh Organizations
|
|
73
|
+
* </button>
|
|
74
|
+
* <button onClick={async () => {
|
|
75
|
+
* const fresh = await getOrganizations();
|
|
76
|
+
* console.log('Fresh organizations:', fresh);
|
|
77
|
+
* }}>
|
|
78
|
+
* Get Organizations Manually
|
|
79
|
+
* </button>
|
|
80
|
+
* </div>
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* // Switch to a specific organization
|
|
85
|
+
* function SwitchOrgButton() {
|
|
86
|
+
* const {organizations, switchOrganization} = useOrganization();
|
|
87
|
+
*
|
|
88
|
+
* const handleSwitch = (orgId: string) => {
|
|
89
|
+
* const org = organizations?.find(o => o.id === orgId);
|
|
90
|
+
* if (org) {
|
|
91
|
+
* switchOrganization(org);
|
|
92
|
+
* }
|
|
93
|
+
* };
|
|
94
|
+
*
|
|
95
|
+
* return (
|
|
96
|
+
* <button onClick={() => handleSwitch('org-123')}>
|
|
97
|
+
* Switch to Organization
|
|
98
|
+
* </button>
|
|
99
|
+
* );
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare const useOrganization: () => OrganizationContextProps;
|
|
104
|
+
export default useOrganization;
|
|
@@ -21,4 +21,5 @@ export interface ThemeProviderProps {
|
|
|
21
21
|
theme?: RecursivePartial<ThemeConfig>;
|
|
22
22
|
defaultColorScheme?: 'light' | 'dark';
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
declare const ThemeProvider: FC<PropsWithChildren<ThemeProviderProps>>;
|
|
25
|
+
export default ThemeProvider;
|
|
@@ -16,24 +16,53 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
export interface ThemeColors {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
background: {
|
|
20
|
+
body: {
|
|
21
|
+
main: string;
|
|
22
|
+
};
|
|
23
|
+
disabled: string;
|
|
24
|
+
surface: string;
|
|
25
|
+
};
|
|
26
|
+
border: string;
|
|
27
|
+
error: {
|
|
28
|
+
contrastText: string;
|
|
29
|
+
main: string;
|
|
30
|
+
};
|
|
31
|
+
primary: {
|
|
32
|
+
contrastText: string;
|
|
33
|
+
main: string;
|
|
34
|
+
};
|
|
35
|
+
secondary: {
|
|
36
|
+
contrastText: string;
|
|
37
|
+
main: string;
|
|
38
|
+
};
|
|
39
|
+
success: {
|
|
40
|
+
contrastText: string;
|
|
41
|
+
main: string;
|
|
42
|
+
};
|
|
22
43
|
text: {
|
|
23
44
|
primary: string;
|
|
24
45
|
secondary: string;
|
|
25
46
|
};
|
|
26
|
-
|
|
47
|
+
warning: {
|
|
48
|
+
contrastText: string;
|
|
49
|
+
main: string;
|
|
50
|
+
};
|
|
27
51
|
}
|
|
28
52
|
export interface ThemeConfig {
|
|
29
|
-
colors: ThemeColors;
|
|
30
|
-
spacing: {
|
|
31
|
-
unit: number;
|
|
32
|
-
};
|
|
33
53
|
borderRadius: {
|
|
34
|
-
|
|
54
|
+
large: string;
|
|
35
55
|
medium: string;
|
|
56
|
+
small: string;
|
|
57
|
+
};
|
|
58
|
+
colors: ThemeColors;
|
|
59
|
+
shadows: {
|
|
36
60
|
large: string;
|
|
61
|
+
medium: string;
|
|
62
|
+
small: string;
|
|
63
|
+
};
|
|
64
|
+
spacing: {
|
|
65
|
+
unit: number;
|
|
37
66
|
};
|
|
38
67
|
}
|
|
39
68
|
export interface Theme extends ThemeConfig {
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { User, Schema } from '@asgardeo/browser';
|
|
19
|
+
import { Context } from 'react';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface of {@link UserContext}
|
|
22
|
+
*/
|
|
23
|
+
export type UserContextProps = {
|
|
24
|
+
flattenedProfile: User | null;
|
|
25
|
+
profile: User | null;
|
|
26
|
+
revalidateProfile: () => Promise<void>;
|
|
27
|
+
schemas: Schema[] | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Context object for managing user profile data and related operations.
|
|
31
|
+
*/
|
|
32
|
+
declare const UserContext: Context<UserContextProps | null>;
|
|
33
|
+
export default UserContext;
|