@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,56 @@
|
|
|
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 { UserProfile } from '@asgardeo/browser';
|
|
19
|
+
import { FC, PropsWithChildren } from 'react';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface of {@link UserProvider}
|
|
22
|
+
*/
|
|
23
|
+
export interface UserProviderProps {
|
|
24
|
+
profile: UserProfile;
|
|
25
|
+
revalidateProfile?: () => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* UserProvider component that manages user profile data and provides it through UserContext.
|
|
29
|
+
*
|
|
30
|
+
* This provider:
|
|
31
|
+
* - Fetches user profile data from the ME endpoint
|
|
32
|
+
* - Retrieves SCIM2 schemas for profile structure
|
|
33
|
+
* - Generates both nested and flattened user profiles
|
|
34
|
+
* - Provides functions for refreshing and updating user data
|
|
35
|
+
* - Handles loading states and errors
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Basic usage
|
|
40
|
+
* <UserProvider>
|
|
41
|
+
* <App />
|
|
42
|
+
* </UserProvider>
|
|
43
|
+
*
|
|
44
|
+
* // With custom error handling
|
|
45
|
+
* <UserProvider onError={(error) => console.error('User error:', error)}>
|
|
46
|
+
* <App />
|
|
47
|
+
* </UserProvider>
|
|
48
|
+
*
|
|
49
|
+
* // Disable auto-fetch (fetch manually using refreshUser)
|
|
50
|
+
* <UserProvider autoFetch={false}>
|
|
51
|
+
* <App />
|
|
52
|
+
* </UserProvider>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare const UserProvider: FC<PropsWithChildren<UserProviderProps>>;
|
|
56
|
+
export default UserProvider;
|
|
@@ -0,0 +1,94 @@
|
|
|
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 { UserContextProps } from './UserContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access the User context.
|
|
21
|
+
*
|
|
22
|
+
* This hook provides access to user profile data including:
|
|
23
|
+
* - Raw profile API response
|
|
24
|
+
* - SCIM2 schemas
|
|
25
|
+
* - Nested user object
|
|
26
|
+
* - Flattened user profile
|
|
27
|
+
* - Functions to refresh and update user data
|
|
28
|
+
* - Loading states and error handling
|
|
29
|
+
*
|
|
30
|
+
* @returns {UserContextProps} The user context value containing all user-related data and functions
|
|
31
|
+
* @throws {Error} Throws an error if used outside of UserProvider
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import {useUser} from '@asgardeo/react';
|
|
36
|
+
*
|
|
37
|
+
* function ProfileComponent() {
|
|
38
|
+
* const {
|
|
39
|
+
* isLoading,
|
|
40
|
+
* profile,
|
|
41
|
+
* schemas,
|
|
42
|
+
* user,
|
|
43
|
+
* flattenedUser,
|
|
44
|
+
* refreshUser,
|
|
45
|
+
* updateUser,
|
|
46
|
+
* error
|
|
47
|
+
* } = useUser();
|
|
48
|
+
*
|
|
49
|
+
* if (isLoading) {
|
|
50
|
+
* return <div>Loading user data...</div>;
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* if (error) {
|
|
54
|
+
* return <div>Error: {error.message}</div>;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* return (
|
|
58
|
+
* <div>
|
|
59
|
+
* <h1>Welcome {user?.name?.givenName}!</h1>
|
|
60
|
+
* <p>Email: {flattenedUser?.emails}</p>
|
|
61
|
+
* <button onClick={refreshUser}>Refresh Profile</button>
|
|
62
|
+
* </div>
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Access specific user properties
|
|
67
|
+
* function UserEmail() {
|
|
68
|
+
* const {flattenedUser} = useUser();
|
|
69
|
+
* return <span>{flattenedUser?.emails?.[0]}</span>;
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* // Update user profile
|
|
73
|
+
* function EditProfile() {
|
|
74
|
+
* const {updateUser, user} = useUser();
|
|
75
|
+
*
|
|
76
|
+
* const handleUpdate = async () => {
|
|
77
|
+
* try {
|
|
78
|
+
* await updateUser({
|
|
79
|
+
* name: {
|
|
80
|
+
* givenName: 'John',
|
|
81
|
+
* familyName: 'Doe'
|
|
82
|
+
* }
|
|
83
|
+
* });
|
|
84
|
+
* } catch (error) {
|
|
85
|
+
* console.error('Update failed:', error);
|
|
86
|
+
* }
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* return <button onClick={handleUpdate}>Update Name</button>;
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare const useUser: () => UserContextProps;
|
|
94
|
+
export default useUser;
|
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
* Generic form field configuration
|
|
20
|
+
*/
|
|
21
|
+
export interface FormField {
|
|
22
|
+
initialValue?: string;
|
|
23
|
+
name: string;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
validator?: (value: string) => string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Form validation result
|
|
29
|
+
*/
|
|
30
|
+
export interface ValidationResult {
|
|
31
|
+
errors: Record<string, string>;
|
|
32
|
+
isValid: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the useForm hook
|
|
36
|
+
*/
|
|
37
|
+
export interface UseFormConfig<T extends Record<string, string>> {
|
|
38
|
+
/**
|
|
39
|
+
* Form field definitions
|
|
40
|
+
*/
|
|
41
|
+
fields?: FormField[];
|
|
42
|
+
/**
|
|
43
|
+
* Initial form values
|
|
44
|
+
*/
|
|
45
|
+
initialValues?: Partial<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Custom required field validation message
|
|
48
|
+
*/
|
|
49
|
+
requiredMessage?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to validate on blur (default: true)
|
|
52
|
+
*/
|
|
53
|
+
validateOnBlur?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to validate on change (default: false)
|
|
56
|
+
*/
|
|
57
|
+
validateOnChange?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Global form validator function
|
|
60
|
+
*/
|
|
61
|
+
validator?: (values: T) => Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Return type for the useForm hook
|
|
65
|
+
*/
|
|
66
|
+
export interface UseFormReturn<T extends Record<string, string>> {
|
|
67
|
+
/**
|
|
68
|
+
* Clear all errors
|
|
69
|
+
*/
|
|
70
|
+
clearErrors: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Current validation errors
|
|
73
|
+
*/
|
|
74
|
+
errors: Record<keyof T, string>;
|
|
75
|
+
/**
|
|
76
|
+
* Get field props for easy integration with form components
|
|
77
|
+
*/
|
|
78
|
+
getFieldProps: (name: keyof T) => {
|
|
79
|
+
error: string | undefined;
|
|
80
|
+
name: keyof T;
|
|
81
|
+
onBlur: () => void;
|
|
82
|
+
onChange: (value: string) => void;
|
|
83
|
+
required: boolean;
|
|
84
|
+
touched: boolean;
|
|
85
|
+
value: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Handle form submission
|
|
89
|
+
*/
|
|
90
|
+
handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (e?: React.FormEvent) => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the form has been submitted
|
|
93
|
+
*/
|
|
94
|
+
isSubmitted: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Whether the form is currently valid
|
|
97
|
+
*/
|
|
98
|
+
isValid: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Reset the form to initial values
|
|
101
|
+
*/
|
|
102
|
+
reset: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Set a field error
|
|
105
|
+
*/
|
|
106
|
+
setError: (name: keyof T, error: string) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Set multiple field errors
|
|
109
|
+
*/
|
|
110
|
+
setErrors: (errors: Partial<Record<keyof T, string>>) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Mark a field as touched
|
|
113
|
+
*/
|
|
114
|
+
setTouched: (name: keyof T, touched?: boolean) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Mark multiple fields as touched
|
|
117
|
+
*/
|
|
118
|
+
setTouchedFields: (touched: Partial<Record<keyof T, boolean>>) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Set a single field value
|
|
121
|
+
*/
|
|
122
|
+
setValue: (name: keyof T, value: string) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Set multiple field values
|
|
125
|
+
*/
|
|
126
|
+
setValues: (values: Partial<T>) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Mark all fields as touched
|
|
129
|
+
*/
|
|
130
|
+
touchAllFields: () => void;
|
|
131
|
+
/**
|
|
132
|
+
* Validate all fields
|
|
133
|
+
*/
|
|
134
|
+
validateForm: () => ValidationResult;
|
|
135
|
+
/**
|
|
136
|
+
* Current form values
|
|
137
|
+
*/
|
|
138
|
+
values: T;
|
|
139
|
+
/**
|
|
140
|
+
* Validate a single field
|
|
141
|
+
*/
|
|
142
|
+
validateField: (name: keyof T) => string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Fields that have been touched by the user
|
|
145
|
+
*/
|
|
146
|
+
touched: Record<keyof T, boolean>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Generic form hook that provides comprehensive form state management and validation.
|
|
150
|
+
*
|
|
151
|
+
* @template T - The type of form values (must extend Record<string, string>)
|
|
152
|
+
* @param config - Configuration options for the form
|
|
153
|
+
* @returns Form state and methods
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* interface LoginForm {
|
|
158
|
+
* username: string;
|
|
159
|
+
* password: string;
|
|
160
|
+
* }
|
|
161
|
+
*
|
|
162
|
+
* const {
|
|
163
|
+
* values,
|
|
164
|
+
* touched,
|
|
165
|
+
* errors,
|
|
166
|
+
* isValid,
|
|
167
|
+
* setValue,
|
|
168
|
+
* handleSubmit,
|
|
169
|
+
* getFieldProps
|
|
170
|
+
* } = useForm<LoginForm>({
|
|
171
|
+
* initialValues: { username: '', password: '' },
|
|
172
|
+
* fields: [
|
|
173
|
+
* { name: 'username', required: true },
|
|
174
|
+
* { name: 'password', required: true }
|
|
175
|
+
* ]
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* const onSubmit = handleSubmit((values) => {
|
|
179
|
+
* console.log('Form submitted:', values);
|
|
180
|
+
* });
|
|
181
|
+
*
|
|
182
|
+
* return (
|
|
183
|
+
* <form onSubmit={onSubmit}>
|
|
184
|
+
* <input {...getFieldProps('username')} />
|
|
185
|
+
* <input {...getFieldProps('password')} type="password" />
|
|
186
|
+
* <button type="submit" disabled={!isValid}>Submit</button>
|
|
187
|
+
* </form>
|
|
188
|
+
* );
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare const useForm: <T extends Record<string, string>>(config?: UseFormConfig<T>) => UseFormReturn<T>;
|
|
192
|
+
export default useForm;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { I18nPreferences } from '@asgardeo/browser';
|
|
19
|
+
export interface UseTranslation {
|
|
20
|
+
/**
|
|
21
|
+
* Translation function that returns a translated string for the given key
|
|
22
|
+
*/
|
|
23
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The current language code
|
|
26
|
+
*/
|
|
27
|
+
currentLanguage: string;
|
|
28
|
+
/**
|
|
29
|
+
* Function to change the current language
|
|
30
|
+
*/
|
|
31
|
+
setLanguage: (language: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* All available language codes
|
|
34
|
+
*/
|
|
35
|
+
availableLanguages: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface UseTranslationWithPreferences extends UseTranslation {
|
|
38
|
+
/**
|
|
39
|
+
* Enhanced translation function that merges component-level preferences
|
|
40
|
+
*/
|
|
41
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook for accessing translation functions and language management.
|
|
45
|
+
* Must be used within an I18nProvider context.
|
|
46
|
+
*
|
|
47
|
+
* @param componentPreferences - Optional component-level i18n preferences to merge with global ones
|
|
48
|
+
* @returns An object containing translation function and language management utilities
|
|
49
|
+
* @throws Error if used outside of I18nProvider context
|
|
50
|
+
*/
|
|
51
|
+
declare const useTranslation: (componentPreferences?: I18nPreferences) => UseTranslationWithPreferences;
|
|
52
|
+
export default useTranslation;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,14 +15,48 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
export { default as AsgardeoProvider } from './
|
|
19
|
-
export * from './
|
|
20
|
-
export { default as AsgardeoContext } from './contexts/AsgardeoContext';
|
|
21
|
-
export * from './contexts/AsgardeoContext';
|
|
22
|
-
export { default as useAsgardeo } from './
|
|
23
|
-
export * from './
|
|
18
|
+
export { default as AsgardeoProvider } from './contexts/Asgardeo/AsgardeoProvider';
|
|
19
|
+
export * from './contexts/Asgardeo/AsgardeoProvider';
|
|
20
|
+
export { default as AsgardeoContext } from './contexts/Asgardeo/AsgardeoContext';
|
|
21
|
+
export * from './contexts/Asgardeo/AsgardeoContext';
|
|
22
|
+
export { default as useAsgardeo } from './contexts/Asgardeo/useAsgardeo';
|
|
23
|
+
export * from './contexts/Asgardeo/useAsgardeo';
|
|
24
|
+
export { default as UserContext } from './contexts/User/UserContext';
|
|
25
|
+
export * from './contexts/User/UserContext';
|
|
26
|
+
export { default as UserProvider } from './contexts/User/UserProvider';
|
|
27
|
+
export * from './contexts/User/UserProvider';
|
|
28
|
+
export { default as useUser } from './contexts/User/useUser';
|
|
29
|
+
export * from './contexts/User/useUser';
|
|
30
|
+
export { default as OrganizationContext } from './contexts/Organization/OrganizationContext';
|
|
31
|
+
export * from './contexts/Organization/OrganizationContext';
|
|
32
|
+
export { default as OrganizationProvider } from './contexts/Organization/OrganizationProvider';
|
|
33
|
+
export * from './contexts/Organization/OrganizationProvider';
|
|
34
|
+
export { default as useOrganization } from './contexts/Organization/useOrganization';
|
|
35
|
+
export * from './contexts/Organization/useOrganization';
|
|
36
|
+
export { default as FlowContext } from './contexts/Flow/FlowContext';
|
|
37
|
+
export * from './contexts/Flow/FlowContext';
|
|
38
|
+
export { default as FlowProvider } from './contexts/Flow/FlowProvider';
|
|
39
|
+
export * from './contexts/Flow/FlowProvider';
|
|
40
|
+
export { default as useFlow } from './contexts/Flow/useFlow';
|
|
41
|
+
export * from './contexts/Flow/useFlow';
|
|
42
|
+
export { default as I18nContext } from './contexts/I18n/I18nContext';
|
|
43
|
+
export * from './contexts/I18n/I18nContext';
|
|
44
|
+
export { default as I18nProvider } from './contexts/I18n/I18nProvider';
|
|
45
|
+
export * from './contexts/I18n/I18nProvider';
|
|
46
|
+
export { default as useI18n } from './contexts/I18n/useI18n';
|
|
47
|
+
export * from './contexts/I18n/useI18n';
|
|
48
|
+
export { default as ThemeContext } from './contexts/Theme/ThemeContext';
|
|
49
|
+
export * from './contexts/Theme/ThemeContext';
|
|
50
|
+
export { default as ThemeProvider } from './contexts/Theme/ThemeProvider';
|
|
51
|
+
export * from './contexts/Theme/ThemeProvider';
|
|
52
|
+
export { default as useTheme } from './contexts/Theme/useTheme';
|
|
53
|
+
export * from './contexts/Theme/useTheme';
|
|
24
54
|
export { default as useBrowserUrl } from './hooks/useBrowserUrl';
|
|
25
55
|
export * from './hooks/useBrowserUrl';
|
|
56
|
+
export { default as useTranslation } from './hooks/useTranslation';
|
|
57
|
+
export * from './hooks/useTranslation';
|
|
58
|
+
export { default as useForm } from './hooks/useForm';
|
|
59
|
+
export * from './hooks/useForm';
|
|
26
60
|
export { default as BaseSignInButton } from './components/actions/SignInButton/BaseSignInButton';
|
|
27
61
|
export * from './components/actions/SignInButton/BaseSignInButton';
|
|
28
62
|
export { default as SignInButton } from './components/actions/SignInButton/SignInButton';
|
|
@@ -39,8 +73,38 @@ export { default as SignedIn } from './components/control/SignedIn';
|
|
|
39
73
|
export * from './components/control/SignedIn';
|
|
40
74
|
export { default as SignedOut } from './components/control/SignedOut';
|
|
41
75
|
export * from './components/control/SignedOut';
|
|
42
|
-
export { default as
|
|
43
|
-
export * from './components/
|
|
76
|
+
export { default as AsgardeoLoading } from './components/control/AsgardeoLoading';
|
|
77
|
+
export * from './components/control/AsgardeoLoading';
|
|
78
|
+
export { default as BaseSignIn } from './components/presentation/SignIn/BaseSignIn';
|
|
79
|
+
export * from './components/presentation/SignIn/BaseSignIn';
|
|
80
|
+
export { default as SignIn } from './components/presentation/SignIn/SignIn';
|
|
81
|
+
export * from './components/presentation/SignIn/SignIn';
|
|
82
|
+
export { default as BaseSignUp } from './components/presentation/SignUp/BaseSignUp';
|
|
83
|
+
export * from './components/presentation/SignUp/BaseSignUp';
|
|
84
|
+
export { default as SignUp } from './components/presentation/SignUp/SignUp';
|
|
85
|
+
export * from './components/presentation/SignUp/SignUp';
|
|
86
|
+
export { default as IdentifierFirst } from './components/presentation/SignIn/options/IdentifierFirst';
|
|
87
|
+
export { default as UsernamePassword } from './components/presentation/SignIn/options/UsernamePassword';
|
|
88
|
+
export { default as GoogleButton } from './components/presentation/SignIn/options/GoogleButton';
|
|
89
|
+
export { default as GitHubButton } from './components/presentation/SignIn/options/GitHubButton';
|
|
90
|
+
export { default as MicrosoftButton } from './components/presentation/SignIn/options/MicrosoftButton';
|
|
91
|
+
export { default as FacebookButton } from './components/presentation/SignIn/options/FacebookButton';
|
|
92
|
+
export { default as LinkedInButton } from './components/presentation/SignIn/options/LinkedInButton';
|
|
93
|
+
export { default as SignInWithEthereumButton } from './components/presentation/SignIn/options/SignInWithEthereumButton';
|
|
94
|
+
export { default as EmailOtp } from './components/presentation/SignIn/options/EmailOtp';
|
|
95
|
+
export { default as Totp } from './components/presentation/SignIn/options/Totp';
|
|
96
|
+
export { default as SmsOtp } from './components/presentation/SignIn/options/SmsOtp';
|
|
97
|
+
export { default as SocialButton } from './components/presentation/SignIn/options/SocialButton';
|
|
98
|
+
export { default as MultiOptionButton } from './components/presentation/SignIn/options/MultiOptionButton';
|
|
99
|
+
export * from './components/presentation/SignIn/options/SignInOptionFactory';
|
|
100
|
+
export { default as BaseUser } from './components/presentation/User/BaseUser';
|
|
101
|
+
export * from './components/presentation/User/BaseUser';
|
|
102
|
+
export { default as User } from './components/presentation/User/User';
|
|
103
|
+
export * from './components/presentation/User/User';
|
|
104
|
+
export { default as BaseOrganization } from './components/presentation/Organization/BaseOrganization';
|
|
105
|
+
export * from './components/presentation/Organization/BaseOrganization';
|
|
106
|
+
export { default as Organization } from './components/presentation/Organization/Organization';
|
|
107
|
+
export * from './components/presentation/Organization/Organization';
|
|
44
108
|
export { default as BaseUserProfile } from './components/presentation/UserProfile/BaseUserProfile';
|
|
45
109
|
export * from './components/presentation/UserProfile/BaseUserProfile';
|
|
46
110
|
export { default as UserProfile } from './components/presentation/UserProfile/UserProfile';
|
|
@@ -49,4 +113,64 @@ export { default as BaseUserDropdown } from './components/presentation/UserDropd
|
|
|
49
113
|
export * from './components/presentation/UserDropdown/BaseUserDropdown';
|
|
50
114
|
export { default as UserDropdown } from './components/presentation/UserDropdown/UserDropdown';
|
|
51
115
|
export * from './components/presentation/UserDropdown/UserDropdown';
|
|
52
|
-
export
|
|
116
|
+
export { default as BaseOrganizationSwitcher } from './components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher';
|
|
117
|
+
export * from './components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher';
|
|
118
|
+
export { default as OrganizationSwitcher } from './components/presentation/OrganizationSwitcher/OrganizationSwitcher';
|
|
119
|
+
export * from './components/presentation/OrganizationSwitcher/OrganizationSwitcher';
|
|
120
|
+
export { default as BaseOrganizationList } from './components/presentation/OrganizationList/BaseOrganizationList';
|
|
121
|
+
export * from './components/presentation/OrganizationList/BaseOrganizationList';
|
|
122
|
+
export { default as OrganizationList } from './components/presentation/OrganizationList/OrganizationList';
|
|
123
|
+
export * from './components/presentation/OrganizationList/OrganizationList';
|
|
124
|
+
export { default as BaseOrganizationProfile } from './components/presentation/OrganizationProfile/BaseOrganizationProfile';
|
|
125
|
+
export * from './components/presentation/OrganizationProfile/BaseOrganizationProfile';
|
|
126
|
+
export { default as OrganizationProfile } from './components/presentation/OrganizationProfile/OrganizationProfile';
|
|
127
|
+
export * from './components/presentation/OrganizationProfile/OrganizationProfile';
|
|
128
|
+
export { BaseCreateOrganization } from './components/presentation/CreateOrganization/BaseCreateOrganization';
|
|
129
|
+
export * from './components/presentation/CreateOrganization/BaseCreateOrganization';
|
|
130
|
+
export { CreateOrganization } from './components/presentation/CreateOrganization/CreateOrganization';
|
|
131
|
+
export * from './components/presentation/CreateOrganization/CreateOrganization';
|
|
132
|
+
export { default as Button } from './components/primitives/Button/Button';
|
|
133
|
+
export * from './components/primitives/Button/Button';
|
|
134
|
+
export { default as Card } from './components/primitives/Card/Card';
|
|
135
|
+
export * from './components/primitives/Card/Card';
|
|
136
|
+
export { default as Alert } from './components/primitives/Alert/Alert';
|
|
137
|
+
export * from './components/primitives/Alert/Alert';
|
|
138
|
+
export { default as OtpField } from './components/primitives/OtpField/OtpField';
|
|
139
|
+
export * from './components/primitives/OtpField/OtpField';
|
|
140
|
+
export { default as TextField } from './components/primitives/TextField/TextField';
|
|
141
|
+
export * from './components/primitives/TextField/TextField';
|
|
142
|
+
export { default as PasswordField } from './components/primitives/PasswordField/PasswordField';
|
|
143
|
+
export * from './components/primitives/PasswordField/PasswordField';
|
|
144
|
+
export { default as Select } from './components/primitives/Select/Select';
|
|
145
|
+
export * from './components/primitives/Select/Select';
|
|
146
|
+
export { default as DatePicker } from './components/primitives/DatePicker/DatePicker';
|
|
147
|
+
export * from './components/primitives/DatePicker/DatePicker';
|
|
148
|
+
export { default as Checkbox } from './components/primitives/Checkbox/Checkbox';
|
|
149
|
+
export * from './components/primitives/Checkbox/Checkbox';
|
|
150
|
+
export { default as FormControl } from './components/primitives/FormControl/FormControl';
|
|
151
|
+
export * from './components/primitives/FormControl/FormControl';
|
|
152
|
+
export { default as InputLabel } from './components/primitives/InputLabel/InputLabel';
|
|
153
|
+
export * from './components/primitives/InputLabel/InputLabel';
|
|
154
|
+
export { default as KeyValueInput } from './components/primitives/KeyValueInput/KeyValueInput';
|
|
155
|
+
export * from './components/primitives/KeyValueInput/KeyValueInput';
|
|
156
|
+
export { default as Typography } from './components/primitives/Typography/Typography';
|
|
157
|
+
export * from './components/primitives/Typography/Typography';
|
|
158
|
+
export { default as Divider } from './components/primitives/Divider/Divider';
|
|
159
|
+
export * from './components/primitives/Divider/Divider';
|
|
160
|
+
export { default as Spinner } from './components/primitives/Spinner/Spinner';
|
|
161
|
+
export * from './components/primitives/Spinner/Spinner';
|
|
162
|
+
export { default as Eye } from './components/primitives/Icons/Eye';
|
|
163
|
+
export { default as EyeOff } from './components/primitives/Icons/EyeOff';
|
|
164
|
+
export { default as CircleCheck } from './components/primitives/Icons/CircleCheck';
|
|
165
|
+
export { default as CircleAlert } from './components/primitives/Icons/CircleAlert';
|
|
166
|
+
export { default as TriangleAlert } from './components/primitives/Icons/TriangleAlert';
|
|
167
|
+
export { default as Info } from './components/primitives/Icons/Info';
|
|
168
|
+
export { default as UserIcon } from './components/primitives/Icons/User';
|
|
169
|
+
export { default as LogOut } from './components/primitives/Icons/LogOut';
|
|
170
|
+
export { createField, FieldFactory, parseMultiValuedString, formatMultiValuedString, validateFieldValue, } from './components/factories/FieldFactory';
|
|
171
|
+
export * from './components/factories/FieldFactory';
|
|
172
|
+
export type { FlowStep, FlowMessage, FlowContextValue } from './contexts/Flow/FlowContext';
|
|
173
|
+
export type { FlowProviderProps } from './contexts/Flow/FlowProvider';
|
|
174
|
+
export { default as createOrganization } from './api/scim2/createOrganization';
|
|
175
|
+
export * from './api/scim2/createOrganization';
|
|
176
|
+
export { default as getMeOrganizations } from './api/scim2/getMeOrganizations';
|