@asgardeo/react 0.4.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 (79) hide show
  1. package/dist/AsgardeoReactClient.d.ts +10 -3
  2. package/dist/__temp__/api.d.ts +11 -5
  3. package/dist/__temp__/models.d.ts +3 -3
  4. package/dist/api/scim2/createOrganization.d.ts +74 -0
  5. package/dist/api/scim2/getAllOrganizations.d.ts +56 -0
  6. package/dist/api/scim2/getMeOrganizations.d.ts +52 -0
  7. package/dist/api/scim2/getOrganization.d.ts +61 -0
  8. package/dist/api/scim2/updateOrganization.d.ts +74 -0
  9. package/dist/cjs/index.js +9854 -17224
  10. package/dist/cjs/index.js.map +4 -4
  11. package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +5 -5
  12. package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +5 -5
  13. package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +5 -5
  14. package/dist/components/control/AsgardeoLoading.d.ts +45 -0
  15. package/dist/components/factories/FieldFactory.d.ts +3 -3
  16. package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +53 -0
  17. package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +67 -0
  18. package/dist/components/presentation/Organization/BaseOrganization.d.ts +66 -0
  19. package/dist/components/presentation/Organization/Organization.d.ts +66 -0
  20. package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +117 -0
  21. package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +93 -0
  22. package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +153 -0
  23. package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +119 -0
  24. package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +141 -0
  25. package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +70 -0
  26. package/dist/components/presentation/SignIn/BaseSignIn.d.ts +29 -40
  27. package/dist/components/presentation/SignIn/SignIn.d.ts +2 -1
  28. package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +4 -4
  29. package/dist/components/presentation/SignIn/types.d.ts +6 -6
  30. package/dist/components/presentation/SignUp/BaseSignUp.d.ts +126 -0
  31. package/dist/components/presentation/SignUp/SignUp.d.ts +55 -0
  32. package/dist/components/presentation/SignUp/options/CheckboxInput.d.ts +24 -0
  33. package/dist/components/presentation/SignUp/options/DateInput.d.ts +24 -0
  34. package/dist/components/presentation/SignUp/options/DividerComponent.d.ts +24 -0
  35. package/dist/components/presentation/SignUp/options/EmailInput.d.ts +24 -0
  36. package/dist/components/presentation/SignUp/options/FormContainer.d.ts +24 -0
  37. package/dist/components/presentation/SignUp/options/GoogleButton.d.ts +25 -0
  38. package/dist/components/presentation/SignUp/options/ImageComponent.d.ts +24 -0
  39. package/dist/components/presentation/SignUp/options/NumberInput.d.ts +24 -0
  40. package/dist/components/presentation/SignUp/options/PasswordInput.d.ts +24 -0
  41. package/dist/components/presentation/SignUp/options/SignUpOptionFactory.d.ts +100 -0
  42. package/dist/components/presentation/SignUp/options/SocialButton.d.ts +24 -0
  43. package/dist/components/presentation/SignUp/options/SubmitButton.d.ts +24 -0
  44. package/dist/components/presentation/SignUp/options/TelephoneInput.d.ts +24 -0
  45. package/dist/components/presentation/SignUp/options/TextInput.d.ts +24 -0
  46. package/dist/components/presentation/SignUp/options/Typography.d.ts +24 -0
  47. package/dist/components/presentation/SignUp/options/index.d.ts +26 -0
  48. package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +34 -22
  49. package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +60 -4
  50. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +17 -15
  51. package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
  52. package/dist/components/primitives/Avatar/Avatar.d.ts +21 -8
  53. package/dist/components/primitives/Card/Card.d.ts +8 -9
  54. package/dist/components/primitives/Divider/Divider.d.ts +8 -8
  55. package/dist/components/primitives/Icons/Building.d.ts +40 -0
  56. package/dist/components/primitives/Icons/BuildingAlt.d.ts +40 -0
  57. package/dist/components/primitives/Icons/Check.d.ts +40 -0
  58. package/dist/components/primitives/Icons/ChevronDown.d.ts +40 -0
  59. package/dist/components/primitives/Icons/LogOut.d.ts +23 -0
  60. package/dist/components/primitives/Icons/Plus.d.ts +23 -0
  61. package/dist/components/primitives/Icons/Settings.d.ts +0 -0
  62. package/dist/components/primitives/Icons/User.d.ts +23 -0
  63. package/dist/components/primitives/Icons/X.d.ts +23 -0
  64. package/dist/components/primitives/Icons/index.d.ts +27 -0
  65. package/dist/components/primitives/KeyValueInput/KeyValueInput.d.ts +123 -0
  66. package/dist/components/primitives/KeyValueInput/index.d.ts +0 -0
  67. package/dist/components/primitives/Popover/Popover.d.ts +19 -19
  68. package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +3 -2
  69. package/dist/contexts/Organization/OrganizationContext.d.ts +74 -0
  70. package/dist/contexts/Organization/OrganizationProvider.d.ts +90 -0
  71. package/dist/contexts/Organization/useOrganization.d.ts +104 -0
  72. package/dist/contexts/Theme/types.d.ts +38 -9
  73. package/dist/contexts/User/UserContext.d.ts +3 -2
  74. package/dist/contexts/User/UserProvider.d.ts +2 -1
  75. package/dist/hooks/useForm.d.ts +52 -52
  76. package/dist/index.d.ts +39 -0
  77. package/dist/index.js +9605 -16988
  78. package/dist/index.js.map +4 -4
  79. package/package.json +1 -1
@@ -0,0 +1,23 @@
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, SVGProps } from 'react';
19
+ /**
20
+ * X (close) icon component.
21
+ */
22
+ declare const X: FC<SVGProps<SVGSVGElement>>;
23
+ export default X;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export { default as CircleAlert } from './CircleAlert';
19
+ export { default as CircleCheck } from './CircleCheck';
20
+ export { default as Eye } from './Eye';
21
+ export { default as EyeOff } from './EyeOff';
22
+ export { default as Info } from './Info';
23
+ export { default as LogOut } from './LogOut';
24
+ export { default as Plus } from './Plus';
25
+ export { default as TriangleAlert } from './TriangleAlert';
26
+ export { default as User } from './User';
27
+ export { default as X } from './X';
@@ -0,0 +1,123 @@
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
+ export interface KeyValuePair {
20
+ key: string;
21
+ value: string;
22
+ }
23
+ export interface KeyValueInputProps {
24
+ /**
25
+ * CSS class name for styling the component.
26
+ */
27
+ className?: string;
28
+ /**
29
+ * Whether the input is disabled.
30
+ */
31
+ disabled?: boolean;
32
+ /**
33
+ * Error message to display.
34
+ */
35
+ error?: string;
36
+ /**
37
+ * Help text to display below the input.
38
+ */
39
+ helperText?: string;
40
+ /**
41
+ * Label for the key input field.
42
+ */
43
+ keyLabel?: string;
44
+ /**
45
+ * Placeholder text for the key input field.
46
+ */
47
+ keyPlaceholder?: string;
48
+ /**
49
+ * Label for the component.
50
+ */
51
+ label?: string;
52
+ /**
53
+ * Maximum number of key-value pairs allowed.
54
+ */
55
+ maxPairs?: number;
56
+ /**
57
+ * Callback fired when the key-value pairs change.
58
+ */
59
+ onChange?: (pairs: KeyValuePair[]) => void;
60
+ /**
61
+ * Callback fired when a pair is added.
62
+ */
63
+ onAdd?: (pair: KeyValuePair) => void;
64
+ /**
65
+ * Callback fired when a pair is removed.
66
+ */
67
+ onRemove?: (pair: KeyValuePair, index: number) => void;
68
+ /**
69
+ * Whether the component is in read-only mode.
70
+ */
71
+ readOnly?: boolean;
72
+ /**
73
+ * Text for the remove button.
74
+ */
75
+ removeButtonText?: string;
76
+ /**
77
+ * Whether the component is required.
78
+ */
79
+ required?: boolean;
80
+ /**
81
+ * Current key-value pairs.
82
+ */
83
+ value?: Record<string, any> | KeyValuePair[];
84
+ /**
85
+ * Label for the value input field.
86
+ */
87
+ valueLabel?: string;
88
+ /**
89
+ * Placeholder text for the value input field.
90
+ */
91
+ valuePlaceholder?: string;
92
+ }
93
+ /**
94
+ * KeyValueInput component allows users to manage key-value pairs with add/remove functionality.
95
+ * It provides a user-friendly interface for editing organization attributes or similar data structures.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * // Basic usage
100
+ * <KeyValueInput
101
+ * label="Organization Attributes"
102
+ * onChange={(pairs) => console.log(pairs)}
103
+ * />
104
+ *
105
+ * // With initial values
106
+ * <KeyValueInput
107
+ * label="Organization Attributes"
108
+ * value={{department: 'IT', location: 'New York'}}
109
+ * onChange={(pairs) => console.log(pairs)}
110
+ * />
111
+ *
112
+ * // With add/remove callbacks
113
+ * <KeyValueInput
114
+ * label="Custom Attributes"
115
+ * value={attributes}
116
+ * onChange={(pairs) => setAttributes(pairs)}
117
+ * onAdd={(pair) => console.log('Added:', pair)}
118
+ * onRemove={(pair, index) => console.log('Removed:', pair, 'at index:', index)}
119
+ * />
120
+ * ```
121
+ */
122
+ declare const KeyValueInput: FC<KeyValueInputProps>;
123
+ export default KeyValueInput;
@@ -15,36 +15,36 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import React from 'react';
19
18
  import { UseFloatingReturn, UseInteractionsReturn } from '@floating-ui/react';
19
+ import React from 'react';
20
20
  interface DialogOptions {
21
21
  initialOpen?: boolean;
22
- open?: boolean;
23
22
  onOpenChange?: (open: boolean) => void;
23
+ open?: boolean;
24
24
  }
25
25
  interface DialogHookReturn extends UseFloatingReturn, UseInteractionsReturn {
26
- open: boolean;
27
- setOpen: (open: boolean) => void;
28
- labelId: string | undefined;
29
26
  descriptionId: string | undefined;
30
- setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
27
+ labelId: string | undefined;
28
+ open: boolean;
31
29
  setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
30
+ setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
31
+ setOpen: (open: boolean) => void;
32
32
  }
33
33
  export declare function useDialog({ initialOpen, open: controlledOpen, onOpenChange: setControlledOpen, }?: DialogOptions): DialogHookReturn;
34
34
  interface PopoverOptions {
35
35
  initialOpen?: boolean;
36
- open?: boolean;
36
+ offset?: number;
37
37
  onOpenChange?: (open: boolean) => void;
38
+ open?: boolean;
38
39
  placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
39
- offset?: number;
40
40
  }
41
41
  interface PopoverHookReturn extends UseFloatingReturn, UseInteractionsReturn {
42
- open: boolean;
43
- setOpen: (open: boolean) => void;
44
- labelId: string | undefined;
45
42
  descriptionId: string | undefined;
46
- setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
43
+ labelId: string | undefined;
44
+ open: boolean;
47
45
  setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
46
+ setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
47
+ setOpen: (open: boolean) => void;
48
48
  }
49
49
  export declare function usePopover({ initialOpen, open: controlledOpen, onOpenChange: setControlledOpen, placement, offset: offsetValue, }?: PopoverOptions): PopoverHookReturn;
50
50
  export declare const useDialogContext: () => DialogHookReturn;
@@ -53,8 +53,8 @@ export declare function Dialog({ children, ...options }: {
53
53
  children: React.ReactNode;
54
54
  } & DialogOptions): import("react/jsx-runtime").JSX.Element;
55
55
  interface DialogTriggerProps {
56
- children: React.ReactNode;
57
56
  asChild?: boolean;
57
+ children: React.ReactNode;
58
58
  }
59
59
  export declare const DialogTrigger: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement> & DialogTriggerProps, "ref"> & React.RefAttributes<HTMLElement>>;
60
60
  export declare const DialogContent: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -62,8 +62,8 @@ export declare function Popover({ children, ...options }: {
62
62
  children: React.ReactNode;
63
63
  } & PopoverOptions): import("react/jsx-runtime").JSX.Element;
64
64
  interface PopoverTriggerProps {
65
- children: React.ReactNode;
66
65
  asChild?: boolean;
66
+ children: React.ReactNode;
67
67
  }
68
68
  export declare const PopoverTrigger: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement> & PopoverTriggerProps, "ref"> & React.RefAttributes<HTMLElement>>;
69
69
  export declare const PopoverContent: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -74,14 +74,14 @@ export declare const DialogDescription: React.ForwardRefExoticComponent<Omit<Rea
74
74
  export declare const PopoverClose: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
75
75
  export declare const DialogClose: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
76
76
  interface LegacyPopoverProps {
77
- isOpen: boolean;
78
77
  children: React.ReactNode;
79
- onClose: () => void;
80
78
  className?: string;
79
+ isOpen: boolean;
81
80
  mode?: 'modal' | 'dropdown';
82
- trigger?: HTMLElement | null;
83
- placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
84
81
  offset?: number;
82
+ onClose: () => void;
83
+ placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
84
+ trigger?: HTMLElement | null;
85
85
  }
86
86
  declare const LegacyPopoverHeader: React.FC<{
87
87
  children?: React.ReactNode;
@@ -90,7 +90,7 @@ declare const LegacyPopoverContent: React.FC<{
90
90
  children: React.ReactNode;
91
91
  }>;
92
92
  export declare const LegacyPopover: React.FC<LegacyPopoverProps> & {
93
- Header: typeof LegacyPopoverHeader;
94
93
  Content: typeof LegacyPopoverContent;
94
+ Header: typeof LegacyPopoverHeader;
95
95
  };
96
96
  export default LegacyPopover;
@@ -20,6 +20,9 @@ import { Context } from 'react';
20
20
  * Props interface of {@link AsgardeoContext}
21
21
  */
22
22
  export type AsgardeoContextProps = {
23
+ afterSignInUrl: string;
24
+ baseUrl: string;
25
+ isInitialized: boolean;
23
26
  /**
24
27
  * Flag indicating whether the SDK is working in the background.
25
28
  */
@@ -47,8 +50,6 @@ export type AsgardeoContextProps = {
47
50
  */
48
51
  signUp: any;
49
52
  user: any;
50
- baseUrl: string;
51
- afterSignInUrl: string;
52
53
  };
53
54
  /**
54
55
  * Context object for managing the Authentication flow builder core context.
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '@asgardeo/browser';
19
+ import { Context } from 'react';
20
+ /**
21
+ * Interface for organizations with switch access information.
22
+ */
23
+ export interface OrganizationWithSwitchAccess extends Organization {
24
+ /**
25
+ * Whether the user has switch access to this organization
26
+ */
27
+ canSwitch: boolean;
28
+ }
29
+ /**
30
+ * Props interface of {@link OrganizationContext}
31
+ */
32
+ export type OrganizationContextProps = {
33
+ currentOrganization: Organization | null;
34
+ error: string | null;
35
+ getOrganizations: () => Promise<Organization[]>;
36
+ isLoading: boolean;
37
+ organizations: Organization[] | null;
38
+ revalidateOrganizations: () => Promise<void>;
39
+ switchOrganization: (organization: Organization) => Promise<void>;
40
+ /**
41
+ * Paginated organizations with switch access information
42
+ */
43
+ paginatedOrganizations: OrganizationWithSwitchAccess[];
44
+ /**
45
+ * Whether there are more organizations to load
46
+ */
47
+ hasMore: boolean;
48
+ /**
49
+ * Whether more data is being loaded
50
+ */
51
+ isLoadingMore: boolean;
52
+ /**
53
+ * Total number of organizations
54
+ */
55
+ totalCount: number;
56
+ /**
57
+ * Function to fetch more organizations (pagination)
58
+ */
59
+ fetchMore: () => Promise<void>;
60
+ /**
61
+ * Function to fetch paginated organizations with switch access
62
+ */
63
+ fetchPaginatedOrganizations: (config?: {
64
+ filter?: string;
65
+ limit?: number;
66
+ recursive?: boolean;
67
+ reset?: boolean;
68
+ }) => Promise<void>;
69
+ };
70
+ /**
71
+ * Context object for managing organization data and related operations.
72
+ */
73
+ declare const OrganizationContext: Context<OrganizationContextProps | null>;
74
+ export default OrganizationContext;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '@asgardeo/browser';
19
+ import { FC, PropsWithChildren } from 'react';
20
+ /**
21
+ * Props interface of {@link OrganizationProvider}
22
+ */
23
+ export interface OrganizationProviderProps {
24
+ /**
25
+ * Whether to automatically fetch organizations on mount
26
+ */
27
+ autoFetch?: boolean;
28
+ /**
29
+ * Initial current organization
30
+ */
31
+ currentOrganization?: Organization | null;
32
+ /**
33
+ * Function to fetch organizations
34
+ */
35
+ getOrganizations: () => Promise<Organization[]>;
36
+ /**
37
+ * Callback function called when an error occurs
38
+ */
39
+ onError?: (error: string) => void;
40
+ /**
41
+ * Callback function called when switching organizations
42
+ */
43
+ onOrganizationSwitch?: (organization: Organization) => Promise<void>;
44
+ /**
45
+ * Initial list of organizations
46
+ */
47
+ organizations?: Organization[] | null;
48
+ }
49
+ /**
50
+ * OrganizationProvider component that manages organization data and provides it through OrganizationContext.
51
+ *
52
+ * This provider:
53
+ * - Fetches organization data from the organizations endpoint
54
+ * - Manages current organization state
55
+ * - Provides functions for switching organizations and refreshing data
56
+ * - Handles loading states and errors
57
+ * - Accepts a custom getOrganizations function for flexible data fetching
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * // Basic usage with auto-fetch (uses internal API)
62
+ * <OrganizationProvider>
63
+ * <App />
64
+ * </OrganizationProvider>
65
+ *
66
+ * // With custom getOrganizations function
67
+ * <OrganizationProvider getOrganizations={async () => asgardeo.getOrganizations()}>
68
+ * <App />
69
+ * </OrganizationProvider>
70
+ *
71
+ * // With custom error handling
72
+ * <OrganizationProvider onError={(error) => console.error('Organization error:', error)}>
73
+ * <App />
74
+ * </OrganizationProvider>
75
+ *
76
+ * // With custom organization switch handler
77
+ * <OrganizationProvider
78
+ * onOrganizationSwitch={(org) => console.log('Switched to:', org.name)}
79
+ * >
80
+ * <App />
81
+ * </OrganizationProvider>
82
+ *
83
+ * // Disable auto-fetch (fetch manually using revalidateOrganizations)
84
+ * <OrganizationProvider autoFetch={false}>
85
+ * <App />
86
+ * </OrganizationProvider>
87
+ * ```
88
+ */
89
+ declare const OrganizationProvider: FC<PropsWithChildren<OrganizationProviderProps>>;
90
+ export default OrganizationProvider;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { OrganizationContextProps } from './OrganizationContext';
19
+ /**
20
+ * Hook to access the Organization context.
21
+ *
22
+ * This hook provides access to organization data including:
23
+ * - List of organizations the user belongs to
24
+ * - Current organization
25
+ * - Functions to switch organizations and refresh data
26
+ * - Function to fetch organizations programmatically
27
+ * - Loading states and error handling
28
+ *
29
+ * @returns {OrganizationContextProps} The organization context value containing all organization-related data and functions
30
+ * @throws {Error} Throws an error if used outside of OrganizationProvider
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import {useOrganization} from '@asgardeo/react';
35
+ *
36
+ * function OrganizationSelector() {
37
+ * const {
38
+ * organizations,
39
+ * currentOrganization,
40
+ * switchOrganization,
41
+ * revalidateOrganizations,
42
+ * getOrganizations,
43
+ * isLoading,
44
+ * error
45
+ * } = useOrganization();
46
+ *
47
+ * if (isLoading) {
48
+ * return <div>Loading organizations...</div>;
49
+ * }
50
+ *
51
+ * if (error) {
52
+ * return <div>Error: {error}</div>;
53
+ * }
54
+ *
55
+ * return (
56
+ * <div>
57
+ * <h2>Current: {currentOrganization?.name}</h2>
58
+ * <select
59
+ * value={currentOrganization?.id || ''}
60
+ * onChange={(e) => {
61
+ * const org = organizations?.find(o => o.id === e.target.value);
62
+ * if (org) switchOrganization(org);
63
+ * }}
64
+ * >
65
+ * {organizations?.map(org => (
66
+ * <option key={org.id} value={org.id}>
67
+ * {org.name}
68
+ * </option>
69
+ * ))}
70
+ * </select>
71
+ * <button onClick={revalidateOrganizations}>
72
+ * Refresh Organizations
73
+ * </button>
74
+ * <button onClick={async () => {
75
+ * const fresh = await getOrganizations();
76
+ * console.log('Fresh organizations:', fresh);
77
+ * }}>
78
+ * Get Organizations Manually
79
+ * </button>
80
+ * </div>
81
+ * );
82
+ * }
83
+ *
84
+ * // Switch to a specific organization
85
+ * function SwitchOrgButton() {
86
+ * const {organizations, switchOrganization} = useOrganization();
87
+ *
88
+ * const handleSwitch = (orgId: string) => {
89
+ * const org = organizations?.find(o => o.id === orgId);
90
+ * if (org) {
91
+ * switchOrganization(org);
92
+ * }
93
+ * };
94
+ *
95
+ * return (
96
+ * <button onClick={() => handleSwitch('org-123')}>
97
+ * Switch to Organization
98
+ * </button>
99
+ * );
100
+ * }
101
+ * ```
102
+ */
103
+ declare const useOrganization: () => OrganizationContextProps;
104
+ export default useOrganization;
@@ -16,24 +16,53 @@
16
16
  * under the License.
17
17
  */
18
18
  export interface ThemeColors {
19
- primary: string;
20
- background: string;
21
- surface: string;
19
+ background: {
20
+ body: {
21
+ main: string;
22
+ };
23
+ disabled: string;
24
+ surface: string;
25
+ };
26
+ border: string;
27
+ error: {
28
+ contrastText: string;
29
+ main: string;
30
+ };
31
+ primary: {
32
+ contrastText: string;
33
+ main: string;
34
+ };
35
+ secondary: {
36
+ contrastText: string;
37
+ main: string;
38
+ };
39
+ success: {
40
+ contrastText: string;
41
+ main: string;
42
+ };
22
43
  text: {
23
44
  primary: string;
24
45
  secondary: string;
25
46
  };
26
- border: string;
47
+ warning: {
48
+ contrastText: string;
49
+ main: string;
50
+ };
27
51
  }
28
52
  export interface ThemeConfig {
29
- colors: ThemeColors;
30
- spacing: {
31
- unit: number;
32
- };
33
53
  borderRadius: {
34
- small: string;
54
+ large: string;
35
55
  medium: string;
56
+ small: string;
57
+ };
58
+ colors: ThemeColors;
59
+ shadows: {
36
60
  large: string;
61
+ medium: string;
62
+ small: string;
63
+ };
64
+ spacing: {
65
+ unit: number;
37
66
  };
38
67
  }
39
68
  export interface Theme extends ThemeConfig {
@@ -15,15 +15,16 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { Context } from 'react';
19
18
  import { User, Schema } from '@asgardeo/browser';
19
+ import { Context } from 'react';
20
20
  /**
21
21
  * Props interface of {@link UserContext}
22
22
  */
23
23
  export type UserContextProps = {
24
+ flattenedProfile: User | null;
24
25
  profile: User | null;
26
+ revalidateProfile: () => Promise<void>;
25
27
  schemas: Schema[] | null;
26
- flattenedProfile: User | null;
27
28
  };
28
29
  /**
29
30
  * Context object for managing user profile data and related operations.
@@ -15,13 +15,14 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FC, PropsWithChildren } from 'react';
19
18
  import { UserProfile } from '@asgardeo/browser';
19
+ import { FC, PropsWithChildren } from 'react';
20
20
  /**
21
21
  * Props interface of {@link UserProvider}
22
22
  */
23
23
  export interface UserProviderProps {
24
24
  profile: UserProfile;
25
+ revalidateProfile?: () => Promise<void>;
25
26
  }
26
27
  /**
27
28
  * UserProvider component that manages user profile data and provides it through UserContext.