@asgardeo/react 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoReactClient.d.ts +13 -5
- package/dist/__temp__/api.d.ts +11 -5
- package/dist/__temp__/models.d.ts +3 -3
- package/dist/api/createOrganization.d.ts +81 -0
- package/dist/api/getAllOrganizations.d.ts +73 -0
- package/dist/api/getMeOrganizations.d.ts +77 -0
- package/dist/api/getOrganization.d.ts +69 -0
- package/dist/api/getSchemas.d.ts +67 -0
- package/dist/api/getScim2Me.d.ts +67 -0
- package/dist/api/updateMeProfile.d.ts +55 -0
- package/dist/api/updateOrganization.d.ts +76 -0
- package/dist/cjs/index.js +9685 -17275
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +5 -5
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +5 -5
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +5 -5
- package/dist/components/control/AsgardeoLoading.d.ts +47 -0
- package/dist/components/control/SignedIn.d.ts +2 -0
- package/dist/components/control/SignedOut.d.ts +2 -0
- package/dist/components/factories/FieldFactory.d.ts +6 -11
- 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 +31 -38
- package/dist/components/presentation/SignIn/SignIn.d.ts +3 -14
- package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +4 -4
- package/dist/components/presentation/SignIn/types.d.ts +6 -6
- 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/UserDropdown/BaseUserDropdown.d.ts +34 -22
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +60 -4
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +17 -15
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
- package/dist/components/primitives/Avatar/Avatar.d.ts +21 -8
- package/dist/components/primitives/Card/Card.d.ts +8 -9
- package/dist/components/primitives/Divider/Divider.d.ts +8 -8
- 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/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/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/KeyValueInput/KeyValueInput.d.ts +123 -0
- package/dist/components/primitives/KeyValueInput/index.d.ts +0 -0
- package/dist/components/primitives/Popover/Popover.d.ts +19 -19
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +7 -2
- 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/contexts/Theme/types.d.ts +38 -9
- package/dist/contexts/User/UserContext.d.ts +3 -2
- package/dist/contexts/User/UserProvider.d.ts +2 -1
- package/dist/hooks/useForm.d.ts +52 -52
- package/dist/index.d.ts +53 -1
- package/dist/index.js +9725 -17303
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/api/scim2/getMeProfile.d.ts +0 -39
- package/dist/api/scim2/getSchemas.d.ts +0 -39
- package/dist/api/scim2/updateMeProfile.d.ts +0 -38
|
@@ -0,0 +1,153 @@
|
|
|
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 { OrganizationDetails } from '@asgardeo/browser';
|
|
19
|
+
import { FC, ReactElement } from 'react';
|
|
20
|
+
export interface BaseOrganizationProfileProps {
|
|
21
|
+
/**
|
|
22
|
+
* Callback fired when the cancel button is clicked (only used in editable mode).
|
|
23
|
+
*/
|
|
24
|
+
cancelButtonText?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to display the profile in a card layout.
|
|
27
|
+
*/
|
|
28
|
+
cardLayout?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* CSS class name for styling the component.
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the organization profile is editable.
|
|
35
|
+
*/
|
|
36
|
+
editable?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Component to render when no organization data is available.
|
|
39
|
+
*/
|
|
40
|
+
fallback?: ReactElement;
|
|
41
|
+
/**
|
|
42
|
+
* Array of field configurations to display. Each field specifies what organization data to show.
|
|
43
|
+
*/
|
|
44
|
+
fields?: Array<{
|
|
45
|
+
key: keyof OrganizationDetails | 'attributes';
|
|
46
|
+
label: string;
|
|
47
|
+
editable?: boolean;
|
|
48
|
+
render?: (value: any, organization: OrganizationDetails) => React.ReactNode;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Display mode for the component.
|
|
52
|
+
*/
|
|
53
|
+
mode?: 'inline' | 'popup';
|
|
54
|
+
/**
|
|
55
|
+
* Callback fired when a field value changes.
|
|
56
|
+
*/
|
|
57
|
+
onChange?: (field: string, value: any) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Callback fired when the popup should be closed (only used in popup mode).
|
|
60
|
+
*/
|
|
61
|
+
onOpenChange?: (open: boolean) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Callback fired when the form is submitted (only used in editable mode).
|
|
64
|
+
*/
|
|
65
|
+
onSubmit?: (data: any) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback fired when the organization should be updated.
|
|
68
|
+
*/
|
|
69
|
+
onUpdate?: (payload: any) => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the popup is open (only used in popup mode).
|
|
72
|
+
*/
|
|
73
|
+
open?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The organization details to display.
|
|
76
|
+
*/
|
|
77
|
+
organization?: OrganizationDetails | null;
|
|
78
|
+
/**
|
|
79
|
+
* Text for the save button (only used in editable mode).
|
|
80
|
+
*/
|
|
81
|
+
saveButtonText?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Custom title for the profile.
|
|
84
|
+
*/
|
|
85
|
+
title?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* BaseOrganizationProfile component displays organization information in a
|
|
89
|
+
* structured and styled format. It shows organization details such as name,
|
|
90
|
+
* description, status, and other available information with support for inline editing.
|
|
91
|
+
*
|
|
92
|
+
* This is the base component that can be used in any context where you have
|
|
93
|
+
* an organization object available. It provides editing capabilities similar to
|
|
94
|
+
* the UserProfile component, allowing users to modify organization fields directly.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* // Basic usage
|
|
99
|
+
* <BaseOrganizationProfile organization={organizationData} />
|
|
100
|
+
*
|
|
101
|
+
* // With editing enabled and update handler
|
|
102
|
+
* <BaseOrganizationProfile
|
|
103
|
+
* organization={organizationData}
|
|
104
|
+
* editable={true}
|
|
105
|
+
* onUpdate={async (payload) => {
|
|
106
|
+
* await updateOrganizationAPI(orgId, payload);
|
|
107
|
+
* }}
|
|
108
|
+
* />
|
|
109
|
+
*
|
|
110
|
+
* // With card layout and custom title
|
|
111
|
+
* <BaseOrganizationProfile
|
|
112
|
+
* organization={organizationData}
|
|
113
|
+
* cardLayout={true}
|
|
114
|
+
* title="Organization Details"
|
|
115
|
+
* fallback={<div>No organization data available</div>}
|
|
116
|
+
* />
|
|
117
|
+
*
|
|
118
|
+
* // With custom fields configuration
|
|
119
|
+
* <BaseOrganizationProfile
|
|
120
|
+
* organization={organizationData}
|
|
121
|
+
* fields={[
|
|
122
|
+
* { key: 'id', label: 'Organization ID', editable: false },
|
|
123
|
+
* { key: 'name', label: 'Organization Name', editable: true },
|
|
124
|
+
* { key: 'description', label: 'Description', editable: true, render: (value) => value || 'No description' },
|
|
125
|
+
* { key: 'created', label: 'Created Date', editable: false, render: (value) => new Date(value).toLocaleDateString() },
|
|
126
|
+
* { key: 'attributes', label: 'Custom Attributes', editable: true }
|
|
127
|
+
* ]}
|
|
128
|
+
* onUpdate={handleUpdate}
|
|
129
|
+
* />
|
|
130
|
+
*
|
|
131
|
+
* // In popup mode
|
|
132
|
+
* <BaseOrganizationProfile
|
|
133
|
+
* organization={organizationData}
|
|
134
|
+
* mode="popup"
|
|
135
|
+
* open={isOpen}
|
|
136
|
+
* onOpenChange={setIsOpen}
|
|
137
|
+
* title="Edit Organization"
|
|
138
|
+
* />
|
|
139
|
+
* ```
|
|
140
|
+
* <BaseOrganizationProfile
|
|
141
|
+
* organization={organizationData}
|
|
142
|
+
* fields={[
|
|
143
|
+
* { key: 'id', label: 'Organization ID' },
|
|
144
|
+
* { key: 'name', label: 'Organization Name' },
|
|
145
|
+
* { key: 'description', label: 'Description', render: (value) => value || 'No description' },
|
|
146
|
+
* { key: 'created', label: 'Created Date', render: (value) => new Date(value).toLocaleDateString() },
|
|
147
|
+
* { key: 'attributes', label: 'Custom Attributes' }
|
|
148
|
+
* ]}
|
|
149
|
+
* />
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare const BaseOrganizationProfile: FC<BaseOrganizationProfileProps>;
|
|
153
|
+
export default BaseOrganizationProfile;
|
|
@@ -0,0 +1,119 @@
|
|
|
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, ReactElement } from 'react';
|
|
19
|
+
import { BaseOrganizationProfileProps } from './BaseOrganizationProfile';
|
|
20
|
+
/**
|
|
21
|
+
* Props for the OrganizationProfile component.
|
|
22
|
+
* Extends BaseOrganizationProfileProps but makes the organization prop optional
|
|
23
|
+
* since it will be fetched using the organizationId
|
|
24
|
+
*/
|
|
25
|
+
export type OrganizationProfileProps = Omit<BaseOrganizationProfileProps, 'organization' | 'mode'> & {
|
|
26
|
+
/**
|
|
27
|
+
* Component to show when there's an error loading organization data.
|
|
28
|
+
*/
|
|
29
|
+
errorFallback?: ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* Component to show while loading organization data.
|
|
32
|
+
*/
|
|
33
|
+
loadingFallback?: ReactElement;
|
|
34
|
+
/**
|
|
35
|
+
* Display mode for the component.
|
|
36
|
+
*/
|
|
37
|
+
mode?: 'default' | 'popup';
|
|
38
|
+
/**
|
|
39
|
+
* Callback fired when the popup should be closed (only used in popup mode).
|
|
40
|
+
*/
|
|
41
|
+
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Callback fired when the organization should be updated.
|
|
44
|
+
*/
|
|
45
|
+
onUpdate?: (payload: any) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the popup is open (only used in popup mode).
|
|
48
|
+
*/
|
|
49
|
+
open?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The ID of the organization to fetch and display.
|
|
52
|
+
*/
|
|
53
|
+
organizationId: string;
|
|
54
|
+
/**
|
|
55
|
+
* Custom title for the popup dialog (only used in popup mode).
|
|
56
|
+
*/
|
|
57
|
+
popupTitle?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* OrganizationProfile component displays organization information in a
|
|
61
|
+
* structured and styled format. It automatically fetches organization details
|
|
62
|
+
* using the provided organization ID and displays them using BaseOrganizationProfile.
|
|
63
|
+
*
|
|
64
|
+
* The component supports editing functionality, allowing users to modify organization
|
|
65
|
+
* fields inline. Updates are automatically synced with the backend via the SCIM2 API.
|
|
66
|
+
*
|
|
67
|
+
* This component is the React-specific implementation that automatically
|
|
68
|
+
* retrieves the organization data from Asgardeo API.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* // Basic usage with editing enabled (default)
|
|
73
|
+
* <OrganizationProfile organizationId="0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1" />
|
|
74
|
+
*
|
|
75
|
+
* // Read-only mode
|
|
76
|
+
* <OrganizationProfile
|
|
77
|
+
* organizationId="0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
|
|
78
|
+
* editable={false}
|
|
79
|
+
* />
|
|
80
|
+
*
|
|
81
|
+
* // With card layout and custom fallbacks
|
|
82
|
+
* <OrganizationProfile
|
|
83
|
+
* organizationId="0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
|
|
84
|
+
* cardLayout={true}
|
|
85
|
+
* loadingFallback={<div>Loading organization...</div>}
|
|
86
|
+
* errorFallback={<div>Failed to load organization</div>}
|
|
87
|
+
* fallback={<div>No organization data available</div>}
|
|
88
|
+
* />
|
|
89
|
+
*
|
|
90
|
+
* // With custom fields configuration and update callback
|
|
91
|
+
* <OrganizationProfile
|
|
92
|
+
* organizationId="0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
|
|
93
|
+
* fields={[
|
|
94
|
+
* { key: 'id', label: 'Organization ID', editable: false },
|
|
95
|
+
* { key: 'name', label: 'Organization Name', editable: true },
|
|
96
|
+
* { key: 'description', label: 'Description', editable: true, render: (value) => value || 'No description' },
|
|
97
|
+
* { key: 'created', label: 'Created Date', editable: false, render: (value) => new Date(value).toLocaleDateString() },
|
|
98
|
+
* { key: 'lastModified', label: 'Last Modified Date', editable: false, render: (value) => new Date(value).toLocaleDateString() },
|
|
99
|
+
* { key: 'attributes', label: 'Custom Attributes', editable: true }
|
|
100
|
+
* ]}
|
|
101
|
+
* onUpdate={async (payload) => {
|
|
102
|
+
* console.log('Organization updated:', payload);
|
|
103
|
+
* // payload contains the updated field values
|
|
104
|
+
* // The component automatically converts these to patch operations
|
|
105
|
+
* }}
|
|
106
|
+
* />
|
|
107
|
+
*
|
|
108
|
+
* // In popup mode
|
|
109
|
+
* <OrganizationProfile
|
|
110
|
+
* organizationId="0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
|
|
111
|
+
* mode="popup"
|
|
112
|
+
* open={isOpen}
|
|
113
|
+
* onOpenChange={setIsOpen}
|
|
114
|
+
* popupTitle="Edit Organization Profile"
|
|
115
|
+
* />
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare const OrganizationProfile: FC<OrganizationProfileProps>;
|
|
119
|
+
export default OrganizationProfile;
|
|
@@ -0,0 +1,141 @@
|
|
|
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, ReactElement, ReactNode } from 'react';
|
|
19
|
+
interface MenuItem {
|
|
20
|
+
href?: string;
|
|
21
|
+
icon?: ReactNode;
|
|
22
|
+
label: ReactNode;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Interface for organization data.
|
|
27
|
+
*/
|
|
28
|
+
export interface Organization {
|
|
29
|
+
/**
|
|
30
|
+
* Avatar URL for the organization.
|
|
31
|
+
*/
|
|
32
|
+
avatar?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Unique identifier for the organization.
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* Number of members in the organization.
|
|
39
|
+
*/
|
|
40
|
+
memberCount?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Additional metadata for the organization.
|
|
43
|
+
*/
|
|
44
|
+
metadata?: Record<string, any>;
|
|
45
|
+
/**
|
|
46
|
+
* Display name of the organization.
|
|
47
|
+
*/
|
|
48
|
+
name: string;
|
|
49
|
+
/**
|
|
50
|
+
* User's role in the organization.
|
|
51
|
+
*/
|
|
52
|
+
role?: 'owner' | 'admin' | 'member';
|
|
53
|
+
/**
|
|
54
|
+
* URL slug for the organization.
|
|
55
|
+
*/
|
|
56
|
+
slug?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Props interface for the BaseOrganizationSwitcher component.
|
|
60
|
+
*/
|
|
61
|
+
export interface BaseOrganizationSwitcherProps {
|
|
62
|
+
/**
|
|
63
|
+
* Optional size for the avatar
|
|
64
|
+
*/
|
|
65
|
+
avatarSize?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Custom class name for styling.
|
|
68
|
+
*/
|
|
69
|
+
className?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Currently selected organization.
|
|
72
|
+
*/
|
|
73
|
+
currentOrganization?: Organization;
|
|
74
|
+
/**
|
|
75
|
+
* Error message to display.
|
|
76
|
+
*/
|
|
77
|
+
error?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Optional element to render when no organization is selected.
|
|
80
|
+
*/
|
|
81
|
+
fallback?: ReactElement;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the component is in a loading state.
|
|
84
|
+
*/
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Additional menu items to display at the bottom of the dropdown.
|
|
88
|
+
*/
|
|
89
|
+
menuItems?: MenuItem[];
|
|
90
|
+
/**
|
|
91
|
+
* Handler for when an organization is selected.
|
|
92
|
+
*/
|
|
93
|
+
onOrganizationSwitch: (organization: Organization) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Handler for when the manage profile button is clicked.
|
|
96
|
+
*/
|
|
97
|
+
onManageProfile?: () => void;
|
|
98
|
+
/**
|
|
99
|
+
* List of available organizations.
|
|
100
|
+
*/
|
|
101
|
+
organizations: Organization[];
|
|
102
|
+
/**
|
|
103
|
+
* The HTML element ID where the portal should be mounted
|
|
104
|
+
*/
|
|
105
|
+
portalId?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Custom render function for the error state.
|
|
108
|
+
*/
|
|
109
|
+
renderError?: (error: string) => ReactElement;
|
|
110
|
+
/**
|
|
111
|
+
* Custom render function for the loading state.
|
|
112
|
+
*/
|
|
113
|
+
renderLoading?: () => ReactElement;
|
|
114
|
+
/**
|
|
115
|
+
* Custom render function for the organization item.
|
|
116
|
+
*/
|
|
117
|
+
renderOrganization?: (organization: Organization, isSelected: boolean) => ReactElement;
|
|
118
|
+
/**
|
|
119
|
+
* Whether to show the member count.
|
|
120
|
+
*/
|
|
121
|
+
showMemberCount?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether to show the role badge.
|
|
124
|
+
*/
|
|
125
|
+
showRole?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Show organization name next to avatar in the trigger button
|
|
128
|
+
*/
|
|
129
|
+
showTriggerLabel?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Custom styles for the component.
|
|
132
|
+
*/
|
|
133
|
+
style?: React.CSSProperties;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* BaseOrganizationSwitcher component displays an organization selector with a dropdown menu.
|
|
137
|
+
* When clicked, it shows a popover with available organizations to switch between.
|
|
138
|
+
* This component serves as the base for framework-specific implementations.
|
|
139
|
+
*/
|
|
140
|
+
export declare const BaseOrganizationSwitcher: FC<BaseOrganizationSwitcherProps>;
|
|
141
|
+
export default BaseOrganizationSwitcher;
|
|
@@ -0,0 +1,70 @@
|
|
|
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, ReactElement } from 'react';
|
|
19
|
+
import { BaseOrganizationSwitcherProps, Organization } from './BaseOrganizationSwitcher';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface for the OrganizationSwitcher component.
|
|
22
|
+
* Makes organizations optional since they'll be retrieved from OrganizationContext.
|
|
23
|
+
*/
|
|
24
|
+
export interface OrganizationSwitcherProps extends Omit<BaseOrganizationSwitcherProps, 'organizations' | 'currentOrganization' | 'onOrganizationSwitch'> {
|
|
25
|
+
/**
|
|
26
|
+
* Optional override for current organization (will use context if not provided)
|
|
27
|
+
*/
|
|
28
|
+
currentOrganization?: Organization;
|
|
29
|
+
/**
|
|
30
|
+
* Fallback element to render when the user is not signed in.
|
|
31
|
+
*/
|
|
32
|
+
fallback?: ReactElement;
|
|
33
|
+
/**
|
|
34
|
+
* Optional callback for organization switch (will use context if not provided)
|
|
35
|
+
*/
|
|
36
|
+
onOrganizationSwitch?: (organization: Organization) => Promise<void> | void;
|
|
37
|
+
/**
|
|
38
|
+
* Optional override for organizations list (will use context if not provided)
|
|
39
|
+
*/
|
|
40
|
+
organizations?: Organization[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* OrganizationSwitcher component that provides organization switching functionality.
|
|
44
|
+
* This component automatically retrieves organizations from the OrganizationContext.
|
|
45
|
+
* You can also override the organizations, currentOrganization, and onOrganizationSwitch
|
|
46
|
+
* by passing them as props.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import { OrganizationSwitcher } from '@asgardeo/react';
|
|
51
|
+
*
|
|
52
|
+
* // Basic usage - uses OrganizationContext
|
|
53
|
+
* <OrganizationSwitcher />
|
|
54
|
+
*
|
|
55
|
+
* // With custom organization switch handler
|
|
56
|
+
* <OrganizationSwitcher
|
|
57
|
+
* onOrganizationSwitch={(org) => {
|
|
58
|
+
* console.log('Switching to:', org.name);
|
|
59
|
+
* // Custom logic here
|
|
60
|
+
* }}
|
|
61
|
+
* />
|
|
62
|
+
*
|
|
63
|
+
* // With fallback for unauthenticated users
|
|
64
|
+
* <OrganizationSwitcher
|
|
65
|
+
* fallback={<div>Please sign in to view organizations</div>}
|
|
66
|
+
* />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const OrganizationSwitcher: FC<OrganizationSwitcherProps>;
|
|
70
|
+
export default OrganizationSwitcher;
|
|
@@ -15,40 +15,34 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { EmbeddedSignInFlowInitiateResponse, EmbeddedSignInFlowHandleResponse, EmbeddedSignInFlowHandleRequestPayload, EmbeddedFlowExecuteRequestConfig } from '@asgardeo/browser';
|
|
19
19
|
import { FC } from 'react';
|
|
20
|
+
import { CardProps } from '../../primitives/Card/Card';
|
|
20
21
|
/**
|
|
21
22
|
* Props for the BaseSignIn component.
|
|
22
23
|
*/
|
|
23
24
|
export interface BaseSignInProps {
|
|
25
|
+
afterSignInUrl?: string;
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @returns Promise resolving to the initial authentication response.
|
|
27
|
+
* Custom CSS class name for the submit button.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
buttonClassName?: string;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param payload - The authentication payload.
|
|
32
|
-
* @returns Promise resolving to the authentication response.
|
|
31
|
+
* Custom CSS class name for the form container.
|
|
33
32
|
*/
|
|
34
|
-
|
|
35
|
-
requestConfig?: {
|
|
36
|
-
method: string;
|
|
37
|
-
url: string;
|
|
38
|
-
};
|
|
39
|
-
payload: {
|
|
40
|
-
flowId: string;
|
|
41
|
-
selectedAuthenticator: {
|
|
42
|
-
authenticatorId: string;
|
|
43
|
-
params: Record<string, string>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}) => Promise<ApplicationNativeAuthenticationHandleResponse>;
|
|
33
|
+
className?: string;
|
|
47
34
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @param authData - The authentication data returned upon successful completion.
|
|
35
|
+
* Custom CSS class name for error messages.
|
|
50
36
|
*/
|
|
51
|
-
|
|
37
|
+
errorClassName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Custom CSS class name for form inputs.
|
|
40
|
+
*/
|
|
41
|
+
inputClassName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom CSS class name for info messages.
|
|
44
|
+
*/
|
|
45
|
+
messageClassName?: string;
|
|
52
46
|
/**
|
|
53
47
|
* Callback function called when authentication fails.
|
|
54
48
|
* @param error - The error that occurred during authentication.
|
|
@@ -58,27 +52,27 @@ export interface BaseSignInProps {
|
|
|
58
52
|
* Callback function called when authentication flow status changes.
|
|
59
53
|
* @param response - The current authentication response.
|
|
60
54
|
*/
|
|
61
|
-
onFlowChange?: (response:
|
|
55
|
+
onFlowChange?: (response: EmbeddedSignInFlowInitiateResponse | EmbeddedSignInFlowHandleResponse) => void;
|
|
62
56
|
/**
|
|
63
|
-
*
|
|
57
|
+
* Flag to determine the component is ready to be rendered.
|
|
64
58
|
*/
|
|
65
|
-
|
|
59
|
+
isLoading?: boolean;
|
|
66
60
|
/**
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
inputClassName?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Custom CSS class name for the submit button.
|
|
61
|
+
* Function to initialize authentication flow.
|
|
62
|
+
* @returns Promise resolving to the initial authentication response.
|
|
72
63
|
*/
|
|
73
|
-
|
|
64
|
+
onInitialize?: () => Promise<EmbeddedSignInFlowInitiateResponse>;
|
|
74
65
|
/**
|
|
75
|
-
*
|
|
66
|
+
* Function to handle authentication steps.
|
|
67
|
+
* @param payload - The authentication payload.
|
|
68
|
+
* @returns Promise resolving to the authentication response.
|
|
76
69
|
*/
|
|
77
|
-
|
|
70
|
+
onSubmit?: (payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig) => Promise<EmbeddedSignInFlowHandleResponse>;
|
|
78
71
|
/**
|
|
79
|
-
*
|
|
72
|
+
* Callback function called when authentication is successful.
|
|
73
|
+
* @param authData - The authentication data returned upon successful completion.
|
|
80
74
|
*/
|
|
81
|
-
|
|
75
|
+
onSuccess?: (authData: Record<string, any>) => void;
|
|
82
76
|
/**
|
|
83
77
|
* Size variant for the component.
|
|
84
78
|
*/
|
|
@@ -86,8 +80,7 @@ export interface BaseSignInProps {
|
|
|
86
80
|
/**
|
|
87
81
|
* Theme variant for the component.
|
|
88
82
|
*/
|
|
89
|
-
variant?: '
|
|
90
|
-
afterSignInUrl?: string;
|
|
83
|
+
variant?: CardProps['variant'];
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
86
|
* Base SignIn component that provides native authentication flow.
|
|
@@ -16,23 +16,12 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { FC } from 'react';
|
|
19
|
+
import { BaseSignInProps } from './BaseSignIn';
|
|
19
20
|
/**
|
|
20
21
|
* Props for the SignIn component.
|
|
22
|
+
* Extends BaseSignInProps for full compatibility with the React BaseSignIn component
|
|
21
23
|
*/
|
|
22
|
-
export
|
|
23
|
-
/**
|
|
24
|
-
* Additional CSS class names for customization.
|
|
25
|
-
*/
|
|
26
|
-
className?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Size variant for the component.
|
|
29
|
-
*/
|
|
30
|
-
size?: 'small' | 'medium' | 'large';
|
|
31
|
-
/**
|
|
32
|
-
* Theme variant for the component.
|
|
33
|
-
*/
|
|
34
|
-
variant?: 'default' | 'outlined' | 'filled';
|
|
35
|
-
}
|
|
24
|
+
export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onError' | 'variant' | 'size'>;
|
|
36
25
|
/**
|
|
37
26
|
* A styled SignIn component that provides native authentication flow with pre-built styling.
|
|
38
27
|
* This component handles the API calls for authentication and delegates UI logic to BaseSignIn.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { EmbeddedSignInFlowAuthenticator, WithPreferences } from '@asgardeo/browser';
|
|
19
19
|
import { ReactElement } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Base props that all sign-in option components share.
|
|
@@ -24,7 +24,7 @@ export interface BaseSignInOptionProps extends WithPreferences {
|
|
|
24
24
|
/**
|
|
25
25
|
* The authenticator configuration.
|
|
26
26
|
*/
|
|
27
|
-
authenticator:
|
|
27
|
+
authenticator: EmbeddedSignInFlowAuthenticator;
|
|
28
28
|
/**
|
|
29
29
|
* Current form values.
|
|
30
30
|
*/
|
|
@@ -48,7 +48,7 @@ export interface BaseSignInOptionProps extends WithPreferences {
|
|
|
48
48
|
/**
|
|
49
49
|
* Callback function called when the option is submitted.
|
|
50
50
|
*/
|
|
51
|
-
onSubmit: (authenticator:
|
|
51
|
+
onSubmit: (authenticator: EmbeddedSignInFlowAuthenticator, formData?: Record<string, string>) => void;
|
|
52
52
|
/**
|
|
53
53
|
* Custom CSS class name for form inputs.
|
|
54
54
|
*/
|
|
@@ -69,7 +69,7 @@ export declare const createSignInOption: (props: BaseSignInOptionProps) => React
|
|
|
69
69
|
/**
|
|
70
70
|
* Convenience function that creates the appropriate sign-in option component from an authenticator.
|
|
71
71
|
*/
|
|
72
|
-
export declare const createSignInOptionFromAuthenticator: (authenticator:
|
|
72
|
+
export declare const createSignInOptionFromAuthenticator: (authenticator: EmbeddedSignInFlowAuthenticator, formValues: Record<string, string>, touchedFields: Record<string, boolean>, isLoading: boolean, onInputChange: (param: string, value: string) => void, onSubmit: (authenticator: EmbeddedSignInFlowAuthenticator, formData?: Record<string, string>) => void, options?: {
|
|
73
73
|
inputClassName?: string;
|
|
74
74
|
buttonClassName?: string;
|
|
75
75
|
error?: string | null;
|