@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.
Files changed (131) hide show
  1. package/README.md +5 -1
  2. package/dist/AsgardeoReactClient.d.ts +12 -4
  3. package/dist/__temp__/api.d.ts +26 -21
  4. package/dist/__temp__/models.d.ts +14 -22
  5. package/dist/api/scim2/createOrganization.d.ts +74 -0
  6. package/dist/api/scim2/getAllOrganizations.d.ts +56 -0
  7. package/dist/api/scim2/getMeOrganizations.d.ts +52 -0
  8. package/dist/api/scim2/getOrganization.d.ts +61 -0
  9. package/dist/api/scim2/updateOrganization.d.ts +74 -0
  10. package/dist/cjs/index.js +9863 -1190
  11. package/dist/cjs/index.js.map +4 -4
  12. package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +7 -6
  13. package/dist/components/actions/SignInButton/SignInButton.d.ts +21 -2
  14. package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +7 -6
  15. package/dist/components/actions/SignOutButton/SignOutButton.d.ts +22 -1
  16. package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +6 -5
  17. package/dist/components/actions/SignUpButton/SignUpButton.d.ts +21 -0
  18. package/dist/components/control/AsgardeoLoading.d.ts +45 -0
  19. package/dist/components/factories/FieldFactory.d.ts +107 -0
  20. package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +53 -0
  21. package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +67 -0
  22. package/dist/components/presentation/Organization/BaseOrganization.d.ts +66 -0
  23. package/dist/components/presentation/Organization/Organization.d.ts +66 -0
  24. package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +117 -0
  25. package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +93 -0
  26. package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +153 -0
  27. package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +119 -0
  28. package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +141 -0
  29. package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +70 -0
  30. package/dist/components/presentation/SignIn/BaseSignIn.d.ts +114 -0
  31. package/dist/components/presentation/SignIn/SignIn.d.ts +63 -0
  32. package/dist/components/presentation/SignIn/options/EmailOtp.d.ts +25 -0
  33. package/dist/components/presentation/SignIn/options/FacebookButton.d.ts +25 -0
  34. package/dist/components/presentation/SignIn/options/GitHubButton.d.ts +25 -0
  35. package/dist/components/presentation/SignIn/options/GoogleButton.d.ts +25 -0
  36. package/dist/components/presentation/SignIn/options/IdentifierFirst.d.ts +25 -0
  37. package/dist/components/presentation/SignIn/options/LinkedInButton.d.ts +25 -0
  38. package/dist/components/presentation/SignIn/options/MicrosoftButton.d.ts +25 -0
  39. package/dist/components/presentation/SignIn/options/MultiOptionButton.d.ts +26 -0
  40. package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +76 -0
  41. package/dist/components/presentation/SignIn/options/SignInWithEthereumButton.d.ts +25 -0
  42. package/dist/components/presentation/SignIn/options/SmsOtp.d.ts +25 -0
  43. package/dist/components/presentation/SignIn/options/SocialButton.d.ts +25 -0
  44. package/dist/components/presentation/SignIn/options/Totp.d.ts +25 -0
  45. package/dist/components/presentation/SignIn/options/UsernamePassword.d.ts +25 -0
  46. package/dist/components/presentation/SignIn/types.d.ts +124 -0
  47. package/dist/components/presentation/SignUp/BaseSignUp.d.ts +126 -0
  48. package/dist/components/presentation/SignUp/SignUp.d.ts +55 -0
  49. package/dist/components/presentation/SignUp/options/CheckboxInput.d.ts +24 -0
  50. package/dist/components/presentation/SignUp/options/DateInput.d.ts +24 -0
  51. package/dist/components/presentation/SignUp/options/DividerComponent.d.ts +24 -0
  52. package/dist/components/presentation/SignUp/options/EmailInput.d.ts +24 -0
  53. package/dist/components/presentation/SignUp/options/FormContainer.d.ts +24 -0
  54. package/dist/components/presentation/SignUp/options/GoogleButton.d.ts +25 -0
  55. package/dist/components/presentation/SignUp/options/ImageComponent.d.ts +24 -0
  56. package/dist/components/presentation/SignUp/options/NumberInput.d.ts +24 -0
  57. package/dist/components/presentation/SignUp/options/PasswordInput.d.ts +24 -0
  58. package/dist/components/presentation/SignUp/options/SignUpOptionFactory.d.ts +100 -0
  59. package/dist/components/presentation/SignUp/options/SocialButton.d.ts +24 -0
  60. package/dist/components/presentation/SignUp/options/SubmitButton.d.ts +24 -0
  61. package/dist/components/presentation/SignUp/options/TelephoneInput.d.ts +24 -0
  62. package/dist/components/presentation/SignUp/options/TextInput.d.ts +24 -0
  63. package/dist/components/presentation/SignUp/options/Typography.d.ts +24 -0
  64. package/dist/components/presentation/SignUp/options/index.d.ts +26 -0
  65. package/dist/components/presentation/User/BaseUser.d.ts +66 -0
  66. package/dist/components/presentation/{User.d.ts → User/User.d.ts} +9 -4
  67. package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +34 -22
  68. package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +60 -4
  69. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +34 -11
  70. package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
  71. package/dist/components/primitives/Alert/Alert.d.ts +74 -0
  72. package/dist/components/primitives/Avatar/Avatar.d.ts +21 -8
  73. package/dist/components/primitives/Button/Button.d.ts +83 -0
  74. package/dist/components/primitives/Card/Card.d.ts +132 -0
  75. package/dist/components/primitives/Checkbox/Checkbox.d.ts +1 -1
  76. package/dist/components/primitives/DatePicker/DatePicker.d.ts +1 -1
  77. package/dist/components/primitives/Divider/Divider.d.ts +58 -0
  78. package/dist/components/primitives/FormControl/FormControl.d.ts +50 -0
  79. package/dist/components/primitives/Icons/Building.d.ts +40 -0
  80. package/dist/components/primitives/Icons/BuildingAlt.d.ts +40 -0
  81. package/dist/components/primitives/Icons/Check.d.ts +40 -0
  82. package/dist/components/primitives/Icons/ChevronDown.d.ts +40 -0
  83. package/dist/components/primitives/Icons/CircleAlert.d.ts +23 -0
  84. package/dist/components/primitives/Icons/CircleCheck.d.ts +23 -0
  85. package/dist/components/primitives/Icons/Eye.d.ts +23 -0
  86. package/dist/components/primitives/Icons/EyeOff.d.ts +23 -0
  87. package/dist/components/primitives/Icons/Info.d.ts +23 -0
  88. package/dist/components/primitives/Icons/LogOut.d.ts +23 -0
  89. package/dist/components/primitives/Icons/Plus.d.ts +23 -0
  90. package/dist/components/primitives/Icons/Settings.d.ts +0 -0
  91. package/dist/components/primitives/Icons/TriangleAlert.d.ts +23 -0
  92. package/dist/components/primitives/Icons/User.d.ts +23 -0
  93. package/dist/components/primitives/Icons/X.d.ts +23 -0
  94. package/dist/components/primitives/Icons/index.d.ts +27 -0
  95. package/dist/components/primitives/InputLabel/InputLabel.d.ts +46 -0
  96. package/dist/components/primitives/KeyValueInput/KeyValueInput.d.ts +123 -0
  97. package/dist/components/primitives/KeyValueInput/index.d.ts +0 -0
  98. package/dist/components/primitives/OtpField/OtpField.d.ts +86 -0
  99. package/dist/components/primitives/PasswordField/PasswordField.d.ts +31 -0
  100. package/dist/components/primitives/Popover/Popover.d.ts +73 -36
  101. package/dist/components/primitives/Select/Select.d.ts +1 -1
  102. package/dist/components/primitives/Spinner/Spinner.d.ts +54 -0
  103. package/dist/components/primitives/TextField/TextField.d.ts +18 -2
  104. package/dist/components/primitives/Typography/Typography.d.ts +81 -0
  105. package/dist/contexts/{AsgardeoContext.d.ts → Asgardeo/AsgardeoContext.d.ts} +3 -1
  106. package/dist/{providers → contexts/Asgardeo}/AsgardeoProvider.d.ts +1 -1
  107. package/dist/{hooks → contexts/Asgardeo}/useAsgardeo.d.ts +1 -1
  108. package/dist/contexts/Flow/FlowContext.d.ts +73 -0
  109. package/dist/contexts/Flow/FlowProvider.d.ts +46 -0
  110. package/dist/contexts/Flow/useFlow.d.ts +48 -0
  111. package/dist/contexts/I18n/I18nContext.d.ts +42 -0
  112. package/dist/contexts/I18n/I18nProvider.d.ts +31 -0
  113. package/dist/contexts/I18n/useI18n.d.ts +27 -0
  114. package/dist/contexts/Organization/OrganizationContext.d.ts +74 -0
  115. package/dist/contexts/Organization/OrganizationProvider.d.ts +90 -0
  116. package/dist/contexts/Organization/useOrganization.d.ts +104 -0
  117. package/dist/{theme → contexts/Theme}/ThemeProvider.d.ts +2 -1
  118. package/dist/{theme → contexts/Theme}/types.d.ts +38 -9
  119. package/dist/{theme → contexts/Theme}/useTheme.d.ts +2 -1
  120. package/dist/contexts/User/UserContext.d.ts +33 -0
  121. package/dist/contexts/User/UserProvider.d.ts +56 -0
  122. package/dist/contexts/User/useUser.d.ts +94 -0
  123. package/dist/hooks/useForm.d.ts +192 -0
  124. package/dist/hooks/useTranslation.d.ts +52 -0
  125. package/dist/index.d.ts +133 -9
  126. package/dist/index.js +9949 -1203
  127. package/dist/index.js.map +4 -4
  128. package/dist/utils/getMappedUserProfileValue.d.ts +33 -1
  129. package/package.json +6 -5
  130. package/dist/utils/getUserProfile.d.ts +0 -59
  131. /package/dist/{theme → contexts/Theme}/ThemeContext.d.ts +0 -0
@@ -0,0 +1,117 @@
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, ReactNode } from 'react';
19
+ import { OrganizationWithSwitchAccess } from '../../../contexts/Organization/OrganizationContext';
20
+ /**
21
+ * Props interface for the BaseOrganizationList component.
22
+ */
23
+ export interface BaseOrganizationListProps {
24
+ /**
25
+ * Additional CSS class names to apply to the container
26
+ */
27
+ className?: string;
28
+ /**
29
+ * List of organizations with switch access information
30
+ */
31
+ data: OrganizationWithSwitchAccess[];
32
+ /**
33
+ * Error message to display
34
+ */
35
+ error?: string | null;
36
+ /**
37
+ * Function called when "Load More" is clicked
38
+ */
39
+ fetchMore?: () => Promise<void>;
40
+ /**
41
+ * Whether there are more organizations to load
42
+ */
43
+ hasMore?: boolean;
44
+ /**
45
+ * Whether the initial data is loading
46
+ */
47
+ isLoading?: boolean;
48
+ /**
49
+ * Whether more data is being loaded
50
+ */
51
+ isLoadingMore?: boolean;
52
+ /**
53
+ * Function called when refresh is requested
54
+ */
55
+ onRefresh?: () => Promise<void>;
56
+ /**
57
+ * Custom renderer for when no organizations are found
58
+ */
59
+ renderEmpty?: () => ReactNode;
60
+ /**
61
+ * Custom renderer for the error state
62
+ */
63
+ renderError?: (error: string) => ReactNode;
64
+ /**
65
+ * Custom renderer for the load more button
66
+ */
67
+ renderLoadMore?: (onLoadMore: () => Promise<void>, isLoading: boolean) => ReactNode;
68
+ /**
69
+ * Custom renderer for the loading state
70
+ */
71
+ renderLoading?: () => ReactNode;
72
+ /**
73
+ * Custom renderer for each organization item
74
+ */
75
+ renderOrganization?: (organization: OrganizationWithSwitchAccess, index: number) => ReactNode;
76
+ /**
77
+ * Inline styles to apply to the container
78
+ */
79
+ style?: React.CSSProperties;
80
+ /**
81
+ * Total number of organizations
82
+ */
83
+ totalCount?: number;
84
+ /**
85
+ * Display mode: 'inline' for normal display, 'popup' for modal dialog
86
+ */
87
+ mode?: 'inline' | 'popup';
88
+ /**
89
+ * Function called when popup open state changes (only used in popup mode)
90
+ */
91
+ onOpenChange?: (open: boolean) => void;
92
+ /**
93
+ * Whether the popup is open (only used in popup mode)
94
+ */
95
+ open?: boolean;
96
+ /**
97
+ * Title for the popup dialog (only used in popup mode)
98
+ */
99
+ title?: string;
100
+ }
101
+ /**
102
+ * BaseOrganizationList component displays a list of organizations with pagination support.
103
+ * This component serves as the base for framework-specific implementations.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * <BaseOrganizationList
108
+ * data={organizations}
109
+ * isLoading={isLoading}
110
+ * hasMore={hasMore}
111
+ * fetchMore={fetchMore}
112
+ * error={error}
113
+ * />
114
+ * ```
115
+ */
116
+ export declare const BaseOrganizationList: FC<BaseOrganizationListProps>;
117
+ export default BaseOrganizationList;
@@ -0,0 +1,93 @@
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 } from 'react';
19
+ import { BaseOrganizationListProps } from './BaseOrganizationList';
20
+ import { OrganizationWithSwitchAccess } from '../../../contexts/Organization/OrganizationContext';
21
+ /**
22
+ * Configuration options for the OrganizationList component.
23
+ */
24
+ export interface OrganizationListConfig {
25
+ /**
26
+ * Whether to automatically fetch organizations on mount
27
+ */
28
+ autoFetch?: boolean;
29
+ /**
30
+ * Filter string for organizations
31
+ */
32
+ filter?: string;
33
+ /**
34
+ * Number of organizations to fetch per page
35
+ */
36
+ limit?: number;
37
+ /**
38
+ * Whether to include recursive organizations
39
+ */
40
+ recursive?: boolean;
41
+ }
42
+ /**
43
+ * Props interface for the OrganizationList component.
44
+ * Uses the enhanced OrganizationContext instead of the useOrganizations hook.
45
+ */
46
+ export interface OrganizationListProps extends Omit<BaseOrganizationListProps, 'data' | 'error' | 'fetchMore' | 'hasMore' | 'isLoading' | 'isLoadingMore' | 'totalCount'>, OrganizationListConfig {
47
+ /**
48
+ * Function called when an organization is selected/clicked
49
+ */
50
+ onOrganizationSelect?: (organization: OrganizationWithSwitchAccess) => void;
51
+ }
52
+ /**
53
+ * OrganizationList component that provides organization listing functionality with pagination.
54
+ * This component uses the enhanced OrganizationContext, eliminating the polling issue and
55
+ * providing better integration with the existing context system.
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * import { OrganizationList } from '@asgardeo/react';
60
+ *
61
+ * // Basic usage
62
+ * <OrganizationList />
63
+ *
64
+ * // With custom limit and filter
65
+ * <OrganizationList
66
+ * limit={20}
67
+ * filter="active"
68
+ * onOrganizationSelect={(org) => {
69
+ * console.log('Selected organization:', org.name);
70
+ * }}
71
+ * />
72
+ *
73
+ * // As a popup dialog
74
+ * <OrganizationList
75
+ * mode="popup"
76
+ * open={isOpen}
77
+ * onOpenChange={setIsOpen}
78
+ * title="Select Organization"
79
+ * />
80
+ *
81
+ * // With custom organization renderer
82
+ * <OrganizationList
83
+ * renderOrganization={(org) => (
84
+ * <div key={org.id}>
85
+ * <h3>{org.name}</h3>
86
+ * <p>Can switch: {org.canSwitch ? 'Yes' : 'No'}</p>
87
+ * </div>
88
+ * )}
89
+ * />
90
+ * ```
91
+ */
92
+ export declare const OrganizationList: FC<OrganizationListProps>;
93
+ export default OrganizationList;
@@ -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 { FC, ReactElement } from 'react';
19
+ import { OrganizationDetails } from '../../../api/scim2/getOrganization';
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;