@asgardeo/react 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -6
- package/dist/AsgardeoReactClient.d.ts +37 -0
- package/dist/__temp__/api.d.ts +229 -0
- package/dist/__temp__/models.d.ts +105 -0
- package/dist/api/scim2/getMeProfile.d.ts +39 -0
- package/dist/api/scim2/getSchemas.d.ts +39 -0
- package/dist/api/scim2/updateMeProfile.d.ts +38 -0
- package/dist/cjs/index.js +1955 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +65 -0
- package/dist/components/actions/SignInButton/SignInButton.d.ts +46 -0
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +65 -0
- package/dist/components/actions/SignOutButton/SignOutButton.d.ts +44 -0
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +65 -0
- package/dist/components/actions/SignUpButton/SignUpButton.d.ts +45 -0
- package/dist/components/control/SignedIn.d.ts +45 -0
- package/dist/components/control/SignedOut.d.ts +45 -0
- package/dist/components/presentation/User.d.ts +57 -0
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +76 -0
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +49 -0
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +42 -0
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +49 -0
- package/dist/{esm/types/components/SignIn/SignIn.d.ts → components/primitives/Avatar/Avatar.d.ts} +25 -14
- package/dist/{esm/types/oxygen-ui-react-auth-components/models/component.d.ts → components/primitives/Checkbox/Checkbox.d.ts} +22 -7
- package/dist/components/primitives/DatePicker/DatePicker.d.ts +50 -0
- package/dist/components/primitives/Popover/Popover.d.ts +59 -0
- package/dist/components/primitives/Select/Select.d.ts +60 -0
- package/dist/components/primitives/TextField/TextField.d.ts +46 -0
- package/dist/contexts/AsgardeoContext.d.ts +56 -0
- package/dist/{esm/types/contexts/i18n-context.d.ts → hooks/useAsgardeo.d.ts} +4 -5
- package/dist/hooks/useBrowserUrl.d.ts +47 -0
- package/dist/index.d.ts +36 -348
- package/dist/index.js +1935 -0
- package/dist/index.js.map +7 -0
- package/dist/{esm/types/oxygen-ui-react-auth-components/index.d.ts → models/config.d.ts} +3 -3
- package/dist/{esm/types/hooks/use-config.d.ts → providers/AsgardeoProvider.d.ts} +7 -5
- package/dist/{esm/types/models/asgardeo-provider-props.d.ts → theme/ThemeContext.d.ts} +8 -7
- package/dist/{esm/types/models/branding-preference-provider-props.d.ts → theme/ThemeProvider.d.ts} +7 -5
- package/dist/{esm/types/models/use-on.d.ts → theme/types.d.ts} +22 -12
- package/dist/{esm/types/models/public-models.d.ts → theme/useTheme.d.ts} +3 -3
- package/dist/{esm/types/models/signed-props.d.ts → utils/getMappedUserProfileValue.d.ts} +3 -6
- package/dist/utils/getUserProfile.d.ts +59 -0
- package/package.json +55 -60
- package/dist/esm/index.js +0 -45278
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types/components/SignIn/fragments/BasicAuth.d.ts +0 -35
- package/dist/esm/types/components/SignIn/fragments/EmailOtp.d.ts +0 -32
- package/dist/esm/types/components/SignIn/fragments/IdentifierFirst.d.ts +0 -35
- package/dist/esm/types/components/SignIn/fragments/LoginOptionsBox.d.ts +0 -30
- package/dist/esm/types/components/SignIn/fragments/SmsOtp.d.ts +0 -21
- package/dist/esm/types/components/SignIn/fragments/Totp.d.ts +0 -33
- package/dist/esm/types/components/SignInButton/SignInButton.d.ts +0 -29
- package/dist/esm/types/components/SignOutButton/SignOutButton.d.ts +0 -27
- package/dist/esm/types/components/SignedIn/SignedIn.d.ts +0 -29
- package/dist/esm/types/components/SignedOut/SignedOut.d.ts +0 -29
- package/dist/esm/types/components/public-components.d.ts +0 -22
- package/dist/esm/types/contexts/asgardeo-context.d.ts +0 -21
- package/dist/esm/types/contexts/branding-preference-context.d.ts +0 -21
- package/dist/esm/types/hooks/use-authentication.d.ts +0 -27
- package/dist/esm/types/hooks/use-on.d.ts +0 -20
- package/dist/esm/types/hooks/use-translations.d.ts +0 -33
- package/dist/esm/types/index.d.ts +0 -22
- package/dist/esm/types/models/auth-context.d.ts +0 -43
- package/dist/esm/types/models/basic-auth-props.d.ts +0 -29
- package/dist/esm/types/models/email-otp-props.d.ts +0 -26
- package/dist/esm/types/models/i18n.d.ts +0 -34
- package/dist/esm/types/models/jwt-verify-options.d.ts +0 -25
- package/dist/esm/types/models/login-options-box-props.d.ts +0 -24
- package/dist/esm/types/models/sign-in.d.ts +0 -49
- package/dist/esm/types/models/totp-props.d.ts +0 -26
- package/dist/esm/types/models/use-authentication.d.ts +0 -29
- package/dist/esm/types/models/use-config.d.ts +0 -22
- package/dist/esm/types/models/use-translations.d.ts +0 -22
- package/dist/esm/types/oxygen-ui-react-auth-components/SignIn/SignIn.d.ts +0 -79
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.d.ts +0 -37
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInButton/SignInButton.d.ts +0 -27
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.d.ts +0 -29
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInImage/SignInImage.d.ts +0 -23
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInLink/SignInLink.d.ts +0 -25
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.d.ts +0 -30
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.d.ts +0 -32
- package/dist/esm/types/providers/AsgardeoProvider.d.ts +0 -34
- package/dist/esm/types/providers/BrandingPreferenceProvider.d.ts +0 -32
- package/dist/esm/types/providers/I18nProvider.d.ts +0 -33
- package/dist/esm/types/theme/generate-theme-sign-in.d.ts +0 -28
- package/dist/esm/types/theme/generate-theme.d.ts +0 -30
- package/dist/esm/types/utils/crypto-utils.d.ts +0 -52
- package/dist/esm/types/utils/session-store.d.ts +0 -25
|
@@ -0,0 +1,1955 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
|
|
32
|
+
// src/index.ts
|
|
33
|
+
var index_exports = {};
|
|
34
|
+
__export(index_exports, {
|
|
35
|
+
AsgardeoContext: () => AsgardeoContext_default,
|
|
36
|
+
AsgardeoProvider: () => AsgardeoProvider_default,
|
|
37
|
+
BaseSignInButton: () => BaseSignInButton_default,
|
|
38
|
+
BaseSignOutButton: () => BaseSignOutButton_default,
|
|
39
|
+
BaseSignUpButton: () => BaseSignUpButton_default,
|
|
40
|
+
BaseUserDropdown: () => BaseUserDropdown_default,
|
|
41
|
+
BaseUserProfile: () => BaseUserProfile_default,
|
|
42
|
+
SignInButton: () => SignInButton_default,
|
|
43
|
+
SignOutButton: () => SignOutButton_default,
|
|
44
|
+
SignUpButton: () => SignUpButton_default,
|
|
45
|
+
SignedIn: () => SignedIn_default,
|
|
46
|
+
SignedOut: () => SignedOut_default,
|
|
47
|
+
User: () => User_default,
|
|
48
|
+
UserDropdown: () => UserDropdown_default,
|
|
49
|
+
UserProfile: () => UserProfile_default,
|
|
50
|
+
useAsgardeo: () => useAsgardeo_default,
|
|
51
|
+
useBrowserUrl: () => useBrowserUrl_default
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(index_exports);
|
|
54
|
+
|
|
55
|
+
// src/providers/AsgardeoProvider.tsx
|
|
56
|
+
var import_react4 = require("react");
|
|
57
|
+
|
|
58
|
+
// src/AsgardeoReactClient.ts
|
|
59
|
+
var import_browser5 = require("@asgardeo/browser");
|
|
60
|
+
|
|
61
|
+
// src/__temp__/api.ts
|
|
62
|
+
var import_browser = require("@asgardeo/browser");
|
|
63
|
+
var _AuthAPI = class _AuthAPI {
|
|
64
|
+
constructor(spaClient) {
|
|
65
|
+
__publicField(this, "_authState", _AuthAPI.DEFAULT_STATE);
|
|
66
|
+
__publicField(this, "_client");
|
|
67
|
+
__publicField(this, "_isLoading");
|
|
68
|
+
this._client = spaClient ?? import_browser.AsgardeoSPAClient.getInstance();
|
|
69
|
+
this.getState = this.getState.bind(this);
|
|
70
|
+
this.init = this.init.bind(this);
|
|
71
|
+
this.signIn = this.signIn.bind(this);
|
|
72
|
+
this.signOut = this.signOut.bind(this);
|
|
73
|
+
this.updateState = this.updateState.bind(this);
|
|
74
|
+
}
|
|
75
|
+
_setIsLoading(isLoading) {
|
|
76
|
+
this._isLoading = isLoading;
|
|
77
|
+
}
|
|
78
|
+
_getIsLoading() {
|
|
79
|
+
return this._isLoading;
|
|
80
|
+
}
|
|
81
|
+
isSignedIn() {
|
|
82
|
+
return this.isAuthenticated();
|
|
83
|
+
}
|
|
84
|
+
isLoading() {
|
|
85
|
+
return this._getIsLoading();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Method to return Auth Client instance authentication state.
|
|
89
|
+
*
|
|
90
|
+
* @return {AuthStateInterface} Authentication State.
|
|
91
|
+
*/
|
|
92
|
+
getState() {
|
|
93
|
+
return this._authState;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Method to initialize the AuthClient instance.
|
|
97
|
+
*
|
|
98
|
+
* @param {Config} config - `dispatch` function from React Auth Context.
|
|
99
|
+
*/
|
|
100
|
+
async init(config) {
|
|
101
|
+
return await this._client.initialize(config);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Method to get the configuration data.
|
|
105
|
+
*
|
|
106
|
+
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
107
|
+
*/
|
|
108
|
+
async getConfigData() {
|
|
109
|
+
return await this._client.getConfigData();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Method to handle user Sign In requests.
|
|
113
|
+
*
|
|
114
|
+
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
115
|
+
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
116
|
+
* @param {any} callback - Action to trigger on successful sign in.
|
|
117
|
+
*/
|
|
118
|
+
async signIn(config, authorizationCode, sessionState, authState, callback, tokenRequestConfig) {
|
|
119
|
+
return this._client.signIn(config, authorizationCode, sessionState, authState, tokenRequestConfig).then(async (response) => {
|
|
120
|
+
if (!response) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (await this._client.isAuthenticated()) {
|
|
124
|
+
const stateToUpdate = {
|
|
125
|
+
allowedScopes: response.allowedScopes,
|
|
126
|
+
displayName: response.displayName,
|
|
127
|
+
email: response.email,
|
|
128
|
+
isAuthenticated: true,
|
|
129
|
+
isLoading: false,
|
|
130
|
+
isSigningOut: false,
|
|
131
|
+
sub: response.sub,
|
|
132
|
+
username: response.username
|
|
133
|
+
};
|
|
134
|
+
this.updateState(stateToUpdate);
|
|
135
|
+
this._setIsLoading(false);
|
|
136
|
+
if (callback) {
|
|
137
|
+
callback(response);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return response;
|
|
141
|
+
}).catch((error) => {
|
|
142
|
+
return Promise.reject(error);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Method to handle user Sign Out requests.
|
|
147
|
+
*
|
|
148
|
+
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
149
|
+
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
150
|
+
* @param {any} callback - Action to trigger on successful sign out.
|
|
151
|
+
*/
|
|
152
|
+
signOut(callback) {
|
|
153
|
+
return this._client.signOut().then((response) => {
|
|
154
|
+
if (callback) {
|
|
155
|
+
callback(response);
|
|
156
|
+
}
|
|
157
|
+
return response;
|
|
158
|
+
}).catch((error) => {
|
|
159
|
+
return Promise.reject(error);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Method to update Auth Client instance authentication state.
|
|
164
|
+
*
|
|
165
|
+
* @param {AuthStateInterface} state - State values to update in authentication state.
|
|
166
|
+
*/
|
|
167
|
+
updateState(state) {
|
|
168
|
+
this._authState = { ...this._authState, ...state };
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* This method returns a Promise that resolves with the basic user information obtained from the ID token.
|
|
172
|
+
*
|
|
173
|
+
* @return {Promise<BasicUserInfo>} - A promise that resolves with the user information.
|
|
174
|
+
*/
|
|
175
|
+
async getBasicUserInfo() {
|
|
176
|
+
return this._client.getBasicUserInfo();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* This method sends an API request to a protected endpoint.
|
|
180
|
+
* The access token is automatically attached to the header of the request.
|
|
181
|
+
* This is the only way by which protected endpoints can be accessed
|
|
182
|
+
* when the web worker is used to store session information.
|
|
183
|
+
*
|
|
184
|
+
* @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
|
|
185
|
+
*
|
|
186
|
+
* @return {Promise<FetchResponse>} - Returns a Promise that resolves with the response to the request.
|
|
187
|
+
*/
|
|
188
|
+
async httpRequest(config) {
|
|
189
|
+
return this._client.httpRequest(config);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* This method sends multiple API requests to a protected endpoint.
|
|
193
|
+
* The access token is automatically attached to the header of the request.
|
|
194
|
+
* This is the only way by which multiple requests can be sent to protected endpoints
|
|
195
|
+
* when the web worker is used to store session information.
|
|
196
|
+
*
|
|
197
|
+
* @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
|
|
198
|
+
*
|
|
199
|
+
* @return {Promise<FetchResponse[]>} - Returns a Promise that resolves with the responses to the requests.
|
|
200
|
+
*/
|
|
201
|
+
async httpRequestAll(configs) {
|
|
202
|
+
return this._client.httpRequestAll(configs);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* This method allows you to send a request with a custom grant.
|
|
206
|
+
*
|
|
207
|
+
* @param {CustomGrantRequestParams} config - The request parameters.
|
|
208
|
+
*
|
|
209
|
+
* @return {Promise<FetchResponse<any> | SignInResponse>} - A Promise that resolves with
|
|
210
|
+
* the value returned by the custom grant request.
|
|
211
|
+
*/
|
|
212
|
+
requestCustomGrant(config, callback, dispatch) {
|
|
213
|
+
return this._client.requestCustomGrant(config).then((response) => {
|
|
214
|
+
if (!response) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
if (config.returnsSession) {
|
|
218
|
+
this.updateState({
|
|
219
|
+
...this.getState(),
|
|
220
|
+
...response,
|
|
221
|
+
isAuthenticated: true,
|
|
222
|
+
isLoading: false
|
|
223
|
+
});
|
|
224
|
+
dispatch({ ...response, isAuthenticated: true, isLoading: false });
|
|
225
|
+
}
|
|
226
|
+
callback && callback(response);
|
|
227
|
+
return response;
|
|
228
|
+
}).catch((error) => {
|
|
229
|
+
return Promise.reject(error);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
234
|
+
*
|
|
235
|
+
* @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
|
|
236
|
+
*/
|
|
237
|
+
async revokeAccessToken(dispatch) {
|
|
238
|
+
return this._client.revokeAccessToken().then(() => {
|
|
239
|
+
this.updateState({ ..._AuthAPI.DEFAULT_STATE, isLoading: false });
|
|
240
|
+
dispatch(_AuthAPI.DEFAULT_STATE);
|
|
241
|
+
return true;
|
|
242
|
+
}).catch((error) => {
|
|
243
|
+
return Promise.reject(error);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* This method returns a Promise that resolves with an object containing the service endpoints.
|
|
248
|
+
*
|
|
249
|
+
* @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
|
|
250
|
+
*/
|
|
251
|
+
async getOIDCServiceEndpoints() {
|
|
252
|
+
return this._client.getOIDCServiceEndpoints();
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* This methods returns the Axios http client.
|
|
256
|
+
*
|
|
257
|
+
* @return {HttpClientInstance} - The Axios HTTP client.
|
|
258
|
+
*/
|
|
259
|
+
async getHttpClient() {
|
|
260
|
+
return this._client.getHttpClient();
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* This method decodes the payload of the id token and returns it.
|
|
264
|
+
*
|
|
265
|
+
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
266
|
+
* the decoded payload of the id token.
|
|
267
|
+
*/
|
|
268
|
+
async getDecodedIDToken() {
|
|
269
|
+
return this._client.getDecodedIDToken();
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* This method decodes the payload of the idp id token and returns it.
|
|
273
|
+
*
|
|
274
|
+
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
275
|
+
* the decoded payload of the idp id token.
|
|
276
|
+
*/
|
|
277
|
+
async getDecodedIDPIDToken() {
|
|
278
|
+
return this._client.getDecodedIDToken();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* This method returns the ID token.
|
|
282
|
+
*
|
|
283
|
+
* @return {Promise<string>} - A Promise that resolves with the id token.
|
|
284
|
+
*/
|
|
285
|
+
async getIDToken() {
|
|
286
|
+
return this._client.getIDToken();
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* This method return a Promise that resolves with the access token.
|
|
290
|
+
*
|
|
291
|
+
* **This method will not return the access token if the storage type is set to `webWorker`.**
|
|
292
|
+
*
|
|
293
|
+
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
294
|
+
*/
|
|
295
|
+
async getAccessToken() {
|
|
296
|
+
return this._client.getAccessToken();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* This method return a Promise that resolves with the idp access token.
|
|
300
|
+
*
|
|
301
|
+
* **This method will not return the idp access token if the storage type is set to `webWorker`.**
|
|
302
|
+
* **This can be used to access the IDP access token when custom auth grant functionalities are used**
|
|
303
|
+
*
|
|
304
|
+
* @return {Promise<string>} - A Promise that resolves with the idp access token.
|
|
305
|
+
*/
|
|
306
|
+
async getIDPAccessToken() {
|
|
307
|
+
return this._client.getIDPAccessToken();
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* This method refreshes the access token.
|
|
311
|
+
*
|
|
312
|
+
* @return {TokenResponseInterface} - A Promise that resolves with an object containing
|
|
313
|
+
* information about the refreshed access token.
|
|
314
|
+
*/
|
|
315
|
+
async refreshAccessToken() {
|
|
316
|
+
return this._client.refreshAccessToken();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* This method specifies if the user is authenticated or not.
|
|
320
|
+
*
|
|
321
|
+
* @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
|
|
322
|
+
*/
|
|
323
|
+
async isAuthenticated() {
|
|
324
|
+
return this._client.isAuthenticated();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* This method specifies if the session is active or not.
|
|
328
|
+
*
|
|
329
|
+
* @return {Promise<boolean>} - A Promise that resolves with `true` if there is an active session.
|
|
330
|
+
*/
|
|
331
|
+
async isSessionActive() {
|
|
332
|
+
return this._client.isSessionActive();
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* This method enables callback functions attached to the http client.
|
|
336
|
+
*
|
|
337
|
+
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
338
|
+
*
|
|
339
|
+
*/
|
|
340
|
+
async enableHttpHandler() {
|
|
341
|
+
return this._client.enableHttpHandler();
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* This method disables callback functions attached to the http client.
|
|
345
|
+
*
|
|
346
|
+
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
347
|
+
*/
|
|
348
|
+
async disableHttpHandler() {
|
|
349
|
+
return this._client.disableHttpHandler();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* This method updates the configuration that was passed into the constructor when instantiating this class.
|
|
353
|
+
*
|
|
354
|
+
* @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
|
|
355
|
+
*/
|
|
356
|
+
async updateConfig(config) {
|
|
357
|
+
return this._client.updateConfig(config);
|
|
358
|
+
}
|
|
359
|
+
on(hook, callback, id) {
|
|
360
|
+
if (hook === import_browser.Hooks.CustomGrant) {
|
|
361
|
+
return this._client.on(hook, callback, id);
|
|
362
|
+
}
|
|
363
|
+
return this._client.on(hook, callback);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* This method allows you to sign in silently.
|
|
367
|
+
* First, this method sends a prompt none request to see if there is an active user session in the identity server.
|
|
368
|
+
* If there is one, then it requests the access token and stores it. Else, it returns false.
|
|
369
|
+
*
|
|
370
|
+
* @return {Promise<BasicUserInfo | boolean>} - A Promise that resolves with the user information after signing in
|
|
371
|
+
* or with `false` if the user is not signed in.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
*```
|
|
375
|
+
* client.trySignInSilently()
|
|
376
|
+
*```
|
|
377
|
+
*/
|
|
378
|
+
async trySignInSilently(state, dispatch, additionalParams, tokenRequestConfig) {
|
|
379
|
+
return this._client.trySignInSilently(additionalParams, tokenRequestConfig).then(async (response) => {
|
|
380
|
+
if (!response) {
|
|
381
|
+
this.updateState({ ...this.getState(), isLoading: false });
|
|
382
|
+
dispatch({ ...state, isLoading: false });
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
if (await this._client.isAuthenticated()) {
|
|
386
|
+
const basicUserInfo = response;
|
|
387
|
+
const stateToUpdate = {
|
|
388
|
+
allowedScopes: basicUserInfo.allowedScopes,
|
|
389
|
+
displayName: basicUserInfo.displayName,
|
|
390
|
+
email: basicUserInfo.email,
|
|
391
|
+
isAuthenticated: true,
|
|
392
|
+
isLoading: false,
|
|
393
|
+
isSigningOut: false,
|
|
394
|
+
sub: basicUserInfo.sub,
|
|
395
|
+
username: basicUserInfo.username
|
|
396
|
+
};
|
|
397
|
+
this.updateState(stateToUpdate);
|
|
398
|
+
dispatch({ ...state, ...stateToUpdate });
|
|
399
|
+
}
|
|
400
|
+
return response;
|
|
401
|
+
}).catch((error) => {
|
|
402
|
+
return Promise.reject(error);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
__publicField(_AuthAPI, "DEFAULT_STATE");
|
|
407
|
+
var AuthAPI = _AuthAPI;
|
|
408
|
+
AuthAPI.DEFAULT_STATE = {
|
|
409
|
+
allowedScopes: "",
|
|
410
|
+
displayName: "",
|
|
411
|
+
email: "",
|
|
412
|
+
isAuthenticated: false,
|
|
413
|
+
isLoading: true,
|
|
414
|
+
sub: "",
|
|
415
|
+
username: ""
|
|
416
|
+
};
|
|
417
|
+
var api_default = AuthAPI;
|
|
418
|
+
|
|
419
|
+
// src/api/scim2/getMeProfile.ts
|
|
420
|
+
var import_browser2 = require("@asgardeo/browser");
|
|
421
|
+
var httpClient = import_browser2.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser2.AsgardeoSPAClient.getInstance());
|
|
422
|
+
var getMeProfile = async ({ url, ...requestConfig }) => {
|
|
423
|
+
try {
|
|
424
|
+
new URL(url);
|
|
425
|
+
} catch (error) {
|
|
426
|
+
throw new import_browser2.AsgardeoAPIError(
|
|
427
|
+
"Invalid endpoint URL provided",
|
|
428
|
+
"getMeProfile-ValidationError-001",
|
|
429
|
+
"javascript",
|
|
430
|
+
400,
|
|
431
|
+
"Invalid Request"
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
const response = await httpClient({
|
|
435
|
+
url,
|
|
436
|
+
method: "GET",
|
|
437
|
+
headers: {
|
|
438
|
+
"Content-Type": "application/scim+json",
|
|
439
|
+
Accept: "application/json"
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
if (!response.data) {
|
|
443
|
+
const errorText = await response.text();
|
|
444
|
+
throw new import_browser2.AsgardeoAPIError(
|
|
445
|
+
`Failed to fetch user profile: ${errorText}`,
|
|
446
|
+
"getMeProfile-ResponseError-001",
|
|
447
|
+
"javascript",
|
|
448
|
+
response.status,
|
|
449
|
+
response.statusText
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
return response.data;
|
|
453
|
+
};
|
|
454
|
+
var getMeProfile_default = getMeProfile;
|
|
455
|
+
|
|
456
|
+
// src/utils/getUserProfile.ts
|
|
457
|
+
var import_browser4 = require("@asgardeo/browser");
|
|
458
|
+
|
|
459
|
+
// src/api/scim2/getSchemas.ts
|
|
460
|
+
var import_browser3 = require("@asgardeo/browser");
|
|
461
|
+
var httpClient2 = import_browser3.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser3.AsgardeoSPAClient.getInstance());
|
|
462
|
+
var getSchemas = async ({ url }) => {
|
|
463
|
+
try {
|
|
464
|
+
new URL(url);
|
|
465
|
+
} catch (error) {
|
|
466
|
+
throw new import_browser3.AsgardeoAPIError(
|
|
467
|
+
"Invalid endpoint URL provided",
|
|
468
|
+
"getSchemas-ValidationError-001",
|
|
469
|
+
"javascript",
|
|
470
|
+
400,
|
|
471
|
+
"Invalid Request"
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
const response = await httpClient2({
|
|
475
|
+
url,
|
|
476
|
+
method: "GET",
|
|
477
|
+
headers: {
|
|
478
|
+
"Content-Type": "application/json",
|
|
479
|
+
Accept: "application/json"
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
if (!response.data) {
|
|
483
|
+
throw new import_browser3.AsgardeoAPIError(
|
|
484
|
+
`Failed to fetch SCIM2 schemas`,
|
|
485
|
+
"getSchemas-ResponseError-001",
|
|
486
|
+
"javascript",
|
|
487
|
+
response.status,
|
|
488
|
+
response.statusText
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
return response.data;
|
|
492
|
+
};
|
|
493
|
+
var getSchemas_default = getSchemas;
|
|
494
|
+
|
|
495
|
+
// src/utils/getUserProfile.ts
|
|
496
|
+
var getUserProfile = async ({ baseUrl }) => {
|
|
497
|
+
try {
|
|
498
|
+
const profile = await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
|
|
499
|
+
const schemas = await getSchemas_default({ url: `${baseUrl}/scim2/Schemas` });
|
|
500
|
+
const result = [];
|
|
501
|
+
for (const schema of schemas) {
|
|
502
|
+
const schemaId = schema.id;
|
|
503
|
+
const source = schemaId.startsWith("urn:ietf:params:scim:schemas:core:2.0") ? profile : profile[schemaId] ?? {};
|
|
504
|
+
for (const attr of schema.attributes || []) {
|
|
505
|
+
const { name, type, subAttributes, multiValued, caseExact, returned } = attr;
|
|
506
|
+
if (type === "COMPLEX" && subAttributes?.length && typeof source[name] === "object") {
|
|
507
|
+
const complexValue = source[name];
|
|
508
|
+
for (const subAttr of subAttributes) {
|
|
509
|
+
if (complexValue[subAttr.name] !== void 0) {
|
|
510
|
+
const { subAttributes: subAttributes2, ...attrWithoutSubAttrs } = attr;
|
|
511
|
+
const basePath = schemaId === "urn:ietf:params:scim:schemas:core:2.0:User" ? `${name}.${subAttr.name}` : `${schemaId}.${name}.${subAttr.name}`;
|
|
512
|
+
result.push({
|
|
513
|
+
schemaId,
|
|
514
|
+
...subAttr,
|
|
515
|
+
value: complexValue[subAttr.name],
|
|
516
|
+
parent: {
|
|
517
|
+
...attrWithoutSubAttrs
|
|
518
|
+
},
|
|
519
|
+
path: basePath
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
const value = source[name];
|
|
525
|
+
if (value !== void 0) {
|
|
526
|
+
const basePath = schemaId === "urn:ietf:params:scim:schemas:core:2.0:User" ? name : `${schemaId}.${name}`;
|
|
527
|
+
result.push({
|
|
528
|
+
schemaId,
|
|
529
|
+
...attr,
|
|
530
|
+
value,
|
|
531
|
+
path: basePath
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return result;
|
|
538
|
+
} catch (error) {
|
|
539
|
+
throw new import_browser4.AsgardeoAPIError(
|
|
540
|
+
"Failed to get user profile",
|
|
541
|
+
"getUserProfile-Error-001",
|
|
542
|
+
"javascript",
|
|
543
|
+
500,
|
|
544
|
+
"Internal Server Error"
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
var getUserProfile_default = getUserProfile;
|
|
549
|
+
|
|
550
|
+
// src/AsgardeoReactClient.ts
|
|
551
|
+
var AsgardeoReactClient = class extends import_browser5.AsgardeoBrowserClient {
|
|
552
|
+
constructor() {
|
|
553
|
+
super();
|
|
554
|
+
__publicField(this, "asgardeo");
|
|
555
|
+
this.asgardeo = new api_default();
|
|
556
|
+
}
|
|
557
|
+
initialize(config) {
|
|
558
|
+
const scopes = Array.isArray(config.scopes) ? config.scopes : config.scopes.split(" ");
|
|
559
|
+
return this.asgardeo.init({
|
|
560
|
+
baseUrl: config.baseUrl,
|
|
561
|
+
clientID: config.clientId,
|
|
562
|
+
signInRedirectURL: config.afterSignInUrl,
|
|
563
|
+
scope: [...scopes, "internal_login"]
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
async getUser() {
|
|
567
|
+
const baseUrl = await (await this.asgardeo.getConfigData()).baseUrl;
|
|
568
|
+
const profile = await getUserProfile_default({ baseUrl });
|
|
569
|
+
return profile;
|
|
570
|
+
}
|
|
571
|
+
isLoading() {
|
|
572
|
+
return this.asgardeo.isLoading();
|
|
573
|
+
}
|
|
574
|
+
isSignedIn() {
|
|
575
|
+
return this.asgardeo.isSignedIn();
|
|
576
|
+
}
|
|
577
|
+
signIn(options) {
|
|
578
|
+
return this.asgardeo.signIn(options);
|
|
579
|
+
}
|
|
580
|
+
async signOut(...args) {
|
|
581
|
+
if (args[1] && typeof args[1] !== "function") {
|
|
582
|
+
throw new Error("The second argument must be a function.");
|
|
583
|
+
}
|
|
584
|
+
const response = await this.asgardeo.signOut(args[1]);
|
|
585
|
+
return Promise.resolve(String(response));
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
var AsgardeoReactClient_default = AsgardeoReactClient;
|
|
589
|
+
|
|
590
|
+
// src/contexts/AsgardeoContext.ts
|
|
591
|
+
var import_react = require("react");
|
|
592
|
+
var AsgardeoContext = (0, import_react.createContext)({
|
|
593
|
+
isLoading: true,
|
|
594
|
+
isSignedIn: false,
|
|
595
|
+
signIn: null,
|
|
596
|
+
signOut: null,
|
|
597
|
+
signUp: null,
|
|
598
|
+
user: null,
|
|
599
|
+
baseUrl: ""
|
|
600
|
+
});
|
|
601
|
+
AsgardeoContext.displayName = "AsgardeoContext";
|
|
602
|
+
var AsgardeoContext_default = AsgardeoContext;
|
|
603
|
+
|
|
604
|
+
// src/hooks/useBrowserUrl.ts
|
|
605
|
+
var import_browser6 = require("@asgardeo/browser");
|
|
606
|
+
var useBrowserUrl = () => {
|
|
607
|
+
const hasAuthParams = (url, afterSignInUrl) => (0, import_browser6.hasAuthParamsInUrl)() && new URL(url.origin + url.pathname).toString() === new URL(afterSignInUrl).toString() || // authParams?.authorizationCode || // FIXME: These are sent externally. Need to see what we can do about this.
|
|
608
|
+
url.searchParams.get("error") !== null;
|
|
609
|
+
return { hasAuthParams };
|
|
610
|
+
};
|
|
611
|
+
var useBrowserUrl_default = useBrowserUrl;
|
|
612
|
+
|
|
613
|
+
// src/theme/ThemeProvider.tsx
|
|
614
|
+
var import_react3 = require("react");
|
|
615
|
+
var import_browser7 = require("@asgardeo/browser");
|
|
616
|
+
|
|
617
|
+
// src/theme/ThemeContext.ts
|
|
618
|
+
var import_react2 = require("react");
|
|
619
|
+
var ThemeContext = (0, import_react2.createContext)(null);
|
|
620
|
+
ThemeContext.displayName = "ThemeContext";
|
|
621
|
+
var ThemeContext_default = ThemeContext;
|
|
622
|
+
|
|
623
|
+
// src/theme/ThemeProvider.tsx
|
|
624
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
625
|
+
var applyThemeToDOM = (theme) => {
|
|
626
|
+
Object.entries(theme.cssVariables).forEach(([key, value]) => {
|
|
627
|
+
document.documentElement.style.setProperty(key, value);
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
var ThemeProvider = ({
|
|
631
|
+
children,
|
|
632
|
+
theme: themeConfig,
|
|
633
|
+
defaultColorScheme = "light"
|
|
634
|
+
}) => {
|
|
635
|
+
const [colorScheme, setColorScheme] = (0, import_react3.useState)(defaultColorScheme);
|
|
636
|
+
const theme = (0, import_react3.useMemo)(() => (0, import_browser7.createTheme)(themeConfig, colorScheme === "dark"), [themeConfig, colorScheme]);
|
|
637
|
+
const toggleTheme = () => {
|
|
638
|
+
setColorScheme((prev) => prev === "light" ? "dark" : "light");
|
|
639
|
+
};
|
|
640
|
+
(0, import_react3.useEffect)(() => {
|
|
641
|
+
applyThemeToDOM(theme);
|
|
642
|
+
}, [theme]);
|
|
643
|
+
const value = {
|
|
644
|
+
theme,
|
|
645
|
+
colorScheme,
|
|
646
|
+
toggleTheme
|
|
647
|
+
};
|
|
648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext_default.Provider, { value, children });
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/providers/AsgardeoProvider.tsx
|
|
652
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
653
|
+
var AsgardeoProvider = ({
|
|
654
|
+
afterSignInUrl = window.location.origin,
|
|
655
|
+
baseUrl,
|
|
656
|
+
clientId,
|
|
657
|
+
children,
|
|
658
|
+
scopes,
|
|
659
|
+
preferences
|
|
660
|
+
}) => {
|
|
661
|
+
const reRenderCheckRef = (0, import_react4.useRef)(false);
|
|
662
|
+
const asgardeo = (0, import_react4.useMemo)(() => new AsgardeoReactClient_default(), []);
|
|
663
|
+
const { hasAuthParams } = useBrowserUrl_default();
|
|
664
|
+
const [user, setUser] = (0, import_react4.useState)(null);
|
|
665
|
+
const [isSignedInSync, setIsSignedInSync] = (0, import_react4.useState)(false);
|
|
666
|
+
(0, import_react4.useEffect)(() => {
|
|
667
|
+
(async () => {
|
|
668
|
+
await asgardeo.initialize({
|
|
669
|
+
afterSignInUrl,
|
|
670
|
+
baseUrl,
|
|
671
|
+
clientId,
|
|
672
|
+
scopes
|
|
673
|
+
});
|
|
674
|
+
})();
|
|
675
|
+
}, []);
|
|
676
|
+
(0, import_react4.useEffect)(() => {
|
|
677
|
+
if (reRenderCheckRef.current) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
reRenderCheckRef.current = true;
|
|
681
|
+
(async () => {
|
|
682
|
+
if (await asgardeo.isSignedIn()) {
|
|
683
|
+
setUser(await asgardeo.getUser());
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (hasAuthParams(new URL(window.location.href), afterSignInUrl)) {
|
|
687
|
+
try {
|
|
688
|
+
await signIn(
|
|
689
|
+
{ callOnlyOnRedirect: true }
|
|
690
|
+
// authParams?.authorizationCode,
|
|
691
|
+
// authParams?.sessionState,
|
|
692
|
+
// authParams?.state,
|
|
693
|
+
);
|
|
694
|
+
} catch (error) {
|
|
695
|
+
debugger;
|
|
696
|
+
if (error && Object.prototype.hasOwnProperty.call(error, "code")) {
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
})();
|
|
701
|
+
}, []);
|
|
702
|
+
(0, import_react4.useEffect)(() => {
|
|
703
|
+
let interval;
|
|
704
|
+
(async () => {
|
|
705
|
+
try {
|
|
706
|
+
const status = await asgardeo.isSignedIn();
|
|
707
|
+
setIsSignedInSync(status);
|
|
708
|
+
if (!status) {
|
|
709
|
+
interval = setInterval(async () => {
|
|
710
|
+
const newStatus = await asgardeo.isSignedIn();
|
|
711
|
+
if (newStatus) {
|
|
712
|
+
setIsSignedInSync(true);
|
|
713
|
+
clearInterval(interval);
|
|
714
|
+
}
|
|
715
|
+
}, 1e3);
|
|
716
|
+
}
|
|
717
|
+
} catch (error) {
|
|
718
|
+
setIsSignedInSync(false);
|
|
719
|
+
}
|
|
720
|
+
})();
|
|
721
|
+
return () => {
|
|
722
|
+
if (interval) {
|
|
723
|
+
clearInterval(interval);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
}, [asgardeo]);
|
|
727
|
+
const signIn = async (options) => {
|
|
728
|
+
try {
|
|
729
|
+
const response = await asgardeo.signIn(options);
|
|
730
|
+
setUser(await asgardeo.getUser());
|
|
731
|
+
return response;
|
|
732
|
+
} catch (error) {
|
|
733
|
+
throw new Error(`Error while signing in: ${error}`);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
const signUp = () => {
|
|
737
|
+
throw new Error("Not implemented");
|
|
738
|
+
};
|
|
739
|
+
const signOut = async (options, afterSignOut) => asgardeo.signOut(options, afterSignOut);
|
|
740
|
+
const isDarkMode = (0, import_react4.useMemo)(() => {
|
|
741
|
+
if (!preferences?.theme?.mode || preferences.theme.mode === "system") {
|
|
742
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
743
|
+
}
|
|
744
|
+
return preferences.theme.mode === "dark";
|
|
745
|
+
}, [preferences?.theme?.mode]);
|
|
746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
747
|
+
AsgardeoContext_default.Provider,
|
|
748
|
+
{
|
|
749
|
+
value: {
|
|
750
|
+
isLoading: false,
|
|
751
|
+
isSignedIn: isSignedInSync,
|
|
752
|
+
signIn,
|
|
753
|
+
signOut,
|
|
754
|
+
signUp: () => {
|
|
755
|
+
throw new Error("Sign up functionality not implemented yet");
|
|
756
|
+
},
|
|
757
|
+
user,
|
|
758
|
+
baseUrl
|
|
759
|
+
},
|
|
760
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ThemeProvider, { theme: preferences?.theme?.overrides, defaultColorScheme: isDarkMode ? "dark" : "light", children })
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
};
|
|
764
|
+
var AsgardeoProvider_default = AsgardeoProvider;
|
|
765
|
+
|
|
766
|
+
// src/hooks/useAsgardeo.ts
|
|
767
|
+
var import_react5 = require("react");
|
|
768
|
+
var useAsgardeo = () => {
|
|
769
|
+
const context = (0, import_react5.useContext)(AsgardeoContext_default);
|
|
770
|
+
if (!context) {
|
|
771
|
+
throw new Error("useAsgardeo must be used within an AsgardeoProvider");
|
|
772
|
+
}
|
|
773
|
+
return context;
|
|
774
|
+
};
|
|
775
|
+
var useAsgardeo_default = useAsgardeo;
|
|
776
|
+
|
|
777
|
+
// src/components/actions/SignInButton/BaseSignInButton.tsx
|
|
778
|
+
var import_react6 = require("react");
|
|
779
|
+
var import_browser8 = require("@asgardeo/browser");
|
|
780
|
+
var import_clsx = __toESM(require("clsx"), 1);
|
|
781
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
782
|
+
var BaseSignInButton = (0, import_react6.forwardRef)(
|
|
783
|
+
({ children, className, style, signIn, isLoading, ...rest }, ref) => {
|
|
784
|
+
if (typeof children === "function") {
|
|
785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: children({ signIn, isLoading }) });
|
|
786
|
+
}
|
|
787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
788
|
+
"button",
|
|
789
|
+
{
|
|
790
|
+
ref,
|
|
791
|
+
className: (0, import_clsx.default)((0, import_browser8.withVendorCSSClassPrefix)("sign-in-button"), className),
|
|
792
|
+
style,
|
|
793
|
+
disabled: isLoading,
|
|
794
|
+
type: "button",
|
|
795
|
+
...rest,
|
|
796
|
+
children
|
|
797
|
+
}
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
);
|
|
801
|
+
BaseSignInButton.displayName = "BaseSignInButton";
|
|
802
|
+
var BaseSignInButton_default = BaseSignInButton;
|
|
803
|
+
|
|
804
|
+
// src/components/actions/SignInButton/SignInButton.tsx
|
|
805
|
+
var import_react7 = require("react");
|
|
806
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
807
|
+
var SignInButton = (0, import_react7.forwardRef)(({ children = "Sign In", onClick, ...rest }, ref) => {
|
|
808
|
+
const { signIn } = useAsgardeo_default();
|
|
809
|
+
const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
|
|
810
|
+
const handleSignIn = async (e) => {
|
|
811
|
+
try {
|
|
812
|
+
setIsLoading(true);
|
|
813
|
+
await signIn();
|
|
814
|
+
if (onClick) {
|
|
815
|
+
onClick(e);
|
|
816
|
+
}
|
|
817
|
+
} catch (error) {
|
|
818
|
+
throw new Error(`Sign in failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
819
|
+
} finally {
|
|
820
|
+
setIsLoading(false);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BaseSignInButton_default, { ref, onClick: handleSignIn, isLoading, signIn: handleSignIn, ...rest, children });
|
|
824
|
+
});
|
|
825
|
+
SignInButton.displayName = "SignInButton";
|
|
826
|
+
var SignInButton_default = SignInButton;
|
|
827
|
+
|
|
828
|
+
// src/components/actions/SignOutButton/BaseSignOutButton.tsx
|
|
829
|
+
var import_react8 = require("react");
|
|
830
|
+
var import_browser9 = require("@asgardeo/browser");
|
|
831
|
+
var import_clsx2 = __toESM(require("clsx"), 1);
|
|
832
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
833
|
+
var BaseSignOutButton = (0, import_react8.forwardRef)(
|
|
834
|
+
({ children, className, style, signOut, isLoading, ...rest }, ref) => {
|
|
835
|
+
if (typeof children === "function") {
|
|
836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: children({ signOut, isLoading }) });
|
|
837
|
+
}
|
|
838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
839
|
+
"button",
|
|
840
|
+
{
|
|
841
|
+
ref,
|
|
842
|
+
className: (0, import_clsx2.default)((0, import_browser9.withVendorCSSClassPrefix)("sign-out-button"), className),
|
|
843
|
+
style,
|
|
844
|
+
disabled: isLoading,
|
|
845
|
+
type: "button",
|
|
846
|
+
...rest,
|
|
847
|
+
children
|
|
848
|
+
}
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
BaseSignOutButton.displayName = "BaseSignOutButton";
|
|
853
|
+
var BaseSignOutButton_default = BaseSignOutButton;
|
|
854
|
+
|
|
855
|
+
// src/components/actions/SignOutButton/SignOutButton.tsx
|
|
856
|
+
var import_react9 = require("react");
|
|
857
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
858
|
+
var SignOutButton = (0, import_react9.forwardRef)(({ children = "Sign Out", onClick, ...rest }, ref) => {
|
|
859
|
+
const { signOut } = useAsgardeo_default();
|
|
860
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
861
|
+
const handleSignOut = async (e) => {
|
|
862
|
+
try {
|
|
863
|
+
setIsLoading(true);
|
|
864
|
+
await signOut();
|
|
865
|
+
if (onClick) {
|
|
866
|
+
onClick(e);
|
|
867
|
+
}
|
|
868
|
+
} catch (error) {
|
|
869
|
+
throw new Error(`Sign out failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
870
|
+
} finally {
|
|
871
|
+
setIsLoading(false);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BaseSignOutButton_default, { ref, onClick: handleSignOut, isLoading, signOut: handleSignOut, ...rest, children });
|
|
875
|
+
});
|
|
876
|
+
SignOutButton.displayName = "SignOutButton";
|
|
877
|
+
var SignOutButton_default = SignOutButton;
|
|
878
|
+
|
|
879
|
+
// src/components/actions/SignUpButton/BaseSignUpButton.tsx
|
|
880
|
+
var import_react10 = require("react");
|
|
881
|
+
var import_browser10 = require("@asgardeo/browser");
|
|
882
|
+
var import_clsx3 = __toESM(require("clsx"), 1);
|
|
883
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
884
|
+
var BaseSignUpButton = (0, import_react10.forwardRef)(
|
|
885
|
+
({ children, className, style, signUp, isLoading, ...rest }, ref) => {
|
|
886
|
+
if (typeof children === "function") {
|
|
887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: children({ signUp, isLoading }) });
|
|
888
|
+
}
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
890
|
+
"button",
|
|
891
|
+
{
|
|
892
|
+
ref,
|
|
893
|
+
className: (0, import_clsx3.default)((0, import_browser10.withVendorCSSClassPrefix)("sign-up-button"), className),
|
|
894
|
+
style,
|
|
895
|
+
disabled: isLoading,
|
|
896
|
+
type: "button",
|
|
897
|
+
...rest,
|
|
898
|
+
children
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
);
|
|
903
|
+
BaseSignUpButton.displayName = "BaseSignUpButton";
|
|
904
|
+
var BaseSignUpButton_default = BaseSignUpButton;
|
|
905
|
+
|
|
906
|
+
// src/components/actions/SignUpButton/SignUpButton.tsx
|
|
907
|
+
var import_react11 = require("react");
|
|
908
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
909
|
+
var SignUpButton = (0, import_react11.forwardRef)(({ children = "Sign Up", onClick, ...rest }, ref) => {
|
|
910
|
+
const { signUp } = useAsgardeo_default();
|
|
911
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
912
|
+
const handleSignUp = async (e) => {
|
|
913
|
+
try {
|
|
914
|
+
setIsLoading(true);
|
|
915
|
+
await signUp();
|
|
916
|
+
if (onClick) {
|
|
917
|
+
onClick(e);
|
|
918
|
+
}
|
|
919
|
+
} catch (error) {
|
|
920
|
+
throw new Error(`Sign up failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
921
|
+
} finally {
|
|
922
|
+
setIsLoading(false);
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BaseSignUpButton_default, { ref, onClick: handleSignUp, isLoading, signUp: handleSignUp, ...rest, children });
|
|
926
|
+
});
|
|
927
|
+
SignUpButton.displayName = "SignUpButton";
|
|
928
|
+
var SignUpButton_default = SignUpButton;
|
|
929
|
+
|
|
930
|
+
// src/components/control/SignedIn.tsx
|
|
931
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
932
|
+
var SignedIn = ({
|
|
933
|
+
children,
|
|
934
|
+
fallback = null
|
|
935
|
+
}) => {
|
|
936
|
+
const { isSignedIn } = useAsgardeo_default();
|
|
937
|
+
if (!isSignedIn) {
|
|
938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: fallback });
|
|
939
|
+
}
|
|
940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
|
|
941
|
+
};
|
|
942
|
+
SignedIn.displayName = "SignedIn";
|
|
943
|
+
var SignedIn_default = SignedIn;
|
|
944
|
+
|
|
945
|
+
// src/components/control/SignedOut.tsx
|
|
946
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
947
|
+
var SignedOut = ({
|
|
948
|
+
children,
|
|
949
|
+
fallback = null
|
|
950
|
+
}) => {
|
|
951
|
+
const { isSignedIn } = useAsgardeo_default();
|
|
952
|
+
if (!isSignedIn) {
|
|
953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
|
|
954
|
+
}
|
|
955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: fallback });
|
|
956
|
+
};
|
|
957
|
+
SignedOut.displayName = "SignedOut";
|
|
958
|
+
var SignedOut_default = SignedOut;
|
|
959
|
+
|
|
960
|
+
// src/components/presentation/User.tsx
|
|
961
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
962
|
+
var User4 = ({ children, fallback = null }) => {
|
|
963
|
+
const { user } = useAsgardeo_default();
|
|
964
|
+
if (!user) {
|
|
965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: fallback });
|
|
966
|
+
}
|
|
967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: children(user) });
|
|
968
|
+
};
|
|
969
|
+
User4.displayName = "User";
|
|
970
|
+
var User_default = User4;
|
|
971
|
+
|
|
972
|
+
// src/components/presentation/UserProfile/BaseUserProfile.tsx
|
|
973
|
+
var import_react15 = require("react");
|
|
974
|
+
|
|
975
|
+
// src/components/primitives/Popover/Popover.tsx
|
|
976
|
+
var import_react13 = __toESM(require("react"), 1);
|
|
977
|
+
var import_react_dom = require("react-dom");
|
|
978
|
+
|
|
979
|
+
// src/theme/useTheme.ts
|
|
980
|
+
var import_react12 = require("react");
|
|
981
|
+
var useTheme = () => {
|
|
982
|
+
const context = (0, import_react12.useContext)(ThemeContext_default);
|
|
983
|
+
if (!context) {
|
|
984
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
985
|
+
}
|
|
986
|
+
return context;
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
// src/components/primitives/Popover/Popover.tsx
|
|
990
|
+
var import_browser11 = require("@asgardeo/browser");
|
|
991
|
+
var import_clsx4 = __toESM(require("clsx"), 1);
|
|
992
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
993
|
+
var useStyles = () => {
|
|
994
|
+
const { theme, colorScheme } = useTheme();
|
|
995
|
+
return (0, import_react13.useMemo)(
|
|
996
|
+
() => ({
|
|
997
|
+
overlay: {
|
|
998
|
+
position: "fixed",
|
|
999
|
+
top: 0,
|
|
1000
|
+
left: 0,
|
|
1001
|
+
right: 0,
|
|
1002
|
+
bottom: 0,
|
|
1003
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
1004
|
+
zIndex: 999
|
|
1005
|
+
},
|
|
1006
|
+
content: {
|
|
1007
|
+
position: "fixed",
|
|
1008
|
+
top: "50%",
|
|
1009
|
+
left: "50%",
|
|
1010
|
+
transform: "translate(-50%, -50%)",
|
|
1011
|
+
zIndex: 1e3,
|
|
1012
|
+
maxHeight: "90vh",
|
|
1013
|
+
overflowY: "auto",
|
|
1014
|
+
background: theme.colors.surface,
|
|
1015
|
+
borderRadius: theme.borderRadius.large,
|
|
1016
|
+
boxShadow: `0 2px 8px ${colorScheme === "dark" ? "rgba(0, 0, 0, 0.3)" : "rgba(0, 0, 0, 0.15)"}`
|
|
1017
|
+
},
|
|
1018
|
+
contentBody: {},
|
|
1019
|
+
header: {
|
|
1020
|
+
display: "flex",
|
|
1021
|
+
justifyContent: "space-between",
|
|
1022
|
+
alignItems: "center",
|
|
1023
|
+
padding: `${theme.spacing.unit * 3}px ${theme.spacing.unit * 4.5}px`,
|
|
1024
|
+
borderBottom: `1px solid ${theme.colors.border}`
|
|
1025
|
+
},
|
|
1026
|
+
headerTitle: {
|
|
1027
|
+
margin: 0,
|
|
1028
|
+
fontSize: "1.2rem",
|
|
1029
|
+
fontWeight: 600,
|
|
1030
|
+
color: theme.colors.text.primary
|
|
1031
|
+
},
|
|
1032
|
+
closeButton: {
|
|
1033
|
+
background: "none",
|
|
1034
|
+
border: "none",
|
|
1035
|
+
cursor: "pointer",
|
|
1036
|
+
padding: theme.spacing.unit / 2 + "px",
|
|
1037
|
+
color: theme.colors.text.secondary,
|
|
1038
|
+
fontSize: "1.2rem",
|
|
1039
|
+
"&:hover": {
|
|
1040
|
+
color: theme.colors.text.primary
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}),
|
|
1044
|
+
[theme, colorScheme]
|
|
1045
|
+
);
|
|
1046
|
+
};
|
|
1047
|
+
var PopoverContext = import_react13.default.createContext({});
|
|
1048
|
+
var PopoverHeader = ({ children }) => {
|
|
1049
|
+
const styles = useStyles();
|
|
1050
|
+
const { onClose } = import_react13.default.useContext(PopoverContext);
|
|
1051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: styles.header, children: [
|
|
1052
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { style: styles.headerTitle, children }),
|
|
1053
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { style: styles.closeButton, onClick: onClose, "aria-label": "Close", children: "\xD7" })
|
|
1054
|
+
] });
|
|
1055
|
+
};
|
|
1056
|
+
var PopoverContent = ({ children }) => {
|
|
1057
|
+
const styles = useStyles();
|
|
1058
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: styles.contentBody, children });
|
|
1059
|
+
};
|
|
1060
|
+
var Popover = ({ isOpen, children, onClose, className = "", portalId = "wso2-popover-root", mode = "modal" }) => {
|
|
1061
|
+
const [portalEl, setPortalEl] = (0, import_react13.useState)(null);
|
|
1062
|
+
const styles = useStyles();
|
|
1063
|
+
(0, import_react13.useEffect)(() => {
|
|
1064
|
+
const existing = document.getElementById(portalId);
|
|
1065
|
+
if (existing) {
|
|
1066
|
+
setPortalEl(existing);
|
|
1067
|
+
return void 0;
|
|
1068
|
+
}
|
|
1069
|
+
const el = document.createElement("div");
|
|
1070
|
+
el.id = portalId;
|
|
1071
|
+
document.body.appendChild(el);
|
|
1072
|
+
setPortalEl(el);
|
|
1073
|
+
return () => {
|
|
1074
|
+
if (document.getElementById(portalId)) {
|
|
1075
|
+
document.getElementById(portalId)?.remove();
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
}, [portalId]);
|
|
1079
|
+
(0, import_react13.useEffect)(() => {
|
|
1080
|
+
const handleEscape = (event) => {
|
|
1081
|
+
if (event.key === "Escape" && isOpen) {
|
|
1082
|
+
onClose();
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
document.addEventListener("keydown", handleEscape);
|
|
1086
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
1087
|
+
}, [isOpen, onClose]);
|
|
1088
|
+
if (!isOpen || !portalEl) {
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
return (0, import_react_dom.createPortal)(
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PopoverContext.Provider, { value: { onClose }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_clsx4.default)((0, import_browser11.withVendorCSSClassPrefix)("popover"), className), children: [
|
|
1093
|
+
mode === "modal" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_browser11.withVendorCSSClassPrefix)("popover-overlay"), style: styles["overlay"], onClick: onClose }),
|
|
1094
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_browser11.withVendorCSSClassPrefix)("popover-content"), style: styles["content"], children })
|
|
1095
|
+
] }) }),
|
|
1096
|
+
portalEl
|
|
1097
|
+
);
|
|
1098
|
+
};
|
|
1099
|
+
Popover.Header = PopoverHeader;
|
|
1100
|
+
Popover.Content = PopoverContent;
|
|
1101
|
+
|
|
1102
|
+
// src/components/primitives/Avatar/Avatar.tsx
|
|
1103
|
+
var import_react14 = require("react");
|
|
1104
|
+
var import_browser12 = require("@asgardeo/browser");
|
|
1105
|
+
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
1106
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1107
|
+
var useStyles2 = ({ size }) => {
|
|
1108
|
+
const { theme, colorScheme } = useTheme();
|
|
1109
|
+
return (0, import_react14.useMemo)(
|
|
1110
|
+
() => ({
|
|
1111
|
+
avatar: {
|
|
1112
|
+
width: `${size}px`,
|
|
1113
|
+
height: `${size}px`,
|
|
1114
|
+
borderRadius: "50%",
|
|
1115
|
+
overflow: "hidden",
|
|
1116
|
+
backgroundColor: theme.colors.surface,
|
|
1117
|
+
display: "flex",
|
|
1118
|
+
alignItems: "center",
|
|
1119
|
+
justifyContent: "center",
|
|
1120
|
+
fontSize: `${size * 0.4}px`,
|
|
1121
|
+
fontWeight: 500,
|
|
1122
|
+
color: theme.colors.text.primary,
|
|
1123
|
+
border: `1px solid ${theme.colors.border}`,
|
|
1124
|
+
boxShadow: colorScheme === "dark" ? "none" : "0 2px 4px rgba(0, 0, 0, 0.1)"
|
|
1125
|
+
},
|
|
1126
|
+
image: {
|
|
1127
|
+
width: "100%",
|
|
1128
|
+
height: "100%",
|
|
1129
|
+
objectFit: "cover"
|
|
1130
|
+
}
|
|
1131
|
+
}),
|
|
1132
|
+
[size, theme, colorScheme]
|
|
1133
|
+
);
|
|
1134
|
+
};
|
|
1135
|
+
var Avatar = ({ imageUrl, alt = "User avatar", size = 64, name, className = "" }) => {
|
|
1136
|
+
const styles = useStyles2({ size });
|
|
1137
|
+
const getInitials = (name2) => {
|
|
1138
|
+
return name2.split(" ").map((part) => part[0]).slice(0, 2).join("").toUpperCase();
|
|
1139
|
+
};
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: styles.avatar, className: (0, import_clsx5.default)((0, import_browser12.withVendorCSSClassPrefix)("avatar"), className), children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { src: imageUrl, alt, style: styles.image }) : name ? getInitials(name) : "?" });
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
// src/components/primitives/TextField/TextField.tsx
|
|
1144
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
1145
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1146
|
+
var TextField = ({ label, error, required, className, disabled, helperText, style = {}, ...rest }) => {
|
|
1147
|
+
const { theme } = useTheme();
|
|
1148
|
+
const containerStyle = {
|
|
1149
|
+
marginBottom: theme.spacing.unit * 2 + "px",
|
|
1150
|
+
...style
|
|
1151
|
+
};
|
|
1152
|
+
const labelStyle = {
|
|
1153
|
+
display: "block",
|
|
1154
|
+
marginBottom: theme.spacing.unit + "px",
|
|
1155
|
+
color: error ? theme.colors.error.main : theme.colors.text.secondary,
|
|
1156
|
+
fontSize: "0.875rem",
|
|
1157
|
+
fontWeight: 500
|
|
1158
|
+
};
|
|
1159
|
+
const inputStyle = {
|
|
1160
|
+
width: "100%",
|
|
1161
|
+
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 1.5}px`,
|
|
1162
|
+
border: `1px solid ${error ? theme.colors.error.main : theme.colors.border}`,
|
|
1163
|
+
borderRadius: theme.borderRadius.small,
|
|
1164
|
+
fontSize: "1rem",
|
|
1165
|
+
color: theme.colors.text.primary,
|
|
1166
|
+
backgroundColor: disabled ? theme.colors.background.disabled : theme.colors.background.surface,
|
|
1167
|
+
outline: "none",
|
|
1168
|
+
transition: "border-color 0.2s ease"
|
|
1169
|
+
};
|
|
1170
|
+
const helperTextStyle = {
|
|
1171
|
+
fontSize: "0.75rem",
|
|
1172
|
+
color: error ? theme.colors.error.main : theme.colors.text.secondary,
|
|
1173
|
+
marginTop: theme.spacing.unit / 2 + "px"
|
|
1174
|
+
};
|
|
1175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: containerStyle, className: (0, import_clsx6.default)("asgardeo-text-field", className), children: [
|
|
1176
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { style: labelStyle, children: [
|
|
1177
|
+
label,
|
|
1178
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { color: theme.colors.error.main }, children: " *" })
|
|
1179
|
+
] }),
|
|
1180
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { style: inputStyle, disabled, "aria-invalid": !!error, "aria-required": required, ...rest }),
|
|
1181
|
+
(error || helperText) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: helperTextStyle, children: error || helperText })
|
|
1182
|
+
] });
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
// src/components/primitives/DatePicker/DatePicker.tsx
|
|
1186
|
+
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
1187
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1188
|
+
var DatePicker = ({
|
|
1189
|
+
label,
|
|
1190
|
+
error,
|
|
1191
|
+
className,
|
|
1192
|
+
required,
|
|
1193
|
+
disabled,
|
|
1194
|
+
helperText,
|
|
1195
|
+
dateFormat = "yyyy-MM-dd",
|
|
1196
|
+
style = {},
|
|
1197
|
+
...rest
|
|
1198
|
+
}) => {
|
|
1199
|
+
const { theme } = useTheme();
|
|
1200
|
+
const containerStyle = {
|
|
1201
|
+
marginBottom: theme.spacing.unit * 2 + "px",
|
|
1202
|
+
...style
|
|
1203
|
+
};
|
|
1204
|
+
const labelStyle = {
|
|
1205
|
+
display: "block",
|
|
1206
|
+
marginBottom: theme.spacing.unit + "px",
|
|
1207
|
+
color: error ? theme.colors.error.main : theme.colors.text.secondary,
|
|
1208
|
+
fontSize: "0.875rem",
|
|
1209
|
+
fontWeight: 500
|
|
1210
|
+
};
|
|
1211
|
+
const inputStyle = {
|
|
1212
|
+
width: "100%",
|
|
1213
|
+
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 1.5}px`,
|
|
1214
|
+
border: `1px solid ${error ? theme.colors.error.main : theme.colors.border}`,
|
|
1215
|
+
borderRadius: theme.borderRadius.small,
|
|
1216
|
+
fontSize: "1rem",
|
|
1217
|
+
color: theme.colors.text.primary,
|
|
1218
|
+
backgroundColor: disabled ? theme.colors.background.disabled : theme.colors.background.surface,
|
|
1219
|
+
outline: "none",
|
|
1220
|
+
transition: "border-color 0.2s ease"
|
|
1221
|
+
};
|
|
1222
|
+
const helperTextStyle = {
|
|
1223
|
+
fontSize: "0.75rem",
|
|
1224
|
+
color: error ? theme.colors.error.main : theme.colors.text.secondary,
|
|
1225
|
+
marginTop: theme.spacing.unit / 2 + "px"
|
|
1226
|
+
};
|
|
1227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: containerStyle, className: (0, import_clsx7.default)("asgardeo-date-picker", className), children: [
|
|
1228
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { style: labelStyle, children: [
|
|
1229
|
+
label,
|
|
1230
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { color: theme.colors.error.main }, children: " *" })
|
|
1231
|
+
] }),
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1233
|
+
"input",
|
|
1234
|
+
{
|
|
1235
|
+
type: "date",
|
|
1236
|
+
pattern: "\\d{4}-\\d{2}-\\d{2}",
|
|
1237
|
+
placeholder: dateFormat,
|
|
1238
|
+
style: inputStyle,
|
|
1239
|
+
disabled,
|
|
1240
|
+
"aria-invalid": !!error,
|
|
1241
|
+
"aria-required": required,
|
|
1242
|
+
...rest
|
|
1243
|
+
}
|
|
1244
|
+
),
|
|
1245
|
+
(error || helperText) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: helperTextStyle, children: error || helperText })
|
|
1246
|
+
] });
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
// src/components/primitives/Checkbox/Checkbox.tsx
|
|
1250
|
+
var import_clsx8 = __toESM(require("clsx"), 1);
|
|
1251
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1252
|
+
var Checkbox = ({ label, error, className, required, helperText, style = {}, ...rest }) => {
|
|
1253
|
+
const { theme } = useTheme();
|
|
1254
|
+
const containerStyle = {
|
|
1255
|
+
marginBottom: theme.spacing.unit * 2 + "px",
|
|
1256
|
+
display: "flex",
|
|
1257
|
+
alignItems: "center",
|
|
1258
|
+
...style
|
|
1259
|
+
};
|
|
1260
|
+
const inputStyle = {
|
|
1261
|
+
width: theme.spacing.unit * 2.5 + "px",
|
|
1262
|
+
height: theme.spacing.unit * 2.5 + "px",
|
|
1263
|
+
marginRight: theme.spacing.unit + "px",
|
|
1264
|
+
accentColor: theme.colors.primary.main
|
|
1265
|
+
};
|
|
1266
|
+
const labelStyle = {
|
|
1267
|
+
color: error ? theme.colors.error.main : theme.colors.text.primary,
|
|
1268
|
+
fontSize: "0.875rem"
|
|
1269
|
+
};
|
|
1270
|
+
const helperTextStyle = {
|
|
1271
|
+
fontSize: "0.75rem",
|
|
1272
|
+
color: error ? theme.colors.error.main : theme.colors.text.secondary,
|
|
1273
|
+
marginTop: theme.spacing.unit / 2 + "px",
|
|
1274
|
+
marginLeft: theme.spacing.unit * 3.5 + "px"
|
|
1275
|
+
};
|
|
1276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: (0, import_clsx8.default)("asgardeo-checkbox", className), children: [
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: containerStyle, children: [
|
|
1278
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "checkbox", style: inputStyle, "aria-invalid": !!error, "aria-required": required, ...rest }),
|
|
1279
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { style: labelStyle, children: [
|
|
1280
|
+
label,
|
|
1281
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { color: theme.colors.error.main }, children: " *" })
|
|
1282
|
+
] })
|
|
1283
|
+
] }),
|
|
1284
|
+
(error || helperText) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: helperTextStyle, children: error || helperText })
|
|
1285
|
+
] });
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
// src/components/presentation/UserProfile/BaseUserProfile.tsx
|
|
1289
|
+
var import_browser13 = require("@asgardeo/browser");
|
|
1290
|
+
var import_clsx9 = __toESM(require("clsx"), 1);
|
|
1291
|
+
|
|
1292
|
+
// src/utils/getMappedUserProfileValue.ts
|
|
1293
|
+
var getMappedUserProfileValue = (key, mappings, user) => {
|
|
1294
|
+
const mappedKey = mappings[key];
|
|
1295
|
+
if (Array.isArray(user)) {
|
|
1296
|
+
if (Array.isArray(mappedKey)) {
|
|
1297
|
+
for (const field of mappedKey) {
|
|
1298
|
+
const found2 = user.find((u) => u.name === field);
|
|
1299
|
+
if (found2?.value !== void 0) {
|
|
1300
|
+
return found2.value;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
} else {
|
|
1304
|
+
const found2 = user.find((u) => u.name === mappedKey);
|
|
1305
|
+
if (found2?.value !== void 0) {
|
|
1306
|
+
return found2.value;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
const found = user.find((u) => u.name === key);
|
|
1310
|
+
return found?.value;
|
|
1311
|
+
}
|
|
1312
|
+
return mappedKey ? user[mappedKey] : user[key];
|
|
1313
|
+
};
|
|
1314
|
+
var getMappedUserProfileValue_default = getMappedUserProfileValue;
|
|
1315
|
+
|
|
1316
|
+
// src/components/presentation/UserProfile/BaseUserProfile.tsx
|
|
1317
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1318
|
+
var BaseUserProfile = ({
|
|
1319
|
+
fallback = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: "Please sign in to view your profile" }),
|
|
1320
|
+
className = "",
|
|
1321
|
+
cardLayout = true,
|
|
1322
|
+
user,
|
|
1323
|
+
mode = "inline",
|
|
1324
|
+
portalId = "asgardeo-user-profile",
|
|
1325
|
+
title = "User Profile",
|
|
1326
|
+
attributeMapping = {},
|
|
1327
|
+
editable = true,
|
|
1328
|
+
onChange,
|
|
1329
|
+
onSubmit,
|
|
1330
|
+
onUpdate,
|
|
1331
|
+
saveButtonText = "Save Changes",
|
|
1332
|
+
cancelButtonText = "Cancel"
|
|
1333
|
+
}) => {
|
|
1334
|
+
const { theme } = useTheme();
|
|
1335
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(mode === "popup");
|
|
1336
|
+
const [editedUser, setEditedUser] = (0, import_react15.useState)(user);
|
|
1337
|
+
const [editingFields, setEditingFields] = (0, import_react15.useState)({});
|
|
1338
|
+
const PencilIcon = () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1339
|
+
"svg",
|
|
1340
|
+
{
|
|
1341
|
+
width: "16",
|
|
1342
|
+
height: "16",
|
|
1343
|
+
viewBox: "0 0 24 24",
|
|
1344
|
+
fill: "none",
|
|
1345
|
+
stroke: "currentColor",
|
|
1346
|
+
strokeWidth: "2",
|
|
1347
|
+
strokeLinecap: "round",
|
|
1348
|
+
strokeLinejoin: "round",
|
|
1349
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z" })
|
|
1350
|
+
}
|
|
1351
|
+
);
|
|
1352
|
+
const toggleFieldEdit = (0, import_react15.useCallback)((fieldName) => {
|
|
1353
|
+
setEditingFields((prev) => ({
|
|
1354
|
+
...prev,
|
|
1355
|
+
[fieldName]: !prev[fieldName]
|
|
1356
|
+
}));
|
|
1357
|
+
}, []);
|
|
1358
|
+
function set(obj, path, value) {
|
|
1359
|
+
const keys = path.split(".");
|
|
1360
|
+
let current = obj;
|
|
1361
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1362
|
+
const key = keys[i];
|
|
1363
|
+
if (i === keys.length - 1) {
|
|
1364
|
+
current[key] = value;
|
|
1365
|
+
} else {
|
|
1366
|
+
if (!current[key] || typeof current[key] !== "object") {
|
|
1367
|
+
current[key] = {};
|
|
1368
|
+
}
|
|
1369
|
+
current = current[key];
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
const handleFieldSave = (0, import_react15.useCallback)(
|
|
1374
|
+
(schema) => {
|
|
1375
|
+
let payload = {};
|
|
1376
|
+
const fieldName = schema.name;
|
|
1377
|
+
const fieldValue = editedUser && fieldName && editedUser[fieldName] !== void 0 ? editedUser[fieldName] : schema.value;
|
|
1378
|
+
set(payload, schema.path, fieldValue);
|
|
1379
|
+
onUpdate(payload);
|
|
1380
|
+
toggleFieldEdit(fieldName);
|
|
1381
|
+
},
|
|
1382
|
+
[editedUser, onUpdate, toggleFieldEdit]
|
|
1383
|
+
);
|
|
1384
|
+
const handleFieldCancel = (0, import_react15.useCallback)(
|
|
1385
|
+
(fieldName) => {
|
|
1386
|
+
setEditedUser((prev) => ({
|
|
1387
|
+
...prev,
|
|
1388
|
+
[fieldName]: user[fieldName]
|
|
1389
|
+
}));
|
|
1390
|
+
toggleFieldEdit(fieldName);
|
|
1391
|
+
},
|
|
1392
|
+
[user, toggleFieldEdit]
|
|
1393
|
+
);
|
|
1394
|
+
const formatLabel = (0, import_react15.useCallback)((key) => {
|
|
1395
|
+
return key.split(/(?=[A-Z])|_/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1396
|
+
}, []);
|
|
1397
|
+
const styles = useStyles3();
|
|
1398
|
+
const buttonStyle = (0, import_react15.useMemo)(
|
|
1399
|
+
() => ({
|
|
1400
|
+
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`,
|
|
1401
|
+
margin: `${theme.spacing.unit}px`,
|
|
1402
|
+
borderRadius: theme.borderRadius.small,
|
|
1403
|
+
border: "none",
|
|
1404
|
+
cursor: "pointer",
|
|
1405
|
+
fontSize: "0.875rem",
|
|
1406
|
+
fontWeight: 500
|
|
1407
|
+
}),
|
|
1408
|
+
[theme]
|
|
1409
|
+
);
|
|
1410
|
+
const saveButtonStyle = (0, import_react15.useMemo)(
|
|
1411
|
+
() => ({
|
|
1412
|
+
...buttonStyle,
|
|
1413
|
+
backgroundColor: theme.colors.primary.main,
|
|
1414
|
+
color: theme.colors.primary.contrastText
|
|
1415
|
+
}),
|
|
1416
|
+
[theme, buttonStyle]
|
|
1417
|
+
);
|
|
1418
|
+
const cancelButtonStyle = (0, import_react15.useMemo)(
|
|
1419
|
+
() => ({
|
|
1420
|
+
...buttonStyle,
|
|
1421
|
+
backgroundColor: theme.colors.secondary.main,
|
|
1422
|
+
border: `1px solid ${theme.colors.border}`
|
|
1423
|
+
}),
|
|
1424
|
+
[theme, buttonStyle]
|
|
1425
|
+
);
|
|
1426
|
+
const defaultAttributeMappings = {
|
|
1427
|
+
picture: ["profile", "profileUrl"],
|
|
1428
|
+
firstName: "givenName",
|
|
1429
|
+
lastName: "familyName"
|
|
1430
|
+
};
|
|
1431
|
+
const mergedMappings = { ...defaultAttributeMappings, ...attributeMapping };
|
|
1432
|
+
const renderSchemaField = (schema, isEditing, onEditValue) => {
|
|
1433
|
+
if (!schema) return null;
|
|
1434
|
+
const { value, displayName, description, name, type, required, mutability, subAttributes } = schema;
|
|
1435
|
+
const label = displayName || description || name || "";
|
|
1436
|
+
if (subAttributes && Array.isArray(subAttributes)) {
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: subAttributes.map((subAttr, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: styles.field, children: [
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: styles.label, children: subAttr.displayName || subAttr.description || "" }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.value, children: Array.isArray(subAttr.value) ? subAttr.value.map((item) => typeof item === "object" ? JSON.stringify(item) : String(item)).join(", ") : typeof subAttr.value === "object" ? JSON.stringify(subAttr.value) : String(subAttr.value) })
|
|
1440
|
+
] }, index)) });
|
|
1441
|
+
}
|
|
1442
|
+
if (Array.isArray(value)) {
|
|
1443
|
+
const displayValue = value.map((item) => typeof item === "object" ? JSON.stringify(item) : String(item)).join(", ");
|
|
1444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: styles.label, children: label }),
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.value, children: displayValue })
|
|
1447
|
+
] });
|
|
1448
|
+
}
|
|
1449
|
+
if (type === "COMPLEX" && typeof value === "object") {
|
|
1450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ObjectDisplay, { data: value });
|
|
1451
|
+
}
|
|
1452
|
+
if (isEditing && onEditValue && mutability !== "READ_ONLY") {
|
|
1453
|
+
const fieldValue = editedUser && name && editedUser[name] !== void 0 ? editedUser[name] : value || "";
|
|
1454
|
+
const commonProps = {
|
|
1455
|
+
label: void 0,
|
|
1456
|
+
// Don't show label in field, we render it outside
|
|
1457
|
+
required,
|
|
1458
|
+
value: fieldValue,
|
|
1459
|
+
onChange: (e) => onEditValue(e.target ? e.target.value : e),
|
|
1460
|
+
style: {
|
|
1461
|
+
marginBottom: 0
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
let field;
|
|
1465
|
+
switch (type) {
|
|
1466
|
+
case "STRING":
|
|
1467
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TextField, { ...commonProps });
|
|
1468
|
+
break;
|
|
1469
|
+
case "DATE_TIME":
|
|
1470
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DatePicker, { ...commonProps });
|
|
1471
|
+
break;
|
|
1472
|
+
case "BOOLEAN":
|
|
1473
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Checkbox, { ...commonProps, checked: !!fieldValue, onChange: (e) => onEditValue(e.target.checked) });
|
|
1474
|
+
break;
|
|
1475
|
+
case "COMPLEX":
|
|
1476
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TextField, { ...commonProps });
|
|
1477
|
+
break;
|
|
1478
|
+
default:
|
|
1479
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TextField, { ...commonProps });
|
|
1480
|
+
}
|
|
1481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: styles.label, children: label }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.value, children: field })
|
|
1484
|
+
] });
|
|
1485
|
+
}
|
|
1486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: styles.label, children: label }),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.value, children: String(value) })
|
|
1489
|
+
] });
|
|
1490
|
+
};
|
|
1491
|
+
const renderUserInfo = (schema) => {
|
|
1492
|
+
if (!schema || !schema.name) return null;
|
|
1493
|
+
const isFieldEditing = editingFields[schema.name];
|
|
1494
|
+
const fieldStyle = {
|
|
1495
|
+
...styles.field,
|
|
1496
|
+
display: "flex",
|
|
1497
|
+
alignItems: "center",
|
|
1498
|
+
gap: theme.spacing.unit + "px"
|
|
1499
|
+
};
|
|
1500
|
+
const actionButtonStyle = {
|
|
1501
|
+
...buttonStyle,
|
|
1502
|
+
padding: `${theme.spacing.unit / 2}px ${theme.spacing.unit}px`,
|
|
1503
|
+
fontSize: "0.75rem",
|
|
1504
|
+
marginLeft: "auto"
|
|
1505
|
+
};
|
|
1506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: fieldStyle, children: [
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { flex: 1, display: "flex", alignItems: "center", gap: theme.spacing.unit + "px" }, children: renderSchemaField(schema, isFieldEditing, (value) => {
|
|
1508
|
+
const tempEditedUser = { ...editedUser };
|
|
1509
|
+
tempEditedUser[schema.name] = value;
|
|
1510
|
+
setEditedUser(tempEditedUser);
|
|
1511
|
+
}) }),
|
|
1512
|
+
editable && schema.mutability !== "READ_ONLY" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1513
|
+
"div",
|
|
1514
|
+
{
|
|
1515
|
+
style: {
|
|
1516
|
+
display: "flex",
|
|
1517
|
+
gap: theme.spacing.unit / 2 + "px",
|
|
1518
|
+
alignItems: "center",
|
|
1519
|
+
marginLeft: theme.spacing.unit + "px"
|
|
1520
|
+
},
|
|
1521
|
+
children: isFieldEditing ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1522
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { style: { ...actionButtonStyle, ...saveButtonStyle }, onClick: () => handleFieldSave(schema), children: "Save" }),
|
|
1523
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1524
|
+
"button",
|
|
1525
|
+
{
|
|
1526
|
+
style: { ...actionButtonStyle, ...cancelButtonStyle },
|
|
1527
|
+
onClick: () => handleFieldCancel(schema.name),
|
|
1528
|
+
children: "Cancel"
|
|
1529
|
+
}
|
|
1530
|
+
)
|
|
1531
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1532
|
+
"button",
|
|
1533
|
+
{
|
|
1534
|
+
style: {
|
|
1535
|
+
...actionButtonStyle,
|
|
1536
|
+
backgroundColor: "transparent",
|
|
1537
|
+
border: "none",
|
|
1538
|
+
margin: 0,
|
|
1539
|
+
padding: theme.spacing.unit / 2 + "px",
|
|
1540
|
+
color: theme.colors.text.secondary
|
|
1541
|
+
},
|
|
1542
|
+
onClick: () => toggleFieldEdit(schema.name),
|
|
1543
|
+
title: "Edit",
|
|
1544
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PencilIcon, {})
|
|
1545
|
+
}
|
|
1546
|
+
)
|
|
1547
|
+
}
|
|
1548
|
+
)
|
|
1549
|
+
] });
|
|
1550
|
+
};
|
|
1551
|
+
const ObjectDisplay = ({ data }) => {
|
|
1552
|
+
if (!data || typeof data !== "object") return null;
|
|
1553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("table", { style: { width: "100%", borderCollapse: "collapse" }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("tbody", { children: Object.entries(data).map(([key, value]) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("tr", { style: { borderBottom: `1px solid ${theme.colors.border}` }, children: [
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("td", { style: { padding: theme.spacing.unit + "px", verticalAlign: "top" }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("strong", { children: [
|
|
1555
|
+
formatLabel(key),
|
|
1556
|
+
":"
|
|
1557
|
+
] }) }),
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("td", { style: { padding: theme.spacing.unit + "px", verticalAlign: "top" }, children: typeof value === "object" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ObjectDisplay, { data: value }) : String(value) })
|
|
1559
|
+
] }, key)) }) });
|
|
1560
|
+
};
|
|
1561
|
+
const getDisplayName = () => {
|
|
1562
|
+
const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
|
|
1563
|
+
const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
|
|
1564
|
+
if (firstName && lastName) {
|
|
1565
|
+
return `${firstName} ${lastName}`;
|
|
1566
|
+
}
|
|
1567
|
+
return getMappedUserProfileValue_default("username", mergedMappings, user) || "";
|
|
1568
|
+
};
|
|
1569
|
+
if (!user) {
|
|
1570
|
+
return fallback;
|
|
1571
|
+
}
|
|
1572
|
+
const containerStyle = {
|
|
1573
|
+
...styles.root,
|
|
1574
|
+
...cardLayout ? styles.card : {}
|
|
1575
|
+
};
|
|
1576
|
+
const avatarAttributes = ["picture"];
|
|
1577
|
+
const excludedProps = avatarAttributes.map((attr) => mergedMappings[attr] || attr);
|
|
1578
|
+
const profileContent = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: containerStyle, className: (0, import_clsx9.default)((0, import_browser13.withVendorCSSClassPrefix)("user-profile"), className), children: [
|
|
1579
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.header, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1580
|
+
Avatar,
|
|
1581
|
+
{
|
|
1582
|
+
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, user),
|
|
1583
|
+
name: getDisplayName(),
|
|
1584
|
+
size: 80,
|
|
1585
|
+
alt: `${getDisplayName()}'s avatar`
|
|
1586
|
+
}
|
|
1587
|
+
) }),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: styles.infoContainer, children: Array.isArray(user) ? user.filter((schema) => !excludedProps.includes(schema.name) && schema.value).map((schema, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: renderUserInfo(schema) }, index)) : Object.entries(user).filter(([key]) => !excludedProps.includes(key) && user[key]).map(
|
|
1589
|
+
([key, value]) => renderUserInfo({
|
|
1590
|
+
name: key,
|
|
1591
|
+
value,
|
|
1592
|
+
displayName: formatLabel(key)
|
|
1593
|
+
})
|
|
1594
|
+
) })
|
|
1595
|
+
] });
|
|
1596
|
+
if (mode === "popup") {
|
|
1597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Popover, { isOpen, onClose: () => setIsOpen(false), portalId, children: [
|
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Popover.Header, { children: title }),
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Popover.Content, { children: profileContent })
|
|
1600
|
+
] });
|
|
1601
|
+
}
|
|
1602
|
+
return profileContent;
|
|
1603
|
+
};
|
|
1604
|
+
var useStyles3 = () => {
|
|
1605
|
+
const { theme, colorScheme } = useTheme();
|
|
1606
|
+
return (0, import_react15.useMemo)(
|
|
1607
|
+
() => ({
|
|
1608
|
+
root: {
|
|
1609
|
+
padding: theme.spacing.unit * 4 + "px",
|
|
1610
|
+
minWidth: "600px",
|
|
1611
|
+
margin: "0 auto"
|
|
1612
|
+
},
|
|
1613
|
+
card: {
|
|
1614
|
+
background: theme.colors.surface,
|
|
1615
|
+
borderRadius: theme.borderRadius.large
|
|
1616
|
+
},
|
|
1617
|
+
header: {
|
|
1618
|
+
display: "flex",
|
|
1619
|
+
alignItems: "center",
|
|
1620
|
+
gap: theme.spacing.unit * 1.5 + "px",
|
|
1621
|
+
marginBottom: theme.spacing.unit * 1.5 + "px"
|
|
1622
|
+
},
|
|
1623
|
+
profileInfo: {
|
|
1624
|
+
flex: 1
|
|
1625
|
+
},
|
|
1626
|
+
name: {
|
|
1627
|
+
fontSize: "1.5rem",
|
|
1628
|
+
fontWeight: 600,
|
|
1629
|
+
margin: "0",
|
|
1630
|
+
color: theme.colors.text.primary
|
|
1631
|
+
},
|
|
1632
|
+
infoContainer: {
|
|
1633
|
+
display: "flex",
|
|
1634
|
+
flexDirection: "column",
|
|
1635
|
+
gap: theme.spacing.unit + "px"
|
|
1636
|
+
},
|
|
1637
|
+
field: {
|
|
1638
|
+
display: "flex",
|
|
1639
|
+
alignItems: "center",
|
|
1640
|
+
padding: theme.spacing.unit + "px 0",
|
|
1641
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
1642
|
+
minHeight: "32px"
|
|
1643
|
+
},
|
|
1644
|
+
lastField: {
|
|
1645
|
+
borderBottom: "none"
|
|
1646
|
+
},
|
|
1647
|
+
label: {
|
|
1648
|
+
fontSize: "0.875rem",
|
|
1649
|
+
fontWeight: 500,
|
|
1650
|
+
color: theme.colors.text.secondary,
|
|
1651
|
+
width: "120px",
|
|
1652
|
+
flexShrink: 0,
|
|
1653
|
+
lineHeight: "32px"
|
|
1654
|
+
},
|
|
1655
|
+
value: {
|
|
1656
|
+
color: theme.colors.text.primary,
|
|
1657
|
+
flex: 1,
|
|
1658
|
+
display: "flex",
|
|
1659
|
+
alignItems: "center",
|
|
1660
|
+
gap: theme.spacing.unit + "px",
|
|
1661
|
+
overflow: "hidden",
|
|
1662
|
+
minHeight: "32px",
|
|
1663
|
+
"& input, & .MuiInputBase-root": {
|
|
1664
|
+
height: "32px",
|
|
1665
|
+
margin: 0
|
|
1666
|
+
},
|
|
1667
|
+
lineHeight: "32px",
|
|
1668
|
+
"& table": {
|
|
1669
|
+
backgroundColor: theme.colors.background,
|
|
1670
|
+
borderRadius: theme.borderRadius.small,
|
|
1671
|
+
whiteSpace: "normal"
|
|
1672
|
+
},
|
|
1673
|
+
"& td": {
|
|
1674
|
+
borderColor: theme.colors.border
|
|
1675
|
+
}
|
|
1676
|
+
},
|
|
1677
|
+
popup: {
|
|
1678
|
+
padding: theme.spacing.unit * 2 + "px"
|
|
1679
|
+
}
|
|
1680
|
+
}),
|
|
1681
|
+
[theme, colorScheme]
|
|
1682
|
+
);
|
|
1683
|
+
};
|
|
1684
|
+
var BaseUserProfile_default = BaseUserProfile;
|
|
1685
|
+
|
|
1686
|
+
// src/api/scim2/updateMeProfile.ts
|
|
1687
|
+
var import_browser14 = require("@asgardeo/browser");
|
|
1688
|
+
var httpClient3 = import_browser14.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser14.AsgardeoSPAClient.getInstance());
|
|
1689
|
+
var updateMeProfile = async ({
|
|
1690
|
+
url,
|
|
1691
|
+
payload,
|
|
1692
|
+
...requestConfig
|
|
1693
|
+
}) => {
|
|
1694
|
+
try {
|
|
1695
|
+
new URL(url);
|
|
1696
|
+
} catch (error) {
|
|
1697
|
+
throw new import_browser14.AsgardeoAPIError(
|
|
1698
|
+
"Invalid endpoint URL provided",
|
|
1699
|
+
"updateMeProfile-ValidationError-001",
|
|
1700
|
+
"javascript",
|
|
1701
|
+
400,
|
|
1702
|
+
"Invalid Request"
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
const data = {
|
|
1706
|
+
Operations: [
|
|
1707
|
+
{
|
|
1708
|
+
op: "replace",
|
|
1709
|
+
value: payload
|
|
1710
|
+
}
|
|
1711
|
+
],
|
|
1712
|
+
schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
|
|
1713
|
+
};
|
|
1714
|
+
const response = await httpClient3({
|
|
1715
|
+
url,
|
|
1716
|
+
method: "PATCH",
|
|
1717
|
+
headers: {
|
|
1718
|
+
"Content-Type": "application/scim+json",
|
|
1719
|
+
Accept: "application/json"
|
|
1720
|
+
},
|
|
1721
|
+
data,
|
|
1722
|
+
...requestConfig
|
|
1723
|
+
});
|
|
1724
|
+
if (!response.data) {
|
|
1725
|
+
const errorText = await response.text();
|
|
1726
|
+
throw new import_browser14.AsgardeoAPIError(
|
|
1727
|
+
`Failed to update user profile: ${errorText}`,
|
|
1728
|
+
"updateMeProfile-ResponseError-001",
|
|
1729
|
+
"javascript",
|
|
1730
|
+
response.status,
|
|
1731
|
+
response.statusText
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
return response.data;
|
|
1735
|
+
};
|
|
1736
|
+
var updateMeProfile_default = updateMeProfile;
|
|
1737
|
+
|
|
1738
|
+
// src/components/presentation/UserProfile/UserProfile.tsx
|
|
1739
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1740
|
+
var UserProfile = ({ ...rest }) => {
|
|
1741
|
+
const { user, baseUrl } = useAsgardeo_default();
|
|
1742
|
+
const handleProfileUpdate = async (payload) => {
|
|
1743
|
+
await updateMeProfile_default({ url: `${baseUrl}/scim2/Me`, payload });
|
|
1744
|
+
await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
|
|
1745
|
+
};
|
|
1746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BaseUserProfile_default, { user, onUpdate: handleProfileUpdate, ...rest });
|
|
1747
|
+
};
|
|
1748
|
+
var UserProfile_default = UserProfile;
|
|
1749
|
+
|
|
1750
|
+
// src/components/presentation/UserDropdown/BaseUserDropdown.tsx
|
|
1751
|
+
var import_react16 = require("react");
|
|
1752
|
+
var import_browser15 = require("@asgardeo/browser");
|
|
1753
|
+
var import_clsx10 = __toESM(require("clsx"), 1);
|
|
1754
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1755
|
+
var useStyles4 = () => {
|
|
1756
|
+
const { theme } = useTheme();
|
|
1757
|
+
return (0, import_react16.useMemo)(
|
|
1758
|
+
() => ({
|
|
1759
|
+
trigger: {
|
|
1760
|
+
display: "inline-flex",
|
|
1761
|
+
alignItems: "center",
|
|
1762
|
+
gap: theme.spacing.unit + "px",
|
|
1763
|
+
padding: theme.spacing.unit * 0.5 + "px",
|
|
1764
|
+
border: "none",
|
|
1765
|
+
background: "none",
|
|
1766
|
+
cursor: "pointer",
|
|
1767
|
+
borderRadius: theme.borderRadius.small,
|
|
1768
|
+
"&:hover": {
|
|
1769
|
+
backgroundColor: theme.colors.background
|
|
1770
|
+
}
|
|
1771
|
+
},
|
|
1772
|
+
userName: {
|
|
1773
|
+
color: theme.colors.text.primary,
|
|
1774
|
+
fontSize: "1rem",
|
|
1775
|
+
fontWeight: 500
|
|
1776
|
+
},
|
|
1777
|
+
dropdownContent: {
|
|
1778
|
+
minWidth: "200px",
|
|
1779
|
+
maxWidth: "300px"
|
|
1780
|
+
},
|
|
1781
|
+
dropdownMenu: {
|
|
1782
|
+
display: "flex",
|
|
1783
|
+
flexDirection: "column",
|
|
1784
|
+
width: "100%"
|
|
1785
|
+
},
|
|
1786
|
+
menuItem: {
|
|
1787
|
+
display: "flex",
|
|
1788
|
+
alignItems: "center",
|
|
1789
|
+
gap: theme.spacing.unit + "px",
|
|
1790
|
+
padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 2}px`,
|
|
1791
|
+
width: "100%",
|
|
1792
|
+
color: theme.colors.text.primary,
|
|
1793
|
+
textDecoration: "none",
|
|
1794
|
+
border: "none",
|
|
1795
|
+
background: "none",
|
|
1796
|
+
cursor: "pointer",
|
|
1797
|
+
fontSize: "0.875rem",
|
|
1798
|
+
"&:hover": {
|
|
1799
|
+
backgroundColor: theme.colors.background
|
|
1800
|
+
}
|
|
1801
|
+
},
|
|
1802
|
+
divider: {
|
|
1803
|
+
margin: `${theme.spacing.unit * 0.5}px 0`,
|
|
1804
|
+
borderBottom: `1px solid ${theme.colors.border}`
|
|
1805
|
+
},
|
|
1806
|
+
dropdownHeader: {
|
|
1807
|
+
display: "flex",
|
|
1808
|
+
alignItems: "center",
|
|
1809
|
+
gap: theme.spacing.unit + "px",
|
|
1810
|
+
padding: `${theme.spacing.unit * 1.5}px`,
|
|
1811
|
+
borderBottom: `1px solid ${theme.colors.border}`
|
|
1812
|
+
},
|
|
1813
|
+
headerInfo: {
|
|
1814
|
+
display: "flex",
|
|
1815
|
+
flexDirection: "column",
|
|
1816
|
+
gap: theme.spacing.unit / 2 + "px"
|
|
1817
|
+
},
|
|
1818
|
+
headerName: {
|
|
1819
|
+
color: theme.colors.text.primary,
|
|
1820
|
+
fontSize: "1rem",
|
|
1821
|
+
fontWeight: 500,
|
|
1822
|
+
margin: 0
|
|
1823
|
+
},
|
|
1824
|
+
headerEmail: {
|
|
1825
|
+
color: theme.colors.text.secondary,
|
|
1826
|
+
fontSize: "0.875rem",
|
|
1827
|
+
margin: 0
|
|
1828
|
+
}
|
|
1829
|
+
}),
|
|
1830
|
+
[theme]
|
|
1831
|
+
);
|
|
1832
|
+
};
|
|
1833
|
+
var BaseUserDropdown = ({
|
|
1834
|
+
fallback = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: "Please sign in" }),
|
|
1835
|
+
className = "",
|
|
1836
|
+
user,
|
|
1837
|
+
portalId = "asgardeo-user-dropdown",
|
|
1838
|
+
menuItems = [],
|
|
1839
|
+
showTriggerLable = false,
|
|
1840
|
+
showDropdownHeader = true,
|
|
1841
|
+
avatarSize = 32,
|
|
1842
|
+
attributeMapping = {}
|
|
1843
|
+
}) => {
|
|
1844
|
+
const styles = useStyles4();
|
|
1845
|
+
const [isOpen, setIsOpen] = (0, import_react16.useState)(false);
|
|
1846
|
+
const defaultAttributeMappings = {
|
|
1847
|
+
picture: ["profile", "profileUrl"],
|
|
1848
|
+
firstName: "givenName",
|
|
1849
|
+
lastName: "familyName",
|
|
1850
|
+
email: "emails"
|
|
1851
|
+
};
|
|
1852
|
+
const mergedMappings = { ...defaultAttributeMappings, ...attributeMapping };
|
|
1853
|
+
const getDisplayName = () => {
|
|
1854
|
+
const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
|
|
1855
|
+
const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
|
|
1856
|
+
if (firstName && lastName) {
|
|
1857
|
+
return `${firstName} ${lastName}`;
|
|
1858
|
+
}
|
|
1859
|
+
return getMappedUserProfileValue_default("username", mergedMappings, user) || "";
|
|
1860
|
+
};
|
|
1861
|
+
if (!user) {
|
|
1862
|
+
return fallback;
|
|
1863
|
+
}
|
|
1864
|
+
const handleMenuItemClick = (item) => {
|
|
1865
|
+
if (item.onClick) {
|
|
1866
|
+
item.onClick();
|
|
1867
|
+
}
|
|
1868
|
+
setIsOpen(false);
|
|
1869
|
+
};
|
|
1870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_clsx10.default)((0, import_browser15.withVendorCSSClassPrefix)("user-dropdown"), className), children: [
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1872
|
+
"button",
|
|
1873
|
+
{
|
|
1874
|
+
className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-trigger"),
|
|
1875
|
+
style: styles.trigger,
|
|
1876
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1877
|
+
children: [
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1879
|
+
Avatar,
|
|
1880
|
+
{
|
|
1881
|
+
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, user),
|
|
1882
|
+
name: getDisplayName(),
|
|
1883
|
+
size: avatarSize,
|
|
1884
|
+
alt: `${getDisplayName()}'s avatar`
|
|
1885
|
+
}
|
|
1886
|
+
),
|
|
1887
|
+
showTriggerLable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { style: styles.userName, children: getDisplayName() })
|
|
1888
|
+
]
|
|
1889
|
+
}
|
|
1890
|
+
),
|
|
1891
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Popover, { isOpen, onClose: () => setIsOpen(false), portalId, mode: "dropdown", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Popover.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { style: styles.dropdownContent, children: [
|
|
1892
|
+
showDropdownHeader && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-header"), style: styles.dropdownHeader, children: [
|
|
1893
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1894
|
+
Avatar,
|
|
1895
|
+
{
|
|
1896
|
+
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, user),
|
|
1897
|
+
name: getDisplayName(),
|
|
1898
|
+
size: avatarSize * 1.25,
|
|
1899
|
+
alt: `${getDisplayName()}'s avatar`
|
|
1900
|
+
}
|
|
1901
|
+
),
|
|
1902
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-header-info"), style: styles.headerInfo, children: [
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-header-name"), style: styles.headerName, children: getDisplayName() }),
|
|
1904
|
+
getMappedUserProfileValue_default("email", mergedMappings, user) !== getDisplayName() && getMappedUserProfileValue_default("email", mergedMappings, user) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1905
|
+
"span",
|
|
1906
|
+
{
|
|
1907
|
+
className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-header-email"),
|
|
1908
|
+
style: styles.headerEmail,
|
|
1909
|
+
children: getMappedUserProfileValue_default("email", mergedMappings, user)
|
|
1910
|
+
}
|
|
1911
|
+
)
|
|
1912
|
+
] })
|
|
1913
|
+
] }),
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-menu"), style: styles.dropdownMenu, children: menuItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
1915
|
+
item.href ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1916
|
+
"a",
|
|
1917
|
+
{
|
|
1918
|
+
href: item.href,
|
|
1919
|
+
style: styles.menuItem,
|
|
1920
|
+
className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-menu-item"),
|
|
1921
|
+
children: [
|
|
1922
|
+
item.icon,
|
|
1923
|
+
item.label
|
|
1924
|
+
]
|
|
1925
|
+
}
|
|
1926
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1927
|
+
"button",
|
|
1928
|
+
{
|
|
1929
|
+
onClick: () => handleMenuItemClick(item),
|
|
1930
|
+
style: styles.menuItem,
|
|
1931
|
+
className: (0, import_browser15.withVendorCSSClassPrefix)("user-dropdown-menu-item"),
|
|
1932
|
+
children: [
|
|
1933
|
+
item.icon,
|
|
1934
|
+
item.label
|
|
1935
|
+
]
|
|
1936
|
+
}
|
|
1937
|
+
),
|
|
1938
|
+
index < menuItems.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: styles.divider })
|
|
1939
|
+
] }, index)) })
|
|
1940
|
+
] }) }) })
|
|
1941
|
+
] });
|
|
1942
|
+
};
|
|
1943
|
+
var BaseUserDropdown_default = BaseUserDropdown;
|
|
1944
|
+
|
|
1945
|
+
// src/components/presentation/UserDropdown/UserDropdown.tsx
|
|
1946
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1947
|
+
var UserDropdown = ({ ...rest }) => {
|
|
1948
|
+
const { user } = useAsgardeo_default();
|
|
1949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(BaseUserDropdown_default, { user, ...rest });
|
|
1950
|
+
};
|
|
1951
|
+
var UserDropdown_default = UserDropdown;
|
|
1952
|
+
|
|
1953
|
+
// src/index.ts
|
|
1954
|
+
__reExport(index_exports, require("@asgardeo/browser"), module.exports);
|
|
1955
|
+
//# sourceMappingURL=index.js.map
|