@thunderid/vue 0.13.0 → 0.13.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ConsentConstants, DEFAULT_THEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowEventType, EmbeddedFlowEventType as EmbeddedFlowEventType$1, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowType, EmbeddedSignInFlowType as EmbeddedSignInFlowType$1, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatus$1, EmbeddedSignUpFlowType, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, ThunderIDAPIError, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, TranslationBundleConstants, arrayBufferToBase64url, base64urlToArrayBuffer, createClassObserver, createClassObserver as createClassObserver$1, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createPackageComponentLogger, createPackageLogger, createTheme, deepMerge, detectThemeMode, detectThemeMode as detectThemeMode$1, executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow, extractEmojiFromUri, extractUserClaimsFromIdToken, generateFlattenedUserProfile, get, getActiveTheme, getDefaultI18nBundles, getFlowMeta, getUsersMe, getVendorPrefix, handleWebAuthnAuthentication, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, http, isEmojiUri, isEmpty, navigate, navigate as navigate$1, normalizeBorderRadius, normalizeTranslations, resolveFlowTemplateLiterals, resolveLogoUri, resolveResourceEndpoint, updateMeProfile, withVendorCSSClassPrefix } from "@thunderid/browser";
2
- import { Fragment, computed, defineComponent, h, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, readonly, ref, shallowReadonly, shallowRef, watch } from "vue";
1
+ import { ConsentConstants, DEFAULT_THEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowComponentType as EmbeddedFlowComponentType$1, EmbeddedFlowEventType, EmbeddedFlowEventType as EmbeddedFlowEventType$1, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatus$1, EmbeddedSignInFlowType, EmbeddedSignInFlowType as EmbeddedSignInFlowType$1, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatus$1, EmbeddedSignUpFlowType, FetchHttpClient, FieldType, FieldType as FieldType$1, FlowMetaType, ThunderIDAPIError, ThunderIDBrowserClient, ThunderIDError, ThunderIDRuntimeError, ThunderIDRuntimeError as ThunderIDRuntimeError$1, TranslationBundleConstants, arrayBufferToBase64url, base64urlToArrayBuffer, createClassObserver, createClassObserver as createClassObserver$1, createMediaQueryListener, createMediaQueryListener as createMediaQueryListener$1, createPackageComponentLogger, createPackageLogger, createTheme, deepMerge, detectThemeMode, detectThemeMode as detectThemeMode$1, executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow, extractEmojiFromUri, extractUserClaimsFromIdToken, generateFlattenedUserProfile, get, getActiveTheme, getDefaultI18nBundles, getFlowMeta, getUsersMe, getUsersMeMeta, getVendorPrefix, handleWebAuthnAuthentication, hasAuthParamsInUrl, hasAuthParamsInUrl as hasAuthParamsInUrl$1, hasCalledForThisInstanceInUrl, http, isEmojiUri, isEmpty, navigate, navigate as navigate$1, normalizeBorderRadius, normalizeTranslations, resolveFlowTemplateLiterals, resolveLogoUri, resolveResourceEndpoint, startCase, updateMeProfile, withVendorCSSClassPrefix } from "@thunderid/browser";
2
+ import { Fragment, Teleport, computed, defineComponent, h, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, readonly, ref, shallowReadonly, shallowRef, watch } from "vue";
3
3
  import DOMPurify from "dompurify";
4
4
 
5
5
  //#region src/keys.ts
@@ -548,20 +548,23 @@ const UserProvider = defineComponent({
548
548
  updateProfile: {
549
549
  default: void 0,
550
550
  type: Function
551
+ },
552
+ userSchema: {
553
+ default: null,
554
+ type: Object
551
555
  }
552
556
  },
553
557
  setup(props, { slots }) {
554
558
  const profileRef = computed(() => props.profile);
559
+ const flattenedProfileRef = computed(() => props.profile?.flattenedProfile ?? null);
560
+ const userSchemaRef = computed(() => props.profile?.userSchema ?? props.userSchema ?? null);
555
561
  provide(USER_KEY, {
556
- flattenedProfile: computed(() => props.profile?.flattenedProfile ?? null),
562
+ flattenedProfile: flattenedProfileRef,
557
563
  onUpdateProfile: props.onUpdateProfile ?? (() => {}),
558
564
  profile: profileRef,
559
565
  revalidateProfile: props.revalidateProfile,
560
- updateProfile: props.updateProfile ?? (async () => ({
561
- data: { user: {} },
562
- error: "updateProfile callback not provided",
563
- success: false
564
- }))
566
+ updateProfile: props.updateProfile,
567
+ userSchema: userSchemaRef
565
568
  });
566
569
  return () => h("div", { style: "display:contents" }, slots["default"]?.());
567
570
  }
@@ -592,6 +595,34 @@ const getUsersMe$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
592
595
  };
593
596
  var getUsersMe_default = getUsersMe$1;
594
597
 
598
+ //#endregion
599
+ //#region src/api/getUsersMeMeta.ts
600
+ /**
601
+ * Retrieves the user schema metadata from the specified /users/me/meta endpoint.
602
+ * Uses ThunderID SPA client FetchHttpClient by default with multi-instance support.
603
+ */
604
+ const getUsersMeMeta$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
605
+ const defaultFetcher = async (url, config) => {
606
+ const response = await FetchHttpClient.getInstance(instanceId).request({
607
+ headers: config.headers,
608
+ method: config.method ?? "GET",
609
+ url
610
+ });
611
+ return {
612
+ json: () => Promise.resolve(response.data),
613
+ ok: response.status >= 200 && response.status < 300,
614
+ status: response.status,
615
+ statusText: response.statusText || "",
616
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
617
+ };
618
+ };
619
+ return getUsersMeMeta({
620
+ ...requestConfig,
621
+ fetcher: fetcher ?? defaultFetcher
622
+ });
623
+ };
624
+ var getUsersMeMeta_default = getUsersMeMeta$1;
625
+
595
626
  //#endregion
596
627
  //#region src/ThunderIDVueClient.ts
597
628
  /**
@@ -837,6 +868,10 @@ const ThunderIDProvider = defineComponent({
837
868
  default: void 0,
838
869
  type: String
839
870
  },
871
+ preferences: {
872
+ default: void 0,
873
+ type: Object
874
+ },
840
875
  scopes: {
841
876
  default: void 0,
842
877
  type: [Array, String]
@@ -874,6 +909,7 @@ const ThunderIDProvider = defineComponent({
874
909
  const isLoading = ref(true);
875
910
  const user = shallowRef(null);
876
911
  const userProfile = shallowRef(null);
912
+ const userSchema = ref(null);
877
913
  const resolvedBaseUrl = ref(props.baseUrl);
878
914
  let isUpdatingSession = false;
879
915
  let signInCheckInterval;
@@ -888,6 +924,7 @@ const ThunderIDProvider = defineComponent({
888
924
  endpoints: props.endpoints,
889
925
  organizationChain: props.organizationChain,
890
926
  organizationHandle: props.organizationHandle,
927
+ preferences: props.preferences,
891
928
  scopes: props.scopes,
892
929
  signInOptions: props.signInOptions,
893
930
  signInUrl: props.signInUrl,
@@ -907,13 +944,40 @@ const ThunderIDProvider = defineComponent({
907
944
  baseUrl = `${(await client.getConfiguration()).baseUrl}/o`;
908
945
  resolvedBaseUrl.value = baseUrl;
909
946
  }
947
+ const shouldFetchProfile = props.preferences?.user?.fetchUserProfile !== false;
910
948
  const claims = extractUserClaimsFromIdToken(decodedToken);
911
- user.value = claims;
949
+ let profileData = claims;
950
+ const currentSignInStatus = await client.isSignedIn();
951
+ if (currentSignInStatus && shouldFetchProfile) {
952
+ try {
953
+ const fetchedProfile = await getUsersMe_default({
954
+ baseUrl,
955
+ url: resolveResourceEndpoint("usersMe", { endpoints: props.endpoints }),
956
+ instanceId: props.instanceId
957
+ });
958
+ profileData = {
959
+ ...claims,
960
+ ...fetchedProfile
961
+ };
962
+ } catch {}
963
+ try {
964
+ const metaRes = await getUsersMeMeta_default({
965
+ baseUrl,
966
+ url: resolveResourceEndpoint("usersMeMeta", { endpoints: props.endpoints }),
967
+ instanceId: props.instanceId
968
+ });
969
+ if (metaRes?.schema) userSchema.value = metaRes.schema;
970
+ else userSchema.value = null;
971
+ } catch {
972
+ userSchema.value = null;
973
+ }
974
+ } else userSchema.value = null;
975
+ user.value = profileData;
912
976
  userProfile.value = {
913
- flattenedProfile: claims,
914
- profile: claims
977
+ flattenedProfile: generateFlattenedUserProfile(profileData),
978
+ profile: profileData
915
979
  };
916
- isSignedIn.value = await client.isSignedIn();
980
+ isSignedIn.value = currentSignInStatus;
917
981
  } catch {} finally {
918
982
  isUpdatingSession = false;
919
983
  isLoading.value = client.isLoading();
@@ -979,6 +1043,7 @@ const ThunderIDProvider = defineComponent({
979
1043
  isLoading,
980
1044
  isSignedIn,
981
1045
  organizationHandle: props.organizationHandle,
1046
+ preferences: props.preferences,
982
1047
  reInitialize: async (config) => {
983
1048
  const result = await client.reInitialize(config);
984
1049
  return typeof result === "boolean" ? result : true;
@@ -992,6 +1057,7 @@ const ThunderIDProvider = defineComponent({
992
1057
  signUpUrl: props.signUpUrl,
993
1058
  storage: props.storage,
994
1059
  user,
1060
+ userSchema,
995
1061
  vendor
996
1062
  });
997
1063
  onMounted(async () => {
@@ -1057,15 +1123,9 @@ const ThunderIDProvider = defineComponent({
1057
1123
  },
1058
1124
  profile: userProfile.value,
1059
1125
  revalidateProfile: async () => {
1060
- try {
1061
- const claims = extractUserClaimsFromIdToken(await client.getDecodedIdToken());
1062
- user.value = claims;
1063
- userProfile.value = {
1064
- flattenedProfile: claims,
1065
- profile: claims
1066
- };
1067
- } catch {}
1068
- }
1126
+ await updateSession();
1127
+ },
1128
+ userSchema: userSchema.value
1069
1129
  }, { default: () => slots["default"]?.() }) }) }) }) });
1070
1130
  }
1071
1131
  });
@@ -1482,6 +1542,8 @@ const USER_DROPDOWN_CSS = `
1482
1542
  justify-content: center;
1483
1543
  width: 32px;
1484
1544
  height: 32px;
1545
+ max-width: 32px;
1546
+ max-height: 32px;
1485
1547
  border-radius: 50%;
1486
1548
  color: #ffffff;
1487
1549
  flex-shrink: 0;
@@ -1490,12 +1552,20 @@ const USER_DROPDOWN_CSS = `
1490
1552
  line-height: 1;
1491
1553
  user-select: none;
1492
1554
  pointer-events: none;
1555
+ object-fit: cover;
1556
+ }
1557
+
1558
+ img.thunderid-user-dropdown__avatar {
1559
+ object-fit: cover;
1560
+ border-radius: 50%;
1493
1561
  }
1494
1562
 
1495
1563
  /* sm — 28 px */
1496
1564
  .thunderid-user-dropdown__avatar--sm {
1497
1565
  width: 28px;
1498
1566
  height: 28px;
1567
+ max-width: 28px;
1568
+ max-height: 28px;
1499
1569
  font-size: var(--thunder-typography-fontSize-xs);
1500
1570
  }
1501
1571
 
@@ -1503,6 +1573,8 @@ const USER_DROPDOWN_CSS = `
1503
1573
  .thunderid-user-dropdown__avatar--lg {
1504
1574
  width: 38px;
1505
1575
  height: 38px;
1576
+ max-width: 38px;
1577
+ max-height: 38px;
1506
1578
  font-size: var(--thunder-typography-fontSize-md);
1507
1579
  }
1508
1580
 
@@ -1622,6 +1694,12 @@ const USER_DROPDOWN_CSS = `
1622
1694
  font-weight: var(--thunder-typography-fontWeight-semibold);
1623
1695
  line-height: 1;
1624
1696
  user-select: none;
1697
+ object-fit: cover;
1698
+ }
1699
+
1700
+ img.thunderid-user-dropdown__menu-header-avatar {
1701
+ object-fit: cover;
1702
+ border-radius: 50%;
1625
1703
  }
1626
1704
 
1627
1705
  .thunderid-user-dropdown__menu-header-info {
@@ -1708,6 +1786,7 @@ const USER_DROPDOWN_CSS = `
1708
1786
  justify-content: center;
1709
1787
  z-index: 9999;
1710
1788
  backdrop-filter: blur(3px);
1789
+ box-sizing: border-box;
1711
1790
  animation: thunderid-overlay-enter var(--thunder-transition-fast) ease;
1712
1791
  }
1713
1792
 
@@ -1722,11 +1801,14 @@ const USER_DROPDOWN_CSS = `
1722
1801
  background: var(--thunder-color-background-surface);
1723
1802
  border-radius: var(--thunder-border-radius-large);
1724
1803
  box-shadow: var(--thunder-shadow-large);
1725
- max-width: 480px;
1804
+ max-width: 640px;
1726
1805
  width: 92%;
1727
1806
  max-height: 90vh;
1728
1807
  overflow-y: auto;
1729
1808
  position: relative;
1809
+ margin: auto;
1810
+ padding: calc(var(--thunder-spacing-unit) * 3);
1811
+ box-sizing: border-box;
1730
1812
  animation: thunderid-modal-enter var(--thunder-transition-normal) ease;
1731
1813
  }
1732
1814
 
@@ -1779,51 +1861,24 @@ var UserDropdown_css_default = USER_DROPDOWN_CSS;
1779
1861
  //#region src/components/presentation/user-profile/UserProfile.css.ts
1780
1862
  /**
1781
1863
  * Styles for the UserProfile presentation component.
1782
- *
1783
- * BEM block: `.thunderid-user-profile`
1784
- *
1785
- * Modifiers:
1786
- * --compact – reduced field padding for modal / dropdown embedding
1787
- *
1788
- * New elements in this version:
1789
- * __hero – avatar + name + subtitle banner
1790
- * __avatar--sm/md/lg – avatar size variants
1791
- * __hero-name – prominent display name
1792
- * __hero-subtitle – secondary line (email / username)
1864
+ * Parity target: `@thunderid/react` BaseUserProfile.styles.ts
1793
1865
  */
1794
1866
  const USER_PROFILE_CSS = `
1795
1867
  /* ============================================================
1796
- UserProfile (modern redesign)
1868
+ UserProfile (React Parity)
1797
1869
  ============================================================ */
1798
1870
 
1799
1871
  .thunderid-user-profile {
1800
1872
  display: flex;
1801
1873
  flex-direction: column;
1802
- min-width: 320px;
1803
- overflow: hidden;
1874
+ padding: calc(var(--thunder-spacing-unit) * 4);
1875
+ width: 100%;
1876
+ max-width: 600px;
1877
+ margin: 0 auto;
1804
1878
  font-family: var(--thunder-typography-fontFamily);
1805
- }
1806
-
1807
- /* ── Header ─────────────────────────────────────────────────── */
1808
-
1809
- .thunderid-user-profile__header {
1810
- display: flex;
1811
- align-items: center;
1812
- justify-content: space-between;
1813
- padding: calc(var(--thunder-spacing-unit) * 2) calc(var(--thunder-spacing-unit) * 2.5)
1814
- calc(var(--thunder-spacing-unit) * 1.75);
1815
- }
1816
-
1817
- .thunderid-user-profile__title {
1818
- margin: 0;
1819
- font-size: var(--thunder-typography-fontSize-md);
1820
- font-weight: var(--thunder-typography-fontWeight-semibold);
1821
- color: var(--thunder-color-text-primary);
1822
- letter-spacing: var(--thunder-typography-letterSpacing-tight);
1823
- }
1824
-
1825
- .thunderid-user-profile__header-divider {
1826
- margin: 0;
1879
+ background: var(--thunder-color-background-surface);
1880
+ border-radius: var(--thunder-border-radius-large, 8px);
1881
+ box-sizing: border-box;
1827
1882
  }
1828
1883
 
1829
1884
  /* ── Hero (avatar + name + subtitle) ────────────────────────── */
@@ -1831,43 +1886,35 @@ const USER_PROFILE_CSS = `
1831
1886
  .thunderid-user-profile__hero {
1832
1887
  display: flex;
1833
1888
  flex-direction: column;
1834
- align-items: center;
1835
- padding: calc(var(--thunder-spacing-unit) * 3) calc(var(--thunder-spacing-unit) * 2.5)
1836
- calc(var(--thunder-spacing-unit) * 2);
1837
- gap: calc(var(--thunder-spacing-unit) * 1.25);
1838
- background: linear-gradient(
1839
- 180deg,
1840
- var(--thunder-color-primary-light) 0%,
1841
- var(--thunder-color-background-surface) 100%
1842
- );
1889
+ align-items: flex-start;
1890
+ gap: calc(var(--thunder-spacing-unit) * 1);
1891
+ padding-bottom: calc(var(--thunder-spacing-unit) * 2);
1892
+ margin-bottom: calc(var(--thunder-spacing-unit) * 2);
1843
1893
  border-bottom: 1px solid var(--thunder-color-border);
1844
1894
  }
1845
1895
 
1846
1896
  .thunderid-user-profile__avatar-wrapper {
1847
1897
  position: relative;
1848
1898
  border-radius: 50%;
1849
- padding: 3px;
1850
- background: linear-gradient(
1851
- 135deg,
1852
- var(--thunder-color-primary-main),
1853
- var(--thunder-color-primary-dark)
1854
- );
1855
- box-shadow: 0 4px 14px rgba(75, 110, 245, 0.28);
1856
1899
  }
1857
1900
 
1858
1901
  .thunderid-user-profile__avatar {
1859
- width: var(--thunder-avatar-size, 72px);
1860
- height: var(--thunder-avatar-size, 72px);
1902
+ border-radius: 50%;
1903
+ object-fit: cover;
1904
+ }
1905
+
1906
+ img.thunderid-user-profile__avatar {
1907
+ border-radius: 50%;
1908
+ object-fit: cover;
1909
+ width: 70px;
1910
+ height: 70px;
1861
1911
  border-radius: 50%;
1862
1912
  display: flex;
1863
1913
  align-items: center;
1864
1914
  justify-content: center;
1865
1915
  flex-shrink: 0;
1866
- border: 2px solid var(--thunder-color-background-surface);
1867
1916
  }
1868
1917
 
1869
- /* Avatar size variants */
1870
-
1871
1918
  .thunderid-user-profile__avatar--sm {
1872
1919
  width: 48px;
1873
1920
  height: 48px;
@@ -1887,17 +1934,17 @@ const USER_PROFILE_CSS = `
1887
1934
  }
1888
1935
 
1889
1936
  .thunderid-user-profile__avatar--lg {
1890
- width: 80px;
1891
- height: 80px;
1937
+ width: 70px;
1938
+ height: 70px;
1892
1939
  }
1893
1940
 
1894
1941
  .thunderid-user-profile__avatar--lg .thunderid-user-profile__avatar-initials {
1895
- font-size: 1.625rem;
1942
+ font-size: 1.5rem;
1896
1943
  }
1897
1944
 
1898
1945
  .thunderid-user-profile__avatar-initials {
1899
1946
  color: #ffffff;
1900
- font-weight: var(--thunder-typography-fontWeight-semibold);
1947
+ font-weight: var(--thunder-typography-fontWeight-semibold, 600);
1901
1948
  line-height: 1;
1902
1949
  letter-spacing: 0.02em;
1903
1950
  pointer-events: none;
@@ -1907,37 +1954,36 @@ const USER_PROFILE_CSS = `
1907
1954
  .thunderid-user-profile__hero-info {
1908
1955
  display: flex;
1909
1956
  flex-direction: column;
1910
- align-items: center;
1911
- gap: calc(var(--thunder-spacing-unit) * 0.375);
1912
- text-align: center;
1957
+ align-items: flex-start;
1958
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
1913
1959
  }
1914
1960
 
1915
1961
  .thunderid-user-profile__hero-name {
1916
- font-size: var(--thunder-typography-fontSize-lg);
1917
- font-weight: var(--thunder-typography-fontWeight-semibold);
1962
+ font-size: var(--thunder-typography-fontSize-xl, 1.5rem);
1963
+ font-weight: var(--thunder-typography-fontWeight-semibold, 600);
1918
1964
  color: var(--thunder-color-text-primary);
1919
- line-height: var(--thunder-typography-lineHeight-tight);
1920
- letter-spacing: var(--thunder-typography-letterSpacing-tight);
1965
+ margin: 0;
1966
+ line-height: var(--thunder-typography-lineHeight-tight, 1.2);
1921
1967
  }
1922
1968
 
1923
1969
  .thunderid-user-profile__hero-subtitle {
1924
- font-size: var(--thunder-typography-fontSize-sm);
1970
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
1925
1971
  color: var(--thunder-color-text-secondary);
1926
- line-height: var(--thunder-typography-lineHeight-normal);
1972
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
1973
+ line-height: var(--thunder-typography-lineHeight-normal, 1.4);
1927
1974
  }
1928
1975
 
1929
1976
  /* ── Alerts & loading ────────────────────────────────────────── */
1930
1977
 
1931
1978
  .thunderid-user-profile__error {
1932
- margin: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5)
1933
- calc(var(--thunder-spacing-unit) * 0.5);
1979
+ margin-bottom: calc(var(--thunder-spacing-unit) * 3);
1934
1980
  }
1935
1981
 
1936
1982
  .thunderid-user-profile__loading {
1937
1983
  display: flex;
1938
1984
  align-items: center;
1939
1985
  justify-content: center;
1940
- padding: calc(var(--thunder-spacing-unit) * 3.5) 0;
1986
+ padding: calc(var(--thunder-spacing-unit) * 4) 0;
1941
1987
  }
1942
1988
 
1943
1989
  /* ── Fields ──────────────────────────────────────────────────── */
@@ -1948,141 +1994,119 @@ const USER_PROFILE_CSS = `
1948
1994
  }
1949
1995
 
1950
1996
  .thunderid-user-profile__field {
1951
- display: grid;
1952
- grid-template-columns: 38% 62%;
1953
- align-items: start;
1954
- padding: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5);
1955
- gap: calc(var(--thunder-spacing-unit) * 0.75);
1997
+ display: flex;
1998
+ align-items: center;
1999
+ justify-content: space-between;
2000
+ padding: calc(var(--thunder-spacing-unit) * 1.5) 0;
2001
+ border-bottom: 1px solid var(--thunder-color-border);
2002
+ min-height: 28px;
1956
2003
  box-sizing: border-box;
1957
- transition: background-color var(--thunder-transition-fast);
1958
2004
  }
1959
2005
 
1960
- .thunderid-user-profile__field:hover {
1961
- background-color: var(--thunder-color-action-hover);
2006
+ .thunderid-user-profile__field:last-child {
2007
+ border-bottom: none;
1962
2008
  }
1963
2009
 
1964
- .thunderid-user-profile__field + .thunderid-user-profile__field {
1965
- border-top: 1px solid var(--thunder-color-border);
2010
+ .thunderid-user-profile__field-inner {
2011
+ flex: 1;
2012
+ display: flex;
2013
+ align-items: center;
2014
+ gap: var(--thunder-spacing-unit);
1966
2015
  }
1967
2016
 
1968
2017
  .thunderid-user-profile__field-label {
2018
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
2019
+ font-weight: var(--thunder-typography-fontWeight-medium, 500);
1969
2020
  color: var(--thunder-color-text-secondary);
1970
- font-size: var(--thunder-typography-fontSize-sm);
1971
- font-weight: var(--thunder-typography-fontWeight-medium);
1972
- padding-top: 2px;
1973
- }
1974
-
1975
- .thunderid-user-profile__field-display {
1976
- display: flex;
1977
- align-items: center;
1978
- justify-content: space-between;
1979
- gap: calc(var(--thunder-spacing-unit) * 0.5);
1980
- min-height: 1.5rem;
2021
+ width: 120px;
2022
+ flex-shrink: 0;
2023
+ line-height: 28px;
2024
+ text-align: start;
1981
2025
  }
1982
2026
 
1983
2027
  .thunderid-user-profile__field-value {
1984
2028
  color: var(--thunder-color-text-primary);
1985
- word-break: break-word;
1986
2029
  flex: 1;
1987
- font-size: var(--thunder-typography-fontSize-sm);
2030
+ display: inline-block;
2031
+ align-items: center;
2032
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
2033
+ line-height: 28px;
2034
+ word-break: break-word;
2035
+ text-overflow: ellipsis;
2036
+ white-space: nowrap;
2037
+ max-width: 350px;
2038
+ text-align: start;
2039
+ overflow: hidden;
1988
2040
  }
1989
2041
 
1990
2042
  .thunderid-user-profile__field-placeholder {
1991
- color: var(--thunder-color-primary-main);
1992
- font-size: var(--thunder-typography-fontSize-sm);
2043
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
1993
2044
  font-style: italic;
1994
- flex: 1;
2045
+ color: var(--thunder-color-text-secondary);
2046
+ opacity: 0.7;
1995
2047
  cursor: pointer;
1996
2048
  text-decoration: underline;
1997
- text-decoration-style: dotted;
1998
- text-underline-offset: 2px;
1999
- opacity: 0.8;
2000
- transition: opacity var(--thunder-transition-fast);
2049
+ white-space: nowrap;
2050
+ line-height: 28px;
2001
2051
  }
2002
2052
 
2003
2053
  .thunderid-user-profile__field-placeholder:hover {
2004
2054
  opacity: 1;
2005
2055
  }
2006
2056
 
2007
- /* ── Edit button (pencil) ────────────────────────────────────── */
2057
+ .thunderid-user-profile__field-actions {
2058
+ display: flex;
2059
+ gap: calc(var(--thunder-spacing-unit) * 0.5);
2060
+ align-items: center;
2061
+ margin-inline-start: calc(var(--thunder-spacing-unit) * 4);
2062
+ }
2008
2063
 
2009
2064
  .thunderid-user-profile__field-edit-btn {
2010
2065
  display: inline-flex;
2011
2066
  align-items: center;
2012
2067
  justify-content: center;
2013
- background: none;
2068
+ background: transparent;
2014
2069
  border: none;
2015
2070
  cursor: pointer;
2016
2071
  color: var(--thunder-color-text-secondary);
2017
- flex-shrink: 0;
2018
- padding: calc(var(--thunder-spacing-unit) * 0.375);
2019
- border-radius: var(--thunder-border-radius-small);
2020
- transition:
2021
- color var(--thunder-transition-fast),
2022
- background-color var(--thunder-transition-fast),
2023
- opacity var(--thunder-transition-fast);
2024
- opacity: 0;
2072
+ padding: 0;
2073
+ min-height: auto;
2074
+ opacity: 0.7;
2025
2075
  line-height: 0;
2026
- }
2027
-
2028
- .thunderid-user-profile__field:hover .thunderid-user-profile__field-edit-btn {
2029
- opacity: 1;
2076
+ transition: opacity var(--thunder-transition-fast, 0.15s ease);
2030
2077
  }
2031
2078
 
2032
2079
  .thunderid-user-profile__field-edit-btn:hover {
2033
- color: var(--thunder-color-primary-main);
2034
- background-color: var(--thunder-color-primary-light);
2035
- }
2036
-
2037
- .thunderid-user-profile__field-edit-btn:focus-visible {
2038
2080
  opacity: 1;
2039
- outline: none;
2040
- box-shadow: 0 0 0 var(--thunder-focus-ring-width) var(--thunder-focus-ring-color);
2081
+ background: transparent;
2041
2082
  }
2042
2083
 
2043
- /* ── Edit mode ───────────────────────────────────────────────── */
2044
-
2045
2084
  .thunderid-user-profile__field-edit {
2085
+ flex: 1;
2046
2086
  display: flex;
2047
2087
  flex-direction: column;
2048
- gap: calc(var(--thunder-spacing-unit) * 0.75);
2049
- padding: calc(var(--thunder-spacing-unit) * 0.25) 0;
2088
+ gap: calc(var(--thunder-spacing-unit) * 0.5);
2050
2089
  }
2051
2090
 
2052
- .thunderid-user-profile__field-edit-actions {
2053
- display: flex;
2054
- align-items: center;
2055
- gap: calc(var(--thunder-spacing-unit) * 0.75);
2091
+ .thunderid-user-profile__field-error {
2092
+ color: var(--thunder-color-error, #d32f2f);
2093
+ font-size: var(--thunder-typography-fontSize-xs, 0.8rem);
2094
+ font-weight: var(--thunder-typography-fontWeight-medium, 500);
2095
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
2056
2096
  }
2057
2097
 
2058
- /* ── Footer slot ─────────────────────────────────────────────── */
2098
+ /* ── Footer ──────────────────────────────────────────────────── */
2059
2099
 
2060
2100
  .thunderid-user-profile__footer {
2061
- padding: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5);
2101
+ padding-top: calc(var(--thunder-spacing-unit) * 2);
2062
2102
  border-top: 1px solid var(--thunder-color-border);
2063
2103
  }
2064
2104
 
2065
2105
  /* ── Compact modifier ────────────────────────────────────────── */
2066
2106
 
2067
- .thunderid-user-profile--compact .thunderid-user-profile__hero {
2068
- padding: calc(var(--thunder-spacing-unit) * 2) calc(var(--thunder-spacing-unit) * 2);
2069
- }
2070
-
2071
- .thunderid-user-profile--compact .thunderid-user-profile__avatar--lg {
2072
- width: 56px;
2073
- height: 56px;
2074
- }
2075
-
2076
- .thunderid-user-profile--compact .thunderid-user-profile__avatar--lg .thunderid-user-profile__avatar-initials {
2077
- font-size: 1.125rem;
2078
- }
2079
-
2080
- .thunderid-user-profile--compact .thunderid-user-profile__field {
2081
- padding: calc(var(--thunder-spacing-unit) * 1) calc(var(--thunder-spacing-unit) * 2);
2082
- }
2083
-
2084
- .thunderid-user-profile--compact .thunderid-user-profile__hero-name {
2085
- font-size: var(--thunder-typography-fontSize-md);
2107
+ .thunderid-user-profile--compact {
2108
+ padding: calc(var(--thunder-spacing-unit) * 2);
2109
+ width: 100%;
2086
2110
  }
2087
2111
  `;
2088
2112
  var UserProfile_css_default = USER_PROFILE_CSS;
@@ -7524,22 +7548,31 @@ const FIELDS_TO_SKIP = [
7524
7548
  "verifiedEmailAddresses",
7525
7549
  "phoneNumbers.mobile",
7526
7550
  "emailAddresses",
7527
- "preferredMFAOption"
7551
+ "preferredMFAOption",
7552
+ "attributes",
7553
+ "isReadOnly",
7554
+ "isReadonly"
7528
7555
  ];
7529
7556
  const READONLY_FIELDS = [
7530
7557
  "username",
7531
7558
  "userName",
7532
- "user_name"
7559
+ "user_name",
7560
+ "sub",
7561
+ "id",
7562
+ "ouId",
7563
+ "attributes",
7564
+ "isReadOnly",
7565
+ "isReadonly"
7533
7566
  ];
7534
7567
  const DEFAULT_ATTRIBUTE_MAPPINGS$1 = {
7535
7568
  email: ["emails", "email"],
7536
7569
  firstName: ["name.givenName", "given_name"],
7537
7570
  lastName: ["name.familyName", "family_name"],
7538
7571
  picture: [
7539
- "profile",
7540
- "profileUrl",
7541
7572
  "picture",
7542
- "URL"
7573
+ "avatar",
7574
+ "pictureUrl",
7575
+ "attributes.picture"
7543
7576
  ],
7544
7577
  username: [
7545
7578
  "userName",
@@ -7626,6 +7659,10 @@ const BaseUserProfile = defineComponent({
7626
7659
  default: void 0,
7627
7660
  type: Function
7628
7661
  },
7662
+ preferences: {
7663
+ default: void 0,
7664
+ type: Object
7665
+ },
7629
7666
  profile: {
7630
7667
  default: null,
7631
7668
  type: Object
@@ -7642,21 +7679,38 @@ const BaseUserProfile = defineComponent({
7642
7679
  default: () => [],
7643
7680
  type: Array
7644
7681
  },
7682
+ t: {
7683
+ default: void 0,
7684
+ type: Function
7685
+ },
7645
7686
  title: {
7646
7687
  default: "Profile",
7647
7688
  type: String
7689
+ },
7690
+ userSchema: {
7691
+ default: null,
7692
+ type: Object
7648
7693
  }
7649
7694
  },
7650
7695
  setup(props, { slots }) {
7651
7696
  const editingFields = ref({});
7652
7697
  const editedValues = ref({});
7653
7698
  const px = withVendorCSSClassPrefix;
7654
- function shouldShowField(fieldName) {
7655
- if (FIELDS_TO_SKIP.includes(fieldName)) return false;
7699
+ const regexCache = /* @__PURE__ */ new Map();
7700
+ const t = (key, fallback) => {
7701
+ if (props.t) {
7702
+ const res = props.t(key);
7703
+ if (res && res !== key) return res;
7704
+ }
7705
+ return fallback ?? key;
7706
+ };
7707
+ function shouldShowField(fieldName, isSchemaBased = false) {
7708
+ if (!isSchemaBased && FIELDS_TO_SKIP.includes(fieldName)) return false;
7656
7709
  if (props.hideFields && props.hideFields.length > 0 && props.hideFields.includes(fieldName)) return false;
7657
7710
  if (props.showFields && props.showFields.length > 0) return props.showFields.includes(fieldName);
7658
7711
  return true;
7659
7712
  }
7713
+ const fieldErrors = ref({});
7660
7714
  function startEditing(fieldName, currentValue) {
7661
7715
  editedValues.value = {
7662
7716
  ...editedValues.value,
@@ -7666,9 +7720,14 @@ const BaseUserProfile = defineComponent({
7666
7720
  ...editingFields.value,
7667
7721
  [fieldName]: true
7668
7722
  };
7723
+ fieldErrors.value = {
7724
+ ...fieldErrors.value,
7725
+ [fieldName]: ""
7726
+ };
7669
7727
  }
7670
7728
  function cancelEditing(fieldName) {
7671
- const originalValue = (props.flattenedProfile ?? props.profile ?? null)?.[fieldName] ?? "";
7729
+ const data = props.flattenedProfile ?? props.profile ?? null;
7730
+ const originalValue = data?.[fieldName] ?? data?.attributes?.[fieldName] ?? "";
7672
7731
  editedValues.value = {
7673
7732
  ...editedValues.value,
7674
7733
  [fieldName]: originalValue
@@ -7677,16 +7736,54 @@ const BaseUserProfile = defineComponent({
7677
7736
  ...editingFields.value,
7678
7737
  [fieldName]: false
7679
7738
  };
7739
+ fieldErrors.value = {
7740
+ ...fieldErrors.value,
7741
+ [fieldName]: ""
7742
+ };
7680
7743
  }
7681
- function saveField(schema) {
7744
+ async function saveField(schema) {
7682
7745
  if (!props.onUpdate || !schema.name) return;
7683
- const value = editedValues.value[schema.name] ?? "";
7684
- const payload = buildPatchValue(schema.name, value, schema.schemaId, schema.multiValued);
7685
- props.onUpdate(payload);
7686
- editingFields.value = {
7687
- ...editingFields.value,
7688
- [schema.name]: false
7746
+ const fieldName = schema.name;
7747
+ const value = editedValues.value[fieldName] ?? "";
7748
+ const strVal = String(value ?? "").trim();
7749
+ const fieldLabel = schema.displayName || formatLabel(fieldName);
7750
+ if (schema.required && !strVal) {
7751
+ fieldErrors.value = {
7752
+ ...fieldErrors.value,
7753
+ [fieldName]: t("userProfile.field.required", `${fieldLabel} is required.`)
7754
+ };
7755
+ return;
7756
+ }
7757
+ if (schema.regex && strVal) if (schema.regex.length > 250) console.warn(`Regex pattern for field "${fieldName}" exceeds maximum length limit (250 chars).`);
7758
+ else {
7759
+ let reg = regexCache.get(schema.regex);
7760
+ if (reg === void 0) try {
7761
+ reg = new RegExp(schema.regex);
7762
+ regexCache.set(schema.regex, reg);
7763
+ } catch (err) {
7764
+ regexCache.set(schema.regex, null);
7765
+ console.warn(`Invalid regular expression syntax in user schema for field "${fieldName}":`, err);
7766
+ }
7767
+ if (reg && !reg.test(strVal)) {
7768
+ fieldErrors.value = {
7769
+ ...fieldErrors.value,
7770
+ [fieldName]: t("userProfile.field.invalidFormat", `${fieldLabel} has an invalid format.`)
7771
+ };
7772
+ return;
7773
+ }
7774
+ }
7775
+ fieldErrors.value = {
7776
+ ...fieldErrors.value,
7777
+ [fieldName]: ""
7689
7778
  };
7779
+ const payload = buildPatchValue(fieldName, typeof value === "string" ? strVal : value, schema.schemaId, schema.multiValued);
7780
+ try {
7781
+ await props.onUpdate(payload);
7782
+ editingFields.value = {
7783
+ ...editingFields.value,
7784
+ [fieldName]: false
7785
+ };
7786
+ } catch {}
7690
7787
  }
7691
7788
  function renderInput(schema) {
7692
7789
  const fieldName = schema.name ?? "";
@@ -7739,30 +7836,29 @@ const BaseUserProfile = defineComponent({
7739
7836
  class: px("user-profile__field-placeholder"),
7740
7837
  onClick: () => startEditing(name, value)
7741
7838
  }, `Enter your ${label.toLowerCase()}`) : null;
7742
- const displayValueNode = hasValue ? h(Typography_default, {
7743
- class: px("user-profile__field-value"),
7744
- variant: "body1"
7745
- }, () => String(value)) : editablePlaceholder;
7839
+ const displayValueNode = hasValue ? h("span", { class: px("user-profile__field-value") }, String(value)) : editablePlaceholder;
7746
7840
  return h("div", {
7747
7841
  class: px("user-profile__field"),
7748
7842
  key: name
7749
- }, [h("div", { class: px("user-profile__field-label-col") }, [h(Typography_default, {
7750
- class: px("user-profile__field-label"),
7751
- variant: "body2"
7752
- }, () => label)]), h("div", { class: px("user-profile__field-value-col") }, [isEditing ? h("div", { class: px("user-profile__field-edit") }, [renderInput(schema), h("div", { class: px("user-profile__field-edit-actions") }, [h(Button_default, {
7843
+ }, [h("div", { class: px("user-profile__field-inner") }, [h("span", { class: px("user-profile__field-label") }, label), isEditing ? h("div", { class: px("user-profile__field-edit") }, [renderInput(schema), fieldErrors.value[name] ? h("div", { class: px("user-profile__field-error") }, fieldErrors.value[name]) : null]) : displayValueNode]), isEditable && !isReadonly ? h("div", { class: px("user-profile__field-actions") }, [isEditing ? [h(Button_default, {
7844
+ color: "primary",
7753
7845
  onClick: () => saveField(schema),
7754
7846
  size: "small",
7755
7847
  variant: "solid"
7756
- }, () => "Save"), h(Button_default, {
7848
+ }, () => t("userProfile.actions.save", "Save")), h(Button_default, {
7849
+ color: "secondary",
7757
7850
  onClick: () => cancelEditing(name),
7758
7851
  size: "small",
7759
- variant: "text"
7760
- }, () => "Cancel")])]) : h("div", { class: px("user-profile__field-display") }, [displayValueNode, isEditable ? h("button", {
7761
- "aria-label": `Edit ${label}`,
7852
+ variant: "solid"
7853
+ }, () => t("userProfile.actions.cancel", "Cancel"))] : hasValue ? h(Button_default, {
7762
7854
  class: px("user-profile__field-edit-btn"),
7855
+ color: "secondary",
7763
7856
  onClick: () => startEditing(name, value),
7764
- type: "button"
7765
- }, [h(PencilIcon)]) : null])])]);
7857
+ size: "small",
7858
+ startIcon: h(PencilIcon),
7859
+ title: t("userProfile.actions.edit", "Edit"),
7860
+ variant: "ghost"
7861
+ }) : null]) : null]);
7766
7862
  }
7767
7863
  function renderProfileWithoutSchemas() {
7768
7864
  const data = props.flattenedProfile || props.profile;
@@ -7773,21 +7869,20 @@ const BaseUserProfile = defineComponent({
7773
7869
  }).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => h("div", {
7774
7870
  class: px("user-profile__field"),
7775
7871
  key
7776
- }, [h("div", { class: px("user-profile__field-label-col") }, [h(Typography_default, {
7777
- class: px("user-profile__field-label"),
7778
- variant: "body2"
7779
- }, () => formatLabel(key))]), h("div", { class: px("user-profile__field-value-col") }, [h(Typography_default, {
7780
- class: px("user-profile__field-value"),
7781
- variant: "body1"
7782
- }, () => typeof value === "object" ? JSON.stringify(value) : String(value))])]));
7872
+ }, [h("div", { class: px("user-profile__field-inner") }, [h("span", { class: px("user-profile__field-label") }, formatLabel(key)), h("span", { class: px("user-profile__field-value") }, typeof value === "object" ? JSON.stringify(value) : String(value))])]));
7783
7873
  }
7784
7874
  function renderHero(currentUser) {
7785
7875
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser);
7786
7876
  const email = getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser) || getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser);
7877
+ const picture = getMappedUserProfileValue_default("picture", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser) || null;
7787
7878
  const avatarGradient = getAvatarGradient$1(String(currentUser["username"] || currentUser["userName"] || currentUser["email"] || currentUser["sub"] || displayName));
7788
7879
  const initials = displayName.split(" ").map((w) => w.charAt(0)).slice(0, 2).join("").toUpperCase() || "?";
7789
7880
  const avatarSizeClass = px(`user-profile__avatar--${props.avatarSize ?? "lg"}`);
7790
- return h("div", { class: px("user-profile__hero") }, [h("div", { class: px("user-profile__avatar-wrapper") }, [h("div", {
7881
+ return h("div", { class: px("user-profile__hero") }, [h("div", { class: px("user-profile__avatar-wrapper") }, [picture ? h("img", {
7882
+ alt: displayName,
7883
+ class: [px("user-profile__avatar"), avatarSizeClass].join(" "),
7884
+ src: picture
7885
+ }) : h("div", {
7791
7886
  class: [px("user-profile__avatar"), avatarSizeClass].join(" "),
7792
7887
  style: { background: avatarGradient }
7793
7888
  }, [h("span", { class: px("user-profile__avatar-initials") }, initials)])]), h("div", { class: px("user-profile__hero-info") }, [h("span", { class: px("user-profile__hero-name") }, displayName), email ? h("span", { class: px("user-profile__hero-subtitle") }, String(email)) : null])]);
@@ -7813,15 +7908,31 @@ const BaseUserProfile = defineComponent({
7813
7908
  props.className ?? ""
7814
7909
  ].filter(Boolean).join(" ");
7815
7910
  const children = [];
7816
- children.push(h("div", { class: px("user-profile__header") }, [h("span", { class: px("user-profile__title") }, props.title ?? "Profile")]));
7817
- children.push(h(Divider_default, { class: px("user-profile__header-divider") }));
7818
7911
  if (props.showAvatar !== false && currentUser) children.push(renderHero(currentUser));
7819
7912
  if (props.error) children.push(h(Alert_default, {
7820
7913
  class: px("user-profile__error"),
7821
7914
  severity: "error"
7822
7915
  }, () => props.error));
7823
7916
  if (props.isLoading) children.push(h("div", { class: px("user-profile__loading") }, [h(Spinner_default)]));
7824
- else if (hasSchemas) {
7917
+ else if (props.userSchema && typeof props.userSchema === "object" && Object.keys(props.userSchema).length > 0) {
7918
+ const fieldRows = Object.entries(props.userSchema).filter(([key, metaAttr]) => {
7919
+ if (metaAttr?.credential) return false;
7920
+ return shouldShowField(key, true);
7921
+ }).map(([key, metaAttr]) => {
7922
+ const val = editedValues.value?.[key] ?? currentUser?.attributes?.[key] ?? currentUser?.[key] ?? "";
7923
+ const isReadonly = metaAttr.readOnly === true || metaAttr.mutability === "READ_ONLY" || READONLY_FIELDS.includes(key);
7924
+ return {
7925
+ displayName: metaAttr.displayName ?? (key ? startCase(key) : ""),
7926
+ mutability: isReadonly ? "READ_ONLY" : "READ_WRITE",
7927
+ name: key,
7928
+ regex: metaAttr.regex,
7929
+ required: !!metaAttr.required,
7930
+ type: (metaAttr.type ?? "STRING").toUpperCase(),
7931
+ value: val
7932
+ };
7933
+ }).map((schema) => renderSchemaFieldRow(schema)).filter((node) => node !== null);
7934
+ children.push(h("div", { class: px("user-profile__fields") }, fieldRows));
7935
+ } else if (hasSchemas) {
7825
7936
  const fieldRows = schemas.filter((s) => s.name && shouldShowField(s.name)).sort((a, b) => {
7826
7937
  return (a.displayOrder ? parseInt(a.displayOrder, 10) : 999) - (b.displayOrder ? parseInt(b.displayOrder, 10) : 999);
7827
7938
  }).map((schema) => {
@@ -7851,7 +7962,7 @@ const updateMeProfile$1 = async ({ fetcher, instanceId = 0,...requestConfig }) =
7851
7962
  const response = await FetchHttpClient.getInstance(instanceId).request({
7852
7963
  data: config.body ? JSON.parse(config.body) : void 0,
7853
7964
  headers: config.headers,
7854
- method: config.method || "PATCH",
7965
+ method: config.method || "PUT",
7855
7966
  url
7856
7967
  });
7857
7968
  return {
@@ -7902,6 +8013,10 @@ const UserProfile = defineComponent({
7902
8013
  default: () => [],
7903
8014
  type: Array
7904
8015
  },
8016
+ preferences: {
8017
+ default: void 0,
8018
+ type: Object
8019
+ },
7905
8020
  showAvatar: {
7906
8021
  default: true,
7907
8022
  type: Boolean
@@ -7916,19 +8031,37 @@ const UserProfile = defineComponent({
7916
8031
  }
7917
8032
  },
7918
8033
  setup(props, { slots }) {
7919
- const { baseUrl, endpoints, instanceId } = useThunderID_default();
7920
- const { flattenedProfile, profile, onUpdateProfile } = useUser_default();
8034
+ const { baseUrl, endpoints, instanceId, preferences: contextPreferences } = useThunderID_default();
8035
+ const { flattenedProfile, profile, onUpdateProfile, updateProfile, userSchema } = useUser_default();
7921
8036
  const { t } = useI18n_default();
8037
+ const resolvedPreferences = computed(() => ({
8038
+ ...contextPreferences,
8039
+ ...props.preferences,
8040
+ user: {
8041
+ ...contextPreferences?.user,
8042
+ ...props.preferences?.user
8043
+ }
8044
+ }));
8045
+ const isEditableProfile = computed(() => resolvedPreferences.value?.user?.fetchUserProfile === false ? false : props.editable);
7922
8046
  const error = ref(null);
7923
8047
  async function handleProfileUpdate(payload) {
7924
- if (!baseUrl) return;
7925
8048
  error.value = null;
7926
8049
  try {
8050
+ const updatedAttributes = deepMerge((profile?.value?.profile ?? profile?.value)?.["attributes"] ?? {}, payload);
8051
+ Object.keys(updatedAttributes).forEach((key) => {
8052
+ if (updatedAttributes[key] === void 0 || updatedAttributes[key] === null) delete updatedAttributes[key];
8053
+ });
8054
+ if (updateProfile) {
8055
+ const res = await updateProfile({ payload: updatedAttributes });
8056
+ if (res && !res.success && res.error) error.value = res.error;
8057
+ return;
8058
+ }
8059
+ if (!baseUrl) return;
7927
8060
  onUpdateProfile(await updateMeProfile_default({
7928
8061
  baseUrl,
7929
8062
  url: resolveResourceEndpoint("usersMe", { endpoints }),
7930
8063
  instanceId,
7931
- payload
8064
+ payload: updatedAttributes
7932
8065
  }));
7933
8066
  } catch (caughtError) {
7934
8067
  let message = t("user.profile.update.generic.error") || "Failed to update profile. Please try again.";
@@ -7943,15 +8076,18 @@ const UserProfile = defineComponent({
7943
8076
  class: withVendorCSSClassPrefix("user-profile--styled"),
7944
8077
  className: props.className,
7945
8078
  compact: props.compact,
7946
- editable: props.editable,
8079
+ editable: isEditableProfile.value,
7947
8080
  error: error.value,
7948
8081
  flattenedProfile: flattenedProfile?.value,
7949
8082
  hideFields: props.hideFields,
7950
- onUpdate: handleProfileUpdate,
8083
+ onUpdate: isEditableProfile.value ? handleProfileUpdate : void 0,
8084
+ preferences: resolvedPreferences.value,
7951
8085
  profile: profile?.value?.profile ?? flattenedProfile?.value,
7952
8086
  showAvatar: props.showAvatar,
7953
8087
  showFields: props.showFields,
7954
- title: props.title
8088
+ t,
8089
+ title: props.title,
8090
+ userSchema: userSchema?.value
7955
8091
  }, slots);
7956
8092
  }
7957
8093
  });
@@ -7963,18 +8099,18 @@ const DEFAULT_ATTRIBUTE_MAPPINGS = {
7963
8099
  email: ["emails", "email"],
7964
8100
  firstName: ["name.givenName", "given_name"],
7965
8101
  lastName: ["name.familyName", "family_name"],
8102
+ picture: [
8103
+ "picture",
8104
+ "avatar",
8105
+ "pictureUrl",
8106
+ "attributes.picture"
8107
+ ],
7966
8108
  username: [
7967
8109
  "userName",
7968
8110
  "username",
7969
8111
  "user_name"
7970
8112
  ]
7971
8113
  };
7972
- /** Approximate min-width for each size, used for auto-alignment decisions. */
7973
- const MENU_MIN_WIDTHS = {
7974
- lg: 280,
7975
- md: 220,
7976
- sm: 180
7977
- };
7978
8114
  const AVATAR_GRADIENTS = [
7979
8115
  "linear-gradient(135deg, #4b6ef5 0%, #7c3aed 100%)",
7980
8116
  "linear-gradient(135deg, #0ea5e9 0%, #4b6ef5 100%)",
@@ -7996,16 +8132,19 @@ function resolveUserInfo(user) {
7996
8132
  displayName: "User",
7997
8133
  gradient: AVATAR_GRADIENTS[0],
7998
8134
  initials: "?",
8135
+ picture: null,
7999
8136
  subtitle: ""
8000
8137
  };
8001
8138
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS, user) || "User";
8002
8139
  const initials = displayName.split(" ").map((w) => w.charAt(0)).slice(0, 2).join("").toUpperCase() || "?";
8140
+ const picture = getMappedUserProfileValue_default("picture", DEFAULT_ATTRIBUTE_MAPPINGS, user) || null;
8003
8141
  const seed = String(getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || displayName);
8004
8142
  const subtitle = String(getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || "");
8005
8143
  return {
8006
8144
  displayName,
8007
8145
  gradient: getAvatarGradient(seed),
8008
8146
  initials,
8147
+ picture,
8009
8148
  subtitle
8010
8149
  };
8011
8150
  }
@@ -8061,13 +8200,46 @@ const BaseUserDropdown = defineComponent({
8061
8200
  setup(props, { slots }) {
8062
8201
  const isOpen = ref(false);
8063
8202
  const containerRef = ref(null);
8203
+ const modalOverlayRef = ref(null);
8204
+ const avatarImageError = ref(false);
8064
8205
  const px = withVendorCSSClassPrefix;
8206
+ watch(() => resolveUserInfo(props.user ?? null).picture, () => {
8207
+ avatarImageError.value = false;
8208
+ });
8065
8209
  function handleClickOutside(event) {
8066
8210
  if (containerRef.value && !containerRef.value.contains(event.target)) isOpen.value = false;
8067
8211
  }
8212
+ function handleModalClose() {
8213
+ props.onProfileModalClose?.();
8214
+ (containerRef.value?.querySelector(`.${px("user-dropdown__trigger")}`))?.focus();
8215
+ }
8068
8216
  function handleKeyDown(event) {
8069
- if (event.key === "Escape") isOpen.value = false;
8217
+ if (props.isProfileModalOpen) {
8218
+ if (event.key === "Escape") handleModalClose();
8219
+ else if (event.key === "Tab") {
8220
+ const overlay = modalOverlayRef.value;
8221
+ if (overlay) {
8222
+ const focusables = overlay.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
8223
+ if (focusables.length > 0) {
8224
+ const first = focusables[0];
8225
+ const last = focusables[focusables.length - 1];
8226
+ if (event.shiftKey && document.activeElement === first) {
8227
+ event.preventDefault();
8228
+ last.focus();
8229
+ } else if (!event.shiftKey && document.activeElement === last) {
8230
+ event.preventDefault();
8231
+ first.focus();
8232
+ }
8233
+ }
8234
+ }
8235
+ }
8236
+ } else if (event.key === "Escape") isOpen.value = false;
8070
8237
  }
8238
+ watch(() => props.isProfileModalOpen, (open) => {
8239
+ if (open) nextTick(() => {
8240
+ (modalOverlayRef.value?.querySelector(`.${px("user-dropdown__modal-close")}`))?.focus();
8241
+ });
8242
+ });
8071
8243
  onMounted(() => {
8072
8244
  document.addEventListener("click", handleClickOutside);
8073
8245
  document.addEventListener("keydown", handleKeyDown);
@@ -8080,8 +8252,7 @@ const BaseUserDropdown = defineComponent({
8080
8252
  if (props.menuAlign !== "auto") return props.menuAlign ?? "right";
8081
8253
  if (!containerRef.value) return "right";
8082
8254
  const rect = containerRef.value.getBoundingClientRect();
8083
- const menuWidth = MENU_MIN_WIDTHS[props.size ?? "md"] ?? 220;
8084
- return window.innerWidth - rect.right >= menuWidth ? "right" : "left";
8255
+ return window.innerWidth - rect.left >= rect.right ? "left" : "right";
8085
8256
  }
8086
8257
  return () => {
8087
8258
  if (slots.default) return slots.default({
@@ -8091,7 +8262,7 @@ const BaseUserDropdown = defineComponent({
8091
8262
  },
8092
8263
  user: props.user
8093
8264
  });
8094
- const { displayName, initials, gradient, subtitle } = resolveUserInfo(props.user ?? null);
8265
+ const { displayName, initials, gradient, picture, subtitle } = resolveUserInfo(props.user ?? null);
8095
8266
  const size = props.size ?? "md";
8096
8267
  const avatarSizeClass = size !== "md" ? px(`user-dropdown__avatar--${size}`) : "";
8097
8268
  const triggerClass = [px("user-dropdown__trigger"), isOpen.value ? px("user-dropdown__trigger--open") : ""].filter(Boolean).join(" ");
@@ -8104,7 +8275,14 @@ const BaseUserDropdown = defineComponent({
8104
8275
  isOpen.value = !isOpen.value;
8105
8276
  },
8106
8277
  type: "button"
8107
- }, [h("span", {
8278
+ }, [picture && !avatarImageError.value ? h("img", {
8279
+ alt: displayName,
8280
+ class: [px("user-dropdown__avatar"), avatarSizeClass].filter(Boolean).join(" "),
8281
+ onError: () => {
8282
+ avatarImageError.value = true;
8283
+ },
8284
+ src: picture
8285
+ }) : h("span", {
8108
8286
  class: [px("user-dropdown__avatar"), avatarSizeClass].filter(Boolean).join(" "),
8109
8287
  style: { background: gradient }
8110
8288
  }, initials), props.showChevron ? h("span", { class: px("user-dropdown__chevron") }, [h(ChevronDownIcon, { size: 14 })]) : null]);
@@ -8118,7 +8296,11 @@ const BaseUserDropdown = defineComponent({
8118
8296
  sizeClass
8119
8297
  ].filter(Boolean).join(" ");
8120
8298
  const menuChildren = [];
8121
- menuChildren.push(h("div", { class: px("user-dropdown__menu-header") }, [h("div", {
8299
+ menuChildren.push(h("div", { class: px("user-dropdown__menu-header") }, [picture ? h("img", {
8300
+ alt: displayName,
8301
+ class: px("user-dropdown__menu-header-avatar"),
8302
+ src: picture
8303
+ }) : h("div", {
8122
8304
  class: px("user-dropdown__menu-header-avatar"),
8123
8305
  style: { background: gradient }
8124
8306
  }, initials), h("div", { class: px("user-dropdown__menu-header-info") }, [h("span", { class: px("user-dropdown__menu-header-name") }, displayName), subtitle ? h("span", { class: px("user-dropdown__menu-header-subtitle") }, subtitle) : null])]));
@@ -8164,17 +8346,21 @@ const BaseUserDropdown = defineComponent({
8164
8346
  class: [px("user-dropdown"), props.className].filter(Boolean).join(" "),
8165
8347
  ref: containerRef
8166
8348
  }, [trigger, menu]);
8167
- if (props.isProfileModalOpen) return h("div", [container, h("div", {
8349
+ if (props.isProfileModalOpen) return h("div", [container, h(Teleport, { to: "body" }, [h("div", {
8350
+ "aria-label": "User profile",
8351
+ "aria-modal": "true",
8168
8352
  class: px("user-dropdown__modal-overlay"),
8353
+ ref: modalOverlayRef,
8354
+ role: "dialog",
8169
8355
  onClick: (e) => {
8170
- if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) props.onProfileModalClose?.();
8356
+ if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) handleModalClose();
8171
8357
  }
8172
8358
  }, [h("div", { class: px("user-dropdown__modal-content") }, [h("button", {
8173
8359
  "aria-label": "Close profile",
8174
8360
  class: px("user-dropdown__modal-close"),
8175
- onClick: props.onProfileModalClose,
8361
+ onClick: handleModalClose,
8176
8362
  type: "button"
8177
- }, [h(XIcon, { size: 18 })]), props.profileContent])])]);
8363
+ }, [h(XIcon, { size: 18 })]), props.profileContent])])])]);
8178
8364
  return container;
8179
8365
  };
8180
8366
  }
@@ -9516,4 +9702,4 @@ const createCallbackRoute = (options = {}) => {
9516
9702
  };
9517
9703
 
9518
9704
  //#endregion
9519
- export { AcceptInvite_default as AcceptInvite, Alert_default as Alert, ArrowLeftRightIcon, BaseAcceptInvite_default as BaseAcceptInvite, BaseInviteUser_default as BaseInviteUser, BaseLanguageSwitcher_default as BaseLanguageSwitcher, BaseSignIn_default as BaseSignIn, BaseSignInButton_default as BaseSignInButton, BaseSignOutButton_default as BaseSignOutButton, BaseSignUp_default as BaseSignUp, BaseSignUpButton_default as BaseSignUpButton, BaseUserDropdown_default as BaseUserDropdown, BaseUserProfile_default as BaseUserProfile, BuildingIcon, Button_default as Button, Callback_default as Callback, Card_default as Card, CheckIcon, Checkbox_default as Checkbox, ChevronDownIcon, CircleAlertIcon, CircleCheckIcon, DatePicker_default as DatePicker, Divider_default as Divider, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowEventType, EmbeddedFlowTextVariant, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowType, EyeIcon, EyeOffIcon, FLOW_KEY, FLOW_META_KEY, FacebookButton_default as FacebookButton, FieldFactory_default as FieldFactory, FieldType, FlowMetaProvider_default as FlowMetaProvider, FlowProvider_default as FlowProvider, GitHubButton_default as GitHubButton, GlobeIcon, GoogleButton_default as GoogleButton, I18N_KEY, I18nProvider_default as I18nProvider, InfoIcon, InviteUser_default as InviteUser, LanguageSwitcher_default as LanguageSwitcher, Loading_default as Loading, LogOutIcon, Logo_default as Logo, MicrosoftButton_default as MicrosoftButton, OtpField_default as OtpField, PasswordField_default as PasswordField, PencilIcon, PlusIcon, Select_default as Select, SignIn_default as SignIn, SignInButton_default as SignInButton, SignOutButton_default as SignOutButton, SignUp_default as SignUp, SignUpButton_default as SignUpButton, SignedIn_default as SignedIn, SignedOut_default as SignedOut, Spinner_default as Spinner, THEME_KEY, THUNDERID_KEY, TextField_default as TextField, ThemeProvider_default as ThemeProvider, ThunderIDPlugin_default as ThunderIDPlugin, ThunderIDProvider_default as ThunderIDProvider, ThunderIDRuntimeError, ThunderIDVueClient_default as ThunderIDVueClient, TriangleAlertIcon, Typography_default as Typography, USER_KEY, User_default as User, UserDropdown_default as UserDropdown, UserIcon, UserProfile_default as UserProfile, UserProvider_default as UserProvider, XIcon, buildThemeConfigFromFlowMeta_default as buildThemeConfigFromFlowMeta, createCallbackRoute, createClassObserver, createField, createMediaQueryListener, createThunderIDGuard, detectThemeMode, getActiveTheme, getAuthComponentHeadings_default as getAuthComponentHeadings, handleWebAuthnAuthentication, hasAuthParamsInUrl, http, initiateOAuthRedirect, navigate, useFlow_default as useFlow, useFlowMeta_default as useFlowMeta, useI18n_default as useI18n, useOAuthCallback, useTheme_default as useTheme, useThunderID_default as useThunderID, useUser_default as useUser, validateFieldValue };
9705
+ export { AcceptInvite_default as AcceptInvite, Alert_default as Alert, ArrowLeftRightIcon, BaseAcceptInvite_default as BaseAcceptInvite, BaseInviteUser_default as BaseInviteUser, BaseLanguageSwitcher_default as BaseLanguageSwitcher, BaseSignIn_default as BaseSignIn, BaseSignInButton_default as BaseSignInButton, BaseSignOutButton_default as BaseSignOutButton, BaseSignUp_default as BaseSignUp, BaseSignUpButton_default as BaseSignUpButton, BaseUserDropdown_default as BaseUserDropdown, BaseUserProfile_default as BaseUserProfile, BuildingIcon, Button_default as Button, Callback_default as Callback, Card_default as Card, CheckIcon, Checkbox_default as Checkbox, ChevronDownIcon, CircleAlertIcon, CircleCheckIcon, DatePicker_default as DatePicker, Divider_default as Divider, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowEventType, EmbeddedFlowTextVariant, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowType, EyeIcon, EyeOffIcon, FLOW_KEY, FLOW_META_KEY, FacebookButton_default as FacebookButton, FieldFactory_default as FieldFactory, FieldType, FlowMetaProvider_default as FlowMetaProvider, FlowProvider_default as FlowProvider, GitHubButton_default as GitHubButton, GlobeIcon, GoogleButton_default as GoogleButton, I18N_KEY, I18nProvider_default as I18nProvider, InfoIcon, InviteUser_default as InviteUser, LanguageSwitcher_default as LanguageSwitcher, Loading_default as Loading, LogOutIcon, Logo_default as Logo, MicrosoftButton_default as MicrosoftButton, OtpField_default as OtpField, PasswordField_default as PasswordField, PencilIcon, PlusIcon, Select_default as Select, SignIn_default as SignIn, SignInButton_default as SignInButton, SignOutButton_default as SignOutButton, SignUp_default as SignUp, SignUpButton_default as SignUpButton, SignedIn_default as SignedIn, SignedOut_default as SignedOut, Spinner_default as Spinner, THEME_KEY, THUNDERID_KEY, TextField_default as TextField, ThemeProvider_default as ThemeProvider, ThunderIDPlugin_default as ThunderIDPlugin, ThunderIDProvider_default as ThunderIDProvider, ThunderIDRuntimeError, ThunderIDVueClient_default as ThunderIDVueClient, TriangleAlertIcon, Typography_default as Typography, USER_KEY, User_default as User, UserDropdown_default as UserDropdown, UserIcon, UserProfile_default as UserProfile, UserProvider_default as UserProvider, XIcon, buildThemeConfigFromFlowMeta_default as buildThemeConfigFromFlowMeta, createCallbackRoute, createClassObserver, createField, createMediaQueryListener, createThunderIDGuard, detectThemeMode, getActiveTheme, getAuthComponentHeadings_default as getAuthComponentHeadings, getUsersMeMeta_default as getUsersMeMeta, handleWebAuthnAuthentication, hasAuthParamsInUrl, http, initiateOAuthRedirect, navigate, useFlow_default as useFlow, useFlowMeta_default as useFlowMeta, useI18n_default as useI18n, useOAuthCallback, useTheme_default as useTheme, useThunderID_default as useThunderID, useUser_default as useUser, validateFieldValue };