@asgardeo/react 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +75 -10
- package/dist/cjs/index.js.map +2 -2
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +1 -0
- package/dist/components/presentation/UserProfile/BaseUserProfile.styles.d.ts +4 -0
- package/dist/index.js +75 -10
- package/dist/index.js.map +2 -2
- package/dist/utils/getDisplayName.d.ts +11 -15
- package/package.json +6 -7
package/dist/cjs/index.js
CHANGED
|
@@ -1805,7 +1805,13 @@ var AsgardeoProvider = ({
|
|
|
1805
1805
|
setBaseUrl(_baseUrl2);
|
|
1806
1806
|
}
|
|
1807
1807
|
if (config.platform === import_browser12.Platform.AsgardeoV2) {
|
|
1808
|
-
|
|
1808
|
+
const claims = (0, import_browser12.extractUserClaimsFromIdToken)(decodedToken);
|
|
1809
|
+
setUser(claims);
|
|
1810
|
+
setUserProfile({
|
|
1811
|
+
profile: claims,
|
|
1812
|
+
flattenedProfile: claims,
|
|
1813
|
+
schemas: []
|
|
1814
|
+
});
|
|
1809
1815
|
} else {
|
|
1810
1816
|
try {
|
|
1811
1817
|
const user2 = await asgardeo.getUser({ baseUrl: _baseUrl2 });
|
|
@@ -11969,6 +11975,31 @@ var useStyles23 = (theme, colorScheme) => {
|
|
|
11969
11975
|
margin: 0;
|
|
11970
11976
|
color: ${theme.vars.colors.text.primary};
|
|
11971
11977
|
`;
|
|
11978
|
+
const profileSummary = import_css50.css`
|
|
11979
|
+
display: flex;
|
|
11980
|
+
flex-direction: column;
|
|
11981
|
+
align-items: flex-start;
|
|
11982
|
+
`;
|
|
11983
|
+
const sectionRow = import_css50.css`
|
|
11984
|
+
display: flex;
|
|
11985
|
+
align-items: center;
|
|
11986
|
+
padding: calc(${theme.vars.spacing.unit} * 1) 0;
|
|
11987
|
+
`;
|
|
11988
|
+
const sectionLabel = import_css50.css`
|
|
11989
|
+
font-size: 0.875rem;
|
|
11990
|
+
font-weight: 600;
|
|
11991
|
+
color: ${theme.vars.colors.text.primary};
|
|
11992
|
+
width: 160px;
|
|
11993
|
+
flex-shrink: 0;
|
|
11994
|
+
`;
|
|
11995
|
+
const sectionValue = import_css50.css`
|
|
11996
|
+
flex: 1;
|
|
11997
|
+
display: flex;
|
|
11998
|
+
align-items: center;
|
|
11999
|
+
gap: calc(${theme.vars.spacing.unit} * 1.5);
|
|
12000
|
+
font-size: 0.875rem;
|
|
12001
|
+
color: ${theme.vars.colors.text.primary};
|
|
12002
|
+
`;
|
|
11972
12003
|
const infoContainer = import_css50.css`
|
|
11973
12004
|
display: flex;
|
|
11974
12005
|
flex-direction: column;
|
|
@@ -12040,6 +12071,7 @@ var useStyles23 = (theme, colorScheme) => {
|
|
|
12040
12071
|
card,
|
|
12041
12072
|
header,
|
|
12042
12073
|
profileInfo,
|
|
12074
|
+
profileSummary,
|
|
12043
12075
|
name,
|
|
12044
12076
|
infoContainer,
|
|
12045
12077
|
info,
|
|
@@ -12054,7 +12086,10 @@ var useStyles23 = (theme, colorScheme) => {
|
|
|
12054
12086
|
fieldActions,
|
|
12055
12087
|
complexTextarea,
|
|
12056
12088
|
objectKey,
|
|
12057
|
-
objectValue
|
|
12089
|
+
objectValue,
|
|
12090
|
+
sectionRow,
|
|
12091
|
+
sectionLabel,
|
|
12092
|
+
sectionValue
|
|
12058
12093
|
};
|
|
12059
12094
|
}, [
|
|
12060
12095
|
theme.vars.colors.background.surface,
|
|
@@ -12070,7 +12105,15 @@ var useStyles23 = (theme, colorScheme) => {
|
|
|
12070
12105
|
var BaseUserProfile_styles_default = useStyles23;
|
|
12071
12106
|
|
|
12072
12107
|
// src/utils/getDisplayName.ts
|
|
12073
|
-
var getDisplayName = (mergedMappings, user) => {
|
|
12108
|
+
var getDisplayName = (mergedMappings, user, displayAttributes) => {
|
|
12109
|
+
if (displayAttributes && displayAttributes.length > 0) {
|
|
12110
|
+
for (const attr of displayAttributes) {
|
|
12111
|
+
const value = getMappedUserProfileValue_default(attr, mergedMappings, user);
|
|
12112
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
12113
|
+
return String(value);
|
|
12114
|
+
}
|
|
12115
|
+
}
|
|
12116
|
+
}
|
|
12074
12117
|
const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
|
|
12075
12118
|
const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
|
|
12076
12119
|
if (firstName && lastName) {
|
|
@@ -12120,7 +12163,8 @@ var BaseUserProfile = ({
|
|
|
12120
12163
|
error = null,
|
|
12121
12164
|
isLoading = false,
|
|
12122
12165
|
showFields = [],
|
|
12123
|
-
hideFields = []
|
|
12166
|
+
hideFields = [],
|
|
12167
|
+
displayNameAttributes = []
|
|
12124
12168
|
}) => {
|
|
12125
12169
|
const { theme, colorScheme } = useTheme_default();
|
|
12126
12170
|
const [editedUser, setEditedUser] = (0, import_react76.useState)(flattenedProfile || profile);
|
|
@@ -12243,7 +12287,7 @@ var BaseUserProfile = ({
|
|
|
12243
12287
|
picture: ["profile", "profileUrl", "picture", "URL"],
|
|
12244
12288
|
firstName: ["name.givenName", "given_name"],
|
|
12245
12289
|
lastName: ["name.familyName", "family_name"],
|
|
12246
|
-
email: ["emails"],
|
|
12290
|
+
email: ["emails", "email"],
|
|
12247
12291
|
username: ["userName", "username", "user_name"]
|
|
12248
12292
|
};
|
|
12249
12293
|
const mergedMappings = {
|
|
@@ -12451,21 +12495,42 @@ var BaseUserProfile = ({
|
|
|
12451
12495
|
const excludedProps = avatarAttributes.map((attr) => mergedMappings[attr] || attr);
|
|
12452
12496
|
const renderProfileWithoutSchemas = () => {
|
|
12453
12497
|
if (!currentUser) return null;
|
|
12498
|
+
const displayName = getDisplayName_default(mergedMappings, profile, displayNameAttributes);
|
|
12454
12499
|
const profileEntries = Object.entries(currentUser).filter(([key, value]) => {
|
|
12455
12500
|
if (!shouldShowField(key)) return false;
|
|
12456
12501
|
return value !== void 0 && value !== "" && value !== null;
|
|
12457
12502
|
}).sort(([a], [b]) => a.localeCompare(b));
|
|
12458
|
-
return /* @__PURE__ */ (0, import_jsx_runtime88.
|
|
12459
|
-
/* @__PURE__ */ (0, import_jsx_runtime88.
|
|
12460
|
-
|
|
12461
|
-
|
|
12503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
|
|
12504
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: styles.profileSummary, children: [
|
|
12505
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
12506
|
+
Avatar,
|
|
12507
|
+
{
|
|
12508
|
+
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, currentUser),
|
|
12509
|
+
name: displayName,
|
|
12510
|
+
size: 70,
|
|
12511
|
+
alt: `${displayName}'s avatar`,
|
|
12512
|
+
isLoading
|
|
12513
|
+
}
|
|
12514
|
+
),
|
|
12515
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Typography_default, { variant: "h3", fontWeight: "medium", children: displayName }),
|
|
12516
|
+
getMappedUserProfileValue_default("email", mergedMappings, currentUser) && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Typography_default, { variant: "body2", color: "textSecondary", children: getMappedUserProfileValue_default("email", mergedMappings, currentUser) })
|
|
12517
|
+
] }),
|
|
12518
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Divider_default, {}),
|
|
12519
|
+
profileEntries.map(([key, value], index) => /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { children: [
|
|
12520
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: styles.sectionRow, children: [
|
|
12521
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: styles.sectionLabel, children: formatLabel(key) }),
|
|
12522
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: styles.sectionValue, children: typeof value === "object" ? /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ObjectDisplay, { data: value }) : String(value) })
|
|
12523
|
+
] }),
|
|
12524
|
+
index < profileEntries.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Divider_default, {})
|
|
12525
|
+
] }, key))
|
|
12526
|
+
] });
|
|
12462
12527
|
};
|
|
12463
12528
|
const profileContent = /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Card_default, { className: containerClasses, children: [
|
|
12464
12529
|
error && /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Alert_default, { variant: "error", className: (0, import_css51.cx)((0, import_browser72.withVendorCSSClassPrefix)((0, import_browser72.bem)("user-profile", "alert")), styles.alert), children: [
|
|
12465
12530
|
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Alert_default.Title, { children: t("errors.heading") || "Error" }),
|
|
12466
12531
|
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Alert_default.Description, { children: error })
|
|
12467
12532
|
] }),
|
|
12468
|
-
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: styles.header, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
12533
|
+
schemas && schemas.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: styles.header, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
12469
12534
|
Avatar,
|
|
12470
12535
|
{
|
|
12471
12536
|
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, currentUser),
|