@asgardeo/react 0.10.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.
@@ -60,6 +60,7 @@ export interface BaseUserProfileProps {
60
60
  title?: string;
61
61
  error?: string | null;
62
62
  isLoading?: boolean;
63
+ displayNameAttributes?: string[];
63
64
  }
64
65
  declare const BaseUserProfile: FC<BaseUserProfileProps>;
65
66
  export default BaseUserProfile;
@@ -28,6 +28,7 @@ declare const useStyles: (theme: Theme, colorScheme: string) => {
28
28
  card: string;
29
29
  header: string;
30
30
  profileInfo: string;
31
+ profileSummary: string;
31
32
  name: string;
32
33
  infoContainer: string;
33
34
  info: string;
@@ -43,5 +44,8 @@ declare const useStyles: (theme: Theme, colorScheme: string) => {
43
44
  complexTextarea: string;
44
45
  objectKey: string;
45
46
  objectValue: string;
47
+ sectionRow: string;
48
+ sectionLabel: string;
49
+ sectionValue: string;
46
50
  };
47
51
  export default useStyles;
package/dist/index.js CHANGED
@@ -1690,7 +1690,13 @@ var AsgardeoProvider = ({
1690
1690
  setBaseUrl(_baseUrl2);
1691
1691
  }
1692
1692
  if (config.platform === Platform2.AsgardeoV2) {
1693
- setUser(extractUserClaimsFromIdToken2(decodedToken));
1693
+ const claims = extractUserClaimsFromIdToken2(decodedToken);
1694
+ setUser(claims);
1695
+ setUserProfile({
1696
+ profile: claims,
1697
+ flattenedProfile: claims,
1698
+ schemas: []
1699
+ });
1694
1700
  } else {
1695
1701
  try {
1696
1702
  const user2 = await asgardeo.getUser({ baseUrl: _baseUrl2 });
@@ -11916,6 +11922,31 @@ var useStyles23 = (theme, colorScheme) => {
11916
11922
  margin: 0;
11917
11923
  color: ${theme.vars.colors.text.primary};
11918
11924
  `;
11925
+ const profileSummary = css23`
11926
+ display: flex;
11927
+ flex-direction: column;
11928
+ align-items: flex-start;
11929
+ `;
11930
+ const sectionRow = css23`
11931
+ display: flex;
11932
+ align-items: center;
11933
+ padding: calc(${theme.vars.spacing.unit} * 1) 0;
11934
+ `;
11935
+ const sectionLabel = css23`
11936
+ font-size: 0.875rem;
11937
+ font-weight: 600;
11938
+ color: ${theme.vars.colors.text.primary};
11939
+ width: 160px;
11940
+ flex-shrink: 0;
11941
+ `;
11942
+ const sectionValue = css23`
11943
+ flex: 1;
11944
+ display: flex;
11945
+ align-items: center;
11946
+ gap: calc(${theme.vars.spacing.unit} * 1.5);
11947
+ font-size: 0.875rem;
11948
+ color: ${theme.vars.colors.text.primary};
11949
+ `;
11919
11950
  const infoContainer = css23`
11920
11951
  display: flex;
11921
11952
  flex-direction: column;
@@ -11987,6 +12018,7 @@ var useStyles23 = (theme, colorScheme) => {
11987
12018
  card,
11988
12019
  header,
11989
12020
  profileInfo,
12021
+ profileSummary,
11990
12022
  name,
11991
12023
  infoContainer,
11992
12024
  info,
@@ -12001,7 +12033,10 @@ var useStyles23 = (theme, colorScheme) => {
12001
12033
  fieldActions,
12002
12034
  complexTextarea,
12003
12035
  objectKey,
12004
- objectValue
12036
+ objectValue,
12037
+ sectionRow,
12038
+ sectionLabel,
12039
+ sectionValue
12005
12040
  };
12006
12041
  }, [
12007
12042
  theme.vars.colors.background.surface,
@@ -12017,7 +12052,15 @@ var useStyles23 = (theme, colorScheme) => {
12017
12052
  var BaseUserProfile_styles_default = useStyles23;
12018
12053
 
12019
12054
  // src/utils/getDisplayName.ts
12020
- var getDisplayName = (mergedMappings, user) => {
12055
+ var getDisplayName = (mergedMappings, user, displayAttributes) => {
12056
+ if (displayAttributes && displayAttributes.length > 0) {
12057
+ for (const attr of displayAttributes) {
12058
+ const value = getMappedUserProfileValue_default(attr, mergedMappings, user);
12059
+ if (value !== void 0 && value !== null && value !== "") {
12060
+ return String(value);
12061
+ }
12062
+ }
12063
+ }
12021
12064
  const firstName = getMappedUserProfileValue_default("firstName", mergedMappings, user);
12022
12065
  const lastName = getMappedUserProfileValue_default("lastName", mergedMappings, user);
12023
12066
  if (firstName && lastName) {
@@ -12067,7 +12110,8 @@ var BaseUserProfile = ({
12067
12110
  error = null,
12068
12111
  isLoading = false,
12069
12112
  showFields = [],
12070
- hideFields = []
12113
+ hideFields = [],
12114
+ displayNameAttributes = []
12071
12115
  }) => {
12072
12116
  const { theme, colorScheme } = useTheme_default();
12073
12117
  const [editedUser, setEditedUser] = useState22(flattenedProfile || profile);
@@ -12190,7 +12234,7 @@ var BaseUserProfile = ({
12190
12234
  picture: ["profile", "profileUrl", "picture", "URL"],
12191
12235
  firstName: ["name.givenName", "given_name"],
12192
12236
  lastName: ["name.familyName", "family_name"],
12193
- email: ["emails"],
12237
+ email: ["emails", "email"],
12194
12238
  username: ["userName", "username", "user_name"]
12195
12239
  };
12196
12240
  const mergedMappings = {
@@ -12398,21 +12442,42 @@ var BaseUserProfile = ({
12398
12442
  const excludedProps = avatarAttributes.map((attr) => mergedMappings[attr] || attr);
12399
12443
  const renderProfileWithoutSchemas = () => {
12400
12444
  if (!currentUser) return null;
12445
+ const displayName = getDisplayName_default(mergedMappings, profile, displayNameAttributes);
12401
12446
  const profileEntries = Object.entries(currentUser).filter(([key, value]) => {
12402
12447
  if (!shouldShowField(key)) return false;
12403
12448
  return value !== void 0 && value !== "" && value !== null;
12404
12449
  }).sort(([a], [b]) => a.localeCompare(b));
12405
- return /* @__PURE__ */ jsx88(Fragment15, { children: profileEntries.map(([key, value]) => /* @__PURE__ */ jsxs38("div", { className: styles.field, children: [
12406
- /* @__PURE__ */ jsx88("span", { className: styles.label, children: formatLabel(key) }),
12407
- /* @__PURE__ */ jsx88("div", { className: styles.value, children: typeof value === "object" ? JSON.stringify(value, null, 2) : String(value) })
12408
- ] }, key)) });
12450
+ return /* @__PURE__ */ jsxs38(Fragment15, { children: [
12451
+ /* @__PURE__ */ jsxs38("div", { className: styles.profileSummary, children: [
12452
+ /* @__PURE__ */ jsx88(
12453
+ Avatar,
12454
+ {
12455
+ imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, currentUser),
12456
+ name: displayName,
12457
+ size: 70,
12458
+ alt: `${displayName}'s avatar`,
12459
+ isLoading
12460
+ }
12461
+ ),
12462
+ /* @__PURE__ */ jsx88(Typography_default, { variant: "h3", fontWeight: "medium", children: displayName }),
12463
+ getMappedUserProfileValue_default("email", mergedMappings, currentUser) && /* @__PURE__ */ jsx88(Typography_default, { variant: "body2", color: "textSecondary", children: getMappedUserProfileValue_default("email", mergedMappings, currentUser) })
12464
+ ] }),
12465
+ /* @__PURE__ */ jsx88(Divider_default, {}),
12466
+ profileEntries.map(([key, value], index) => /* @__PURE__ */ jsxs38("div", { children: [
12467
+ /* @__PURE__ */ jsxs38("div", { className: styles.sectionRow, children: [
12468
+ /* @__PURE__ */ jsx88("div", { className: styles.sectionLabel, children: formatLabel(key) }),
12469
+ /* @__PURE__ */ jsx88("div", { className: styles.sectionValue, children: typeof value === "object" ? /* @__PURE__ */ jsx88(ObjectDisplay, { data: value }) : String(value) })
12470
+ ] }),
12471
+ index < profileEntries.length - 1 && /* @__PURE__ */ jsx88(Divider_default, {})
12472
+ ] }, key))
12473
+ ] });
12409
12474
  };
12410
12475
  const profileContent = /* @__PURE__ */ jsxs38(Card_default, { className: containerClasses, children: [
12411
12476
  error && /* @__PURE__ */ jsxs38(Alert_default, { variant: "error", className: cx28(withVendorCSSClassPrefix27(bem19("user-profile", "alert")), styles.alert), children: [
12412
12477
  /* @__PURE__ */ jsx88(Alert_default.Title, { children: t("errors.heading") || "Error" }),
12413
12478
  /* @__PURE__ */ jsx88(Alert_default.Description, { children: error })
12414
12479
  ] }),
12415
- /* @__PURE__ */ jsx88("div", { className: styles.header, children: /* @__PURE__ */ jsx88(
12480
+ schemas && schemas.length > 0 && /* @__PURE__ */ jsx88("div", { className: styles.header, children: /* @__PURE__ */ jsx88(
12416
12481
  Avatar,
12417
12482
  {
12418
12483
  imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, currentUser),