@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.
@@ -574,20 +574,23 @@ const UserProvider = (0, vue.defineComponent)({
574
574
  updateProfile: {
575
575
  default: void 0,
576
576
  type: Function
577
+ },
578
+ userSchema: {
579
+ default: null,
580
+ type: Object
577
581
  }
578
582
  },
579
583
  setup(props, { slots }) {
580
584
  const profileRef = (0, vue.computed)(() => props.profile);
585
+ const flattenedProfileRef = (0, vue.computed)(() => props.profile?.flattenedProfile ?? null);
586
+ const userSchemaRef = (0, vue.computed)(() => props.profile?.userSchema ?? props.userSchema ?? null);
581
587
  (0, vue.provide)(USER_KEY, {
582
- flattenedProfile: (0, vue.computed)(() => props.profile?.flattenedProfile ?? null),
588
+ flattenedProfile: flattenedProfileRef,
583
589
  onUpdateProfile: props.onUpdateProfile ?? (() => {}),
584
590
  profile: profileRef,
585
591
  revalidateProfile: props.revalidateProfile,
586
- updateProfile: props.updateProfile ?? (async () => ({
587
- data: { user: {} },
588
- error: "updateProfile callback not provided",
589
- success: false
590
- }))
592
+ updateProfile: props.updateProfile,
593
+ userSchema: userSchemaRef
591
594
  });
592
595
  return () => (0, vue.h)("div", { style: "display:contents" }, slots["default"]?.());
593
596
  }
@@ -618,6 +621,34 @@ const getUsersMe = async ({ fetcher, instanceId = 0,...requestConfig }) => {
618
621
  };
619
622
  var getUsersMe_default = getUsersMe;
620
623
 
624
+ //#endregion
625
+ //#region src/api/getUsersMeMeta.ts
626
+ /**
627
+ * Retrieves the user schema metadata from the specified /users/me/meta endpoint.
628
+ * Uses ThunderID SPA client FetchHttpClient by default with multi-instance support.
629
+ */
630
+ const getUsersMeMeta = async ({ fetcher, instanceId = 0,...requestConfig }) => {
631
+ const defaultFetcher = async (url, config) => {
632
+ const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
633
+ headers: config.headers,
634
+ method: config.method ?? "GET",
635
+ url
636
+ });
637
+ return {
638
+ json: () => Promise.resolve(response.data),
639
+ ok: response.status >= 200 && response.status < 300,
640
+ status: response.status,
641
+ statusText: response.statusText || "",
642
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
643
+ };
644
+ };
645
+ return (0, __thunderid_browser.getUsersMeMeta)({
646
+ ...requestConfig,
647
+ fetcher: fetcher ?? defaultFetcher
648
+ });
649
+ };
650
+ var getUsersMeMeta_default = getUsersMeMeta;
651
+
621
652
  //#endregion
622
653
  //#region src/ThunderIDVueClient.ts
623
654
  /**
@@ -863,6 +894,10 @@ const ThunderIDProvider = (0, vue.defineComponent)({
863
894
  default: void 0,
864
895
  type: String
865
896
  },
897
+ preferences: {
898
+ default: void 0,
899
+ type: Object
900
+ },
866
901
  scopes: {
867
902
  default: void 0,
868
903
  type: [Array, String]
@@ -900,6 +935,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
900
935
  const isLoading = (0, vue.ref)(true);
901
936
  const user = (0, vue.shallowRef)(null);
902
937
  const userProfile = (0, vue.shallowRef)(null);
938
+ const userSchema = (0, vue.ref)(null);
903
939
  const resolvedBaseUrl = (0, vue.ref)(props.baseUrl);
904
940
  let isUpdatingSession = false;
905
941
  let signInCheckInterval;
@@ -914,6 +950,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
914
950
  endpoints: props.endpoints,
915
951
  organizationChain: props.organizationChain,
916
952
  organizationHandle: props.organizationHandle,
953
+ preferences: props.preferences,
917
954
  scopes: props.scopes,
918
955
  signInOptions: props.signInOptions,
919
956
  signInUrl: props.signInUrl,
@@ -933,13 +970,40 @@ const ThunderIDProvider = (0, vue.defineComponent)({
933
970
  baseUrl = `${(await client.getConfiguration()).baseUrl}/o`;
934
971
  resolvedBaseUrl.value = baseUrl;
935
972
  }
973
+ const shouldFetchProfile = props.preferences?.user?.fetchUserProfile !== false;
936
974
  const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedToken);
937
- user.value = claims;
975
+ let profileData = claims;
976
+ const currentSignInStatus = await client.isSignedIn();
977
+ if (currentSignInStatus && shouldFetchProfile) {
978
+ try {
979
+ const fetchedProfile = await getUsersMe_default({
980
+ baseUrl,
981
+ url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMe", { endpoints: props.endpoints }),
982
+ instanceId: props.instanceId
983
+ });
984
+ profileData = {
985
+ ...claims,
986
+ ...fetchedProfile
987
+ };
988
+ } catch {}
989
+ try {
990
+ const metaRes = await getUsersMeMeta_default({
991
+ baseUrl,
992
+ url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMeMeta", { endpoints: props.endpoints }),
993
+ instanceId: props.instanceId
994
+ });
995
+ if (metaRes?.schema) userSchema.value = metaRes.schema;
996
+ else userSchema.value = null;
997
+ } catch {
998
+ userSchema.value = null;
999
+ }
1000
+ } else userSchema.value = null;
1001
+ user.value = profileData;
938
1002
  userProfile.value = {
939
- flattenedProfile: claims,
940
- profile: claims
1003
+ flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(profileData),
1004
+ profile: profileData
941
1005
  };
942
- isSignedIn.value = await client.isSignedIn();
1006
+ isSignedIn.value = currentSignInStatus;
943
1007
  } catch {} finally {
944
1008
  isUpdatingSession = false;
945
1009
  isLoading.value = client.isLoading();
@@ -1005,6 +1069,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1005
1069
  isLoading,
1006
1070
  isSignedIn,
1007
1071
  organizationHandle: props.organizationHandle,
1072
+ preferences: props.preferences,
1008
1073
  reInitialize: async (config) => {
1009
1074
  const result = await client.reInitialize(config);
1010
1075
  return typeof result === "boolean" ? result : true;
@@ -1018,6 +1083,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1018
1083
  signUpUrl: props.signUpUrl,
1019
1084
  storage: props.storage,
1020
1085
  user,
1086
+ userSchema,
1021
1087
  vendor
1022
1088
  });
1023
1089
  (0, vue.onMounted)(async () => {
@@ -1083,15 +1149,9 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1083
1149
  },
1084
1150
  profile: userProfile.value,
1085
1151
  revalidateProfile: async () => {
1086
- try {
1087
- const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(await client.getDecodedIdToken());
1088
- user.value = claims;
1089
- userProfile.value = {
1090
- flattenedProfile: claims,
1091
- profile: claims
1092
- };
1093
- } catch {}
1094
- }
1152
+ await updateSession();
1153
+ },
1154
+ userSchema: userSchema.value
1095
1155
  }, { default: () => slots["default"]?.() }) }) }) }) });
1096
1156
  }
1097
1157
  });
@@ -1508,6 +1568,8 @@ const USER_DROPDOWN_CSS = `
1508
1568
  justify-content: center;
1509
1569
  width: 32px;
1510
1570
  height: 32px;
1571
+ max-width: 32px;
1572
+ max-height: 32px;
1511
1573
  border-radius: 50%;
1512
1574
  color: #ffffff;
1513
1575
  flex-shrink: 0;
@@ -1516,12 +1578,20 @@ const USER_DROPDOWN_CSS = `
1516
1578
  line-height: 1;
1517
1579
  user-select: none;
1518
1580
  pointer-events: none;
1581
+ object-fit: cover;
1582
+ }
1583
+
1584
+ img.thunderid-user-dropdown__avatar {
1585
+ object-fit: cover;
1586
+ border-radius: 50%;
1519
1587
  }
1520
1588
 
1521
1589
  /* sm — 28 px */
1522
1590
  .thunderid-user-dropdown__avatar--sm {
1523
1591
  width: 28px;
1524
1592
  height: 28px;
1593
+ max-width: 28px;
1594
+ max-height: 28px;
1525
1595
  font-size: var(--thunder-typography-fontSize-xs);
1526
1596
  }
1527
1597
 
@@ -1529,6 +1599,8 @@ const USER_DROPDOWN_CSS = `
1529
1599
  .thunderid-user-dropdown__avatar--lg {
1530
1600
  width: 38px;
1531
1601
  height: 38px;
1602
+ max-width: 38px;
1603
+ max-height: 38px;
1532
1604
  font-size: var(--thunder-typography-fontSize-md);
1533
1605
  }
1534
1606
 
@@ -1648,6 +1720,12 @@ const USER_DROPDOWN_CSS = `
1648
1720
  font-weight: var(--thunder-typography-fontWeight-semibold);
1649
1721
  line-height: 1;
1650
1722
  user-select: none;
1723
+ object-fit: cover;
1724
+ }
1725
+
1726
+ img.thunderid-user-dropdown__menu-header-avatar {
1727
+ object-fit: cover;
1728
+ border-radius: 50%;
1651
1729
  }
1652
1730
 
1653
1731
  .thunderid-user-dropdown__menu-header-info {
@@ -1734,6 +1812,7 @@ const USER_DROPDOWN_CSS = `
1734
1812
  justify-content: center;
1735
1813
  z-index: 9999;
1736
1814
  backdrop-filter: blur(3px);
1815
+ box-sizing: border-box;
1737
1816
  animation: thunderid-overlay-enter var(--thunder-transition-fast) ease;
1738
1817
  }
1739
1818
 
@@ -1748,11 +1827,14 @@ const USER_DROPDOWN_CSS = `
1748
1827
  background: var(--thunder-color-background-surface);
1749
1828
  border-radius: var(--thunder-border-radius-large);
1750
1829
  box-shadow: var(--thunder-shadow-large);
1751
- max-width: 480px;
1830
+ max-width: 640px;
1752
1831
  width: 92%;
1753
1832
  max-height: 90vh;
1754
1833
  overflow-y: auto;
1755
1834
  position: relative;
1835
+ margin: auto;
1836
+ padding: calc(var(--thunder-spacing-unit) * 3);
1837
+ box-sizing: border-box;
1756
1838
  animation: thunderid-modal-enter var(--thunder-transition-normal) ease;
1757
1839
  }
1758
1840
 
@@ -1805,51 +1887,24 @@ var UserDropdown_css_default = USER_DROPDOWN_CSS;
1805
1887
  //#region src/components/presentation/user-profile/UserProfile.css.ts
1806
1888
  /**
1807
1889
  * Styles for the UserProfile presentation component.
1808
- *
1809
- * BEM block: `.thunderid-user-profile`
1810
- *
1811
- * Modifiers:
1812
- * --compact – reduced field padding for modal / dropdown embedding
1813
- *
1814
- * New elements in this version:
1815
- * __hero – avatar + name + subtitle banner
1816
- * __avatar--sm/md/lg – avatar size variants
1817
- * __hero-name – prominent display name
1818
- * __hero-subtitle – secondary line (email / username)
1890
+ * Parity target: `@thunderid/react` BaseUserProfile.styles.ts
1819
1891
  */
1820
1892
  const USER_PROFILE_CSS = `
1821
1893
  /* ============================================================
1822
- UserProfile (modern redesign)
1894
+ UserProfile (React Parity)
1823
1895
  ============================================================ */
1824
1896
 
1825
1897
  .thunderid-user-profile {
1826
1898
  display: flex;
1827
1899
  flex-direction: column;
1828
- min-width: 320px;
1829
- overflow: hidden;
1900
+ padding: calc(var(--thunder-spacing-unit) * 4);
1901
+ width: 100%;
1902
+ max-width: 600px;
1903
+ margin: 0 auto;
1830
1904
  font-family: var(--thunder-typography-fontFamily);
1831
- }
1832
-
1833
- /* ── Header ─────────────────────────────────────────────────── */
1834
-
1835
- .thunderid-user-profile__header {
1836
- display: flex;
1837
- align-items: center;
1838
- justify-content: space-between;
1839
- padding: calc(var(--thunder-spacing-unit) * 2) calc(var(--thunder-spacing-unit) * 2.5)
1840
- calc(var(--thunder-spacing-unit) * 1.75);
1841
- }
1842
-
1843
- .thunderid-user-profile__title {
1844
- margin: 0;
1845
- font-size: var(--thunder-typography-fontSize-md);
1846
- font-weight: var(--thunder-typography-fontWeight-semibold);
1847
- color: var(--thunder-color-text-primary);
1848
- letter-spacing: var(--thunder-typography-letterSpacing-tight);
1849
- }
1850
-
1851
- .thunderid-user-profile__header-divider {
1852
- margin: 0;
1905
+ background: var(--thunder-color-background-surface);
1906
+ border-radius: var(--thunder-border-radius-large, 8px);
1907
+ box-sizing: border-box;
1853
1908
  }
1854
1909
 
1855
1910
  /* ── Hero (avatar + name + subtitle) ────────────────────────── */
@@ -1857,43 +1912,35 @@ const USER_PROFILE_CSS = `
1857
1912
  .thunderid-user-profile__hero {
1858
1913
  display: flex;
1859
1914
  flex-direction: column;
1860
- align-items: center;
1861
- padding: calc(var(--thunder-spacing-unit) * 3) calc(var(--thunder-spacing-unit) * 2.5)
1862
- calc(var(--thunder-spacing-unit) * 2);
1863
- gap: calc(var(--thunder-spacing-unit) * 1.25);
1864
- background: linear-gradient(
1865
- 180deg,
1866
- var(--thunder-color-primary-light) 0%,
1867
- var(--thunder-color-background-surface) 100%
1868
- );
1915
+ align-items: flex-start;
1916
+ gap: calc(var(--thunder-spacing-unit) * 1);
1917
+ padding-bottom: calc(var(--thunder-spacing-unit) * 2);
1918
+ margin-bottom: calc(var(--thunder-spacing-unit) * 2);
1869
1919
  border-bottom: 1px solid var(--thunder-color-border);
1870
1920
  }
1871
1921
 
1872
1922
  .thunderid-user-profile__avatar-wrapper {
1873
1923
  position: relative;
1874
1924
  border-radius: 50%;
1875
- padding: 3px;
1876
- background: linear-gradient(
1877
- 135deg,
1878
- var(--thunder-color-primary-main),
1879
- var(--thunder-color-primary-dark)
1880
- );
1881
- box-shadow: 0 4px 14px rgba(75, 110, 245, 0.28);
1882
1925
  }
1883
1926
 
1884
1927
  .thunderid-user-profile__avatar {
1885
- width: var(--thunder-avatar-size, 72px);
1886
- height: var(--thunder-avatar-size, 72px);
1928
+ border-radius: 50%;
1929
+ object-fit: cover;
1930
+ }
1931
+
1932
+ img.thunderid-user-profile__avatar {
1933
+ border-radius: 50%;
1934
+ object-fit: cover;
1935
+ width: 70px;
1936
+ height: 70px;
1887
1937
  border-radius: 50%;
1888
1938
  display: flex;
1889
1939
  align-items: center;
1890
1940
  justify-content: center;
1891
1941
  flex-shrink: 0;
1892
- border: 2px solid var(--thunder-color-background-surface);
1893
1942
  }
1894
1943
 
1895
- /* Avatar size variants */
1896
-
1897
1944
  .thunderid-user-profile__avatar--sm {
1898
1945
  width: 48px;
1899
1946
  height: 48px;
@@ -1913,17 +1960,17 @@ const USER_PROFILE_CSS = `
1913
1960
  }
1914
1961
 
1915
1962
  .thunderid-user-profile__avatar--lg {
1916
- width: 80px;
1917
- height: 80px;
1963
+ width: 70px;
1964
+ height: 70px;
1918
1965
  }
1919
1966
 
1920
1967
  .thunderid-user-profile__avatar--lg .thunderid-user-profile__avatar-initials {
1921
- font-size: 1.625rem;
1968
+ font-size: 1.5rem;
1922
1969
  }
1923
1970
 
1924
1971
  .thunderid-user-profile__avatar-initials {
1925
1972
  color: #ffffff;
1926
- font-weight: var(--thunder-typography-fontWeight-semibold);
1973
+ font-weight: var(--thunder-typography-fontWeight-semibold, 600);
1927
1974
  line-height: 1;
1928
1975
  letter-spacing: 0.02em;
1929
1976
  pointer-events: none;
@@ -1933,37 +1980,36 @@ const USER_PROFILE_CSS = `
1933
1980
  .thunderid-user-profile__hero-info {
1934
1981
  display: flex;
1935
1982
  flex-direction: column;
1936
- align-items: center;
1937
- gap: calc(var(--thunder-spacing-unit) * 0.375);
1938
- text-align: center;
1983
+ align-items: flex-start;
1984
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
1939
1985
  }
1940
1986
 
1941
1987
  .thunderid-user-profile__hero-name {
1942
- font-size: var(--thunder-typography-fontSize-lg);
1943
- font-weight: var(--thunder-typography-fontWeight-semibold);
1988
+ font-size: var(--thunder-typography-fontSize-xl, 1.5rem);
1989
+ font-weight: var(--thunder-typography-fontWeight-semibold, 600);
1944
1990
  color: var(--thunder-color-text-primary);
1945
- line-height: var(--thunder-typography-lineHeight-tight);
1946
- letter-spacing: var(--thunder-typography-letterSpacing-tight);
1991
+ margin: 0;
1992
+ line-height: var(--thunder-typography-lineHeight-tight, 1.2);
1947
1993
  }
1948
1994
 
1949
1995
  .thunderid-user-profile__hero-subtitle {
1950
- font-size: var(--thunder-typography-fontSize-sm);
1996
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
1951
1997
  color: var(--thunder-color-text-secondary);
1952
- line-height: var(--thunder-typography-lineHeight-normal);
1998
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
1999
+ line-height: var(--thunder-typography-lineHeight-normal, 1.4);
1953
2000
  }
1954
2001
 
1955
2002
  /* ── Alerts & loading ────────────────────────────────────────── */
1956
2003
 
1957
2004
  .thunderid-user-profile__error {
1958
- margin: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5)
1959
- calc(var(--thunder-spacing-unit) * 0.5);
2005
+ margin-bottom: calc(var(--thunder-spacing-unit) * 3);
1960
2006
  }
1961
2007
 
1962
2008
  .thunderid-user-profile__loading {
1963
2009
  display: flex;
1964
2010
  align-items: center;
1965
2011
  justify-content: center;
1966
- padding: calc(var(--thunder-spacing-unit) * 3.5) 0;
2012
+ padding: calc(var(--thunder-spacing-unit) * 4) 0;
1967
2013
  }
1968
2014
 
1969
2015
  /* ── Fields ──────────────────────────────────────────────────── */
@@ -1974,141 +2020,119 @@ const USER_PROFILE_CSS = `
1974
2020
  }
1975
2021
 
1976
2022
  .thunderid-user-profile__field {
1977
- display: grid;
1978
- grid-template-columns: 38% 62%;
1979
- align-items: start;
1980
- padding: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5);
1981
- gap: calc(var(--thunder-spacing-unit) * 0.75);
2023
+ display: flex;
2024
+ align-items: center;
2025
+ justify-content: space-between;
2026
+ padding: calc(var(--thunder-spacing-unit) * 1.5) 0;
2027
+ border-bottom: 1px solid var(--thunder-color-border);
2028
+ min-height: 28px;
1982
2029
  box-sizing: border-box;
1983
- transition: background-color var(--thunder-transition-fast);
1984
2030
  }
1985
2031
 
1986
- .thunderid-user-profile__field:hover {
1987
- background-color: var(--thunder-color-action-hover);
2032
+ .thunderid-user-profile__field:last-child {
2033
+ border-bottom: none;
1988
2034
  }
1989
2035
 
1990
- .thunderid-user-profile__field + .thunderid-user-profile__field {
1991
- border-top: 1px solid var(--thunder-color-border);
2036
+ .thunderid-user-profile__field-inner {
2037
+ flex: 1;
2038
+ display: flex;
2039
+ align-items: center;
2040
+ gap: var(--thunder-spacing-unit);
1992
2041
  }
1993
2042
 
1994
2043
  .thunderid-user-profile__field-label {
2044
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
2045
+ font-weight: var(--thunder-typography-fontWeight-medium, 500);
1995
2046
  color: var(--thunder-color-text-secondary);
1996
- font-size: var(--thunder-typography-fontSize-sm);
1997
- font-weight: var(--thunder-typography-fontWeight-medium);
1998
- padding-top: 2px;
1999
- }
2000
-
2001
- .thunderid-user-profile__field-display {
2002
- display: flex;
2003
- align-items: center;
2004
- justify-content: space-between;
2005
- gap: calc(var(--thunder-spacing-unit) * 0.5);
2006
- min-height: 1.5rem;
2047
+ width: 120px;
2048
+ flex-shrink: 0;
2049
+ line-height: 28px;
2050
+ text-align: start;
2007
2051
  }
2008
2052
 
2009
2053
  .thunderid-user-profile__field-value {
2010
2054
  color: var(--thunder-color-text-primary);
2011
- word-break: break-word;
2012
2055
  flex: 1;
2013
- font-size: var(--thunder-typography-fontSize-sm);
2056
+ display: inline-block;
2057
+ align-items: center;
2058
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
2059
+ line-height: 28px;
2060
+ word-break: break-word;
2061
+ text-overflow: ellipsis;
2062
+ white-space: nowrap;
2063
+ max-width: 350px;
2064
+ text-align: start;
2065
+ overflow: hidden;
2014
2066
  }
2015
2067
 
2016
2068
  .thunderid-user-profile__field-placeholder {
2017
- color: var(--thunder-color-primary-main);
2018
- font-size: var(--thunder-typography-fontSize-sm);
2069
+ font-size: var(--thunder-typography-fontSize-sm, 0.875rem);
2019
2070
  font-style: italic;
2020
- flex: 1;
2071
+ color: var(--thunder-color-text-secondary);
2072
+ opacity: 0.7;
2021
2073
  cursor: pointer;
2022
2074
  text-decoration: underline;
2023
- text-decoration-style: dotted;
2024
- text-underline-offset: 2px;
2025
- opacity: 0.8;
2026
- transition: opacity var(--thunder-transition-fast);
2075
+ white-space: nowrap;
2076
+ line-height: 28px;
2027
2077
  }
2028
2078
 
2029
2079
  .thunderid-user-profile__field-placeholder:hover {
2030
2080
  opacity: 1;
2031
2081
  }
2032
2082
 
2033
- /* ── Edit button (pencil) ────────────────────────────────────── */
2083
+ .thunderid-user-profile__field-actions {
2084
+ display: flex;
2085
+ gap: calc(var(--thunder-spacing-unit) * 0.5);
2086
+ align-items: center;
2087
+ margin-inline-start: calc(var(--thunder-spacing-unit) * 4);
2088
+ }
2034
2089
 
2035
2090
  .thunderid-user-profile__field-edit-btn {
2036
2091
  display: inline-flex;
2037
2092
  align-items: center;
2038
2093
  justify-content: center;
2039
- background: none;
2094
+ background: transparent;
2040
2095
  border: none;
2041
2096
  cursor: pointer;
2042
2097
  color: var(--thunder-color-text-secondary);
2043
- flex-shrink: 0;
2044
- padding: calc(var(--thunder-spacing-unit) * 0.375);
2045
- border-radius: var(--thunder-border-radius-small);
2046
- transition:
2047
- color var(--thunder-transition-fast),
2048
- background-color var(--thunder-transition-fast),
2049
- opacity var(--thunder-transition-fast);
2050
- opacity: 0;
2098
+ padding: 0;
2099
+ min-height: auto;
2100
+ opacity: 0.7;
2051
2101
  line-height: 0;
2052
- }
2053
-
2054
- .thunderid-user-profile__field:hover .thunderid-user-profile__field-edit-btn {
2055
- opacity: 1;
2102
+ transition: opacity var(--thunder-transition-fast, 0.15s ease);
2056
2103
  }
2057
2104
 
2058
2105
  .thunderid-user-profile__field-edit-btn:hover {
2059
- color: var(--thunder-color-primary-main);
2060
- background-color: var(--thunder-color-primary-light);
2061
- }
2062
-
2063
- .thunderid-user-profile__field-edit-btn:focus-visible {
2064
2106
  opacity: 1;
2065
- outline: none;
2066
- box-shadow: 0 0 0 var(--thunder-focus-ring-width) var(--thunder-focus-ring-color);
2107
+ background: transparent;
2067
2108
  }
2068
2109
 
2069
- /* ── Edit mode ───────────────────────────────────────────────── */
2070
-
2071
2110
  .thunderid-user-profile__field-edit {
2111
+ flex: 1;
2072
2112
  display: flex;
2073
2113
  flex-direction: column;
2074
- gap: calc(var(--thunder-spacing-unit) * 0.75);
2075
- padding: calc(var(--thunder-spacing-unit) * 0.25) 0;
2114
+ gap: calc(var(--thunder-spacing-unit) * 0.5);
2076
2115
  }
2077
2116
 
2078
- .thunderid-user-profile__field-edit-actions {
2079
- display: flex;
2080
- align-items: center;
2081
- gap: calc(var(--thunder-spacing-unit) * 0.75);
2117
+ .thunderid-user-profile__field-error {
2118
+ color: var(--thunder-color-error, #d32f2f);
2119
+ font-size: var(--thunder-typography-fontSize-xs, 0.8rem);
2120
+ font-weight: var(--thunder-typography-fontWeight-medium, 500);
2121
+ margin-top: calc(var(--thunder-spacing-unit) * 0.5);
2082
2122
  }
2083
2123
 
2084
- /* ── Footer slot ─────────────────────────────────────────────── */
2124
+ /* ── Footer ──────────────────────────────────────────────────── */
2085
2125
 
2086
2126
  .thunderid-user-profile__footer {
2087
- padding: calc(var(--thunder-spacing-unit) * 1.5) calc(var(--thunder-spacing-unit) * 2.5);
2127
+ padding-top: calc(var(--thunder-spacing-unit) * 2);
2088
2128
  border-top: 1px solid var(--thunder-color-border);
2089
2129
  }
2090
2130
 
2091
2131
  /* ── Compact modifier ────────────────────────────────────────── */
2092
2132
 
2093
- .thunderid-user-profile--compact .thunderid-user-profile__hero {
2094
- padding: calc(var(--thunder-spacing-unit) * 2) calc(var(--thunder-spacing-unit) * 2);
2095
- }
2096
-
2097
- .thunderid-user-profile--compact .thunderid-user-profile__avatar--lg {
2098
- width: 56px;
2099
- height: 56px;
2100
- }
2101
-
2102
- .thunderid-user-profile--compact .thunderid-user-profile__avatar--lg .thunderid-user-profile__avatar-initials {
2103
- font-size: 1.125rem;
2104
- }
2105
-
2106
- .thunderid-user-profile--compact .thunderid-user-profile__field {
2107
- padding: calc(var(--thunder-spacing-unit) * 1) calc(var(--thunder-spacing-unit) * 2);
2108
- }
2109
-
2110
- .thunderid-user-profile--compact .thunderid-user-profile__hero-name {
2111
- font-size: var(--thunder-typography-fontSize-md);
2133
+ .thunderid-user-profile--compact {
2134
+ padding: calc(var(--thunder-spacing-unit) * 2);
2135
+ width: 100%;
2112
2136
  }
2113
2137
  `;
2114
2138
  var UserProfile_css_default = USER_PROFILE_CSS;
@@ -7550,22 +7574,31 @@ const FIELDS_TO_SKIP = [
7550
7574
  "verifiedEmailAddresses",
7551
7575
  "phoneNumbers.mobile",
7552
7576
  "emailAddresses",
7553
- "preferredMFAOption"
7577
+ "preferredMFAOption",
7578
+ "attributes",
7579
+ "isReadOnly",
7580
+ "isReadonly"
7554
7581
  ];
7555
7582
  const READONLY_FIELDS = [
7556
7583
  "username",
7557
7584
  "userName",
7558
- "user_name"
7585
+ "user_name",
7586
+ "sub",
7587
+ "id",
7588
+ "ouId",
7589
+ "attributes",
7590
+ "isReadOnly",
7591
+ "isReadonly"
7559
7592
  ];
7560
7593
  const DEFAULT_ATTRIBUTE_MAPPINGS$1 = {
7561
7594
  email: ["emails", "email"],
7562
7595
  firstName: ["name.givenName", "given_name"],
7563
7596
  lastName: ["name.familyName", "family_name"],
7564
7597
  picture: [
7565
- "profile",
7566
- "profileUrl",
7567
7598
  "picture",
7568
- "URL"
7599
+ "avatar",
7600
+ "pictureUrl",
7601
+ "attributes.picture"
7569
7602
  ],
7570
7603
  username: [
7571
7604
  "userName",
@@ -7652,6 +7685,10 @@ const BaseUserProfile = (0, vue.defineComponent)({
7652
7685
  default: void 0,
7653
7686
  type: Function
7654
7687
  },
7688
+ preferences: {
7689
+ default: void 0,
7690
+ type: Object
7691
+ },
7655
7692
  profile: {
7656
7693
  default: null,
7657
7694
  type: Object
@@ -7668,21 +7705,38 @@ const BaseUserProfile = (0, vue.defineComponent)({
7668
7705
  default: () => [],
7669
7706
  type: Array
7670
7707
  },
7708
+ t: {
7709
+ default: void 0,
7710
+ type: Function
7711
+ },
7671
7712
  title: {
7672
7713
  default: "Profile",
7673
7714
  type: String
7715
+ },
7716
+ userSchema: {
7717
+ default: null,
7718
+ type: Object
7674
7719
  }
7675
7720
  },
7676
7721
  setup(props, { slots }) {
7677
7722
  const editingFields = (0, vue.ref)({});
7678
7723
  const editedValues = (0, vue.ref)({});
7679
7724
  const px = __thunderid_browser.withVendorCSSClassPrefix;
7680
- function shouldShowField(fieldName) {
7681
- if (FIELDS_TO_SKIP.includes(fieldName)) return false;
7725
+ const regexCache = /* @__PURE__ */ new Map();
7726
+ const t = (key, fallback) => {
7727
+ if (props.t) {
7728
+ const res = props.t(key);
7729
+ if (res && res !== key) return res;
7730
+ }
7731
+ return fallback ?? key;
7732
+ };
7733
+ function shouldShowField(fieldName, isSchemaBased = false) {
7734
+ if (!isSchemaBased && FIELDS_TO_SKIP.includes(fieldName)) return false;
7682
7735
  if (props.hideFields && props.hideFields.length > 0 && props.hideFields.includes(fieldName)) return false;
7683
7736
  if (props.showFields && props.showFields.length > 0) return props.showFields.includes(fieldName);
7684
7737
  return true;
7685
7738
  }
7739
+ const fieldErrors = (0, vue.ref)({});
7686
7740
  function startEditing(fieldName, currentValue) {
7687
7741
  editedValues.value = {
7688
7742
  ...editedValues.value,
@@ -7692,9 +7746,14 @@ const BaseUserProfile = (0, vue.defineComponent)({
7692
7746
  ...editingFields.value,
7693
7747
  [fieldName]: true
7694
7748
  };
7749
+ fieldErrors.value = {
7750
+ ...fieldErrors.value,
7751
+ [fieldName]: ""
7752
+ };
7695
7753
  }
7696
7754
  function cancelEditing(fieldName) {
7697
- const originalValue = (props.flattenedProfile ?? props.profile ?? null)?.[fieldName] ?? "";
7755
+ const data = props.flattenedProfile ?? props.profile ?? null;
7756
+ const originalValue = data?.[fieldName] ?? data?.attributes?.[fieldName] ?? "";
7698
7757
  editedValues.value = {
7699
7758
  ...editedValues.value,
7700
7759
  [fieldName]: originalValue
@@ -7703,16 +7762,54 @@ const BaseUserProfile = (0, vue.defineComponent)({
7703
7762
  ...editingFields.value,
7704
7763
  [fieldName]: false
7705
7764
  };
7765
+ fieldErrors.value = {
7766
+ ...fieldErrors.value,
7767
+ [fieldName]: ""
7768
+ };
7706
7769
  }
7707
- function saveField(schema) {
7770
+ async function saveField(schema) {
7708
7771
  if (!props.onUpdate || !schema.name) return;
7709
- const value = editedValues.value[schema.name] ?? "";
7710
- const payload = buildPatchValue(schema.name, value, schema.schemaId, schema.multiValued);
7711
- props.onUpdate(payload);
7712
- editingFields.value = {
7713
- ...editingFields.value,
7714
- [schema.name]: false
7772
+ const fieldName = schema.name;
7773
+ const value = editedValues.value[fieldName] ?? "";
7774
+ const strVal = String(value ?? "").trim();
7775
+ const fieldLabel = schema.displayName || formatLabel(fieldName);
7776
+ if (schema.required && !strVal) {
7777
+ fieldErrors.value = {
7778
+ ...fieldErrors.value,
7779
+ [fieldName]: t("userProfile.field.required", `${fieldLabel} is required.`)
7780
+ };
7781
+ return;
7782
+ }
7783
+ if (schema.regex && strVal) if (schema.regex.length > 250) console.warn(`Regex pattern for field "${fieldName}" exceeds maximum length limit (250 chars).`);
7784
+ else {
7785
+ let reg = regexCache.get(schema.regex);
7786
+ if (reg === void 0) try {
7787
+ reg = new RegExp(schema.regex);
7788
+ regexCache.set(schema.regex, reg);
7789
+ } catch (err) {
7790
+ regexCache.set(schema.regex, null);
7791
+ console.warn(`Invalid regular expression syntax in user schema for field "${fieldName}":`, err);
7792
+ }
7793
+ if (reg && !reg.test(strVal)) {
7794
+ fieldErrors.value = {
7795
+ ...fieldErrors.value,
7796
+ [fieldName]: t("userProfile.field.invalidFormat", `${fieldLabel} has an invalid format.`)
7797
+ };
7798
+ return;
7799
+ }
7800
+ }
7801
+ fieldErrors.value = {
7802
+ ...fieldErrors.value,
7803
+ [fieldName]: ""
7715
7804
  };
7805
+ const payload = buildPatchValue(fieldName, typeof value === "string" ? strVal : value, schema.schemaId, schema.multiValued);
7806
+ try {
7807
+ await props.onUpdate(payload);
7808
+ editingFields.value = {
7809
+ ...editingFields.value,
7810
+ [fieldName]: false
7811
+ };
7812
+ } catch {}
7716
7813
  }
7717
7814
  function renderInput(schema) {
7718
7815
  const fieldName = schema.name ?? "";
@@ -7765,30 +7862,29 @@ const BaseUserProfile = (0, vue.defineComponent)({
7765
7862
  class: px("user-profile__field-placeholder"),
7766
7863
  onClick: () => startEditing(name, value)
7767
7864
  }, `Enter your ${label.toLowerCase()}`) : null;
7768
- const displayValueNode = hasValue ? (0, vue.h)(Typography_default, {
7769
- class: px("user-profile__field-value"),
7770
- variant: "body1"
7771
- }, () => String(value)) : editablePlaceholder;
7865
+ const displayValueNode = hasValue ? (0, vue.h)("span", { class: px("user-profile__field-value") }, String(value)) : editablePlaceholder;
7772
7866
  return (0, vue.h)("div", {
7773
7867
  class: px("user-profile__field"),
7774
7868
  key: name
7775
- }, [(0, vue.h)("div", { class: px("user-profile__field-label-col") }, [(0, vue.h)(Typography_default, {
7776
- class: px("user-profile__field-label"),
7777
- variant: "body2"
7778
- }, () => label)]), (0, vue.h)("div", { class: px("user-profile__field-value-col") }, [isEditing ? (0, vue.h)("div", { class: px("user-profile__field-edit") }, [renderInput(schema), (0, vue.h)("div", { class: px("user-profile__field-edit-actions") }, [(0, vue.h)(Button_default, {
7869
+ }, [(0, vue.h)("div", { class: px("user-profile__field-inner") }, [(0, vue.h)("span", { class: px("user-profile__field-label") }, label), isEditing ? (0, vue.h)("div", { class: px("user-profile__field-edit") }, [renderInput(schema), fieldErrors.value[name] ? (0, vue.h)("div", { class: px("user-profile__field-error") }, fieldErrors.value[name]) : null]) : displayValueNode]), isEditable && !isReadonly ? (0, vue.h)("div", { class: px("user-profile__field-actions") }, [isEditing ? [(0, vue.h)(Button_default, {
7870
+ color: "primary",
7779
7871
  onClick: () => saveField(schema),
7780
7872
  size: "small",
7781
7873
  variant: "solid"
7782
- }, () => "Save"), (0, vue.h)(Button_default, {
7874
+ }, () => t("userProfile.actions.save", "Save")), (0, vue.h)(Button_default, {
7875
+ color: "secondary",
7783
7876
  onClick: () => cancelEditing(name),
7784
7877
  size: "small",
7785
- variant: "text"
7786
- }, () => "Cancel")])]) : (0, vue.h)("div", { class: px("user-profile__field-display") }, [displayValueNode, isEditable ? (0, vue.h)("button", {
7787
- "aria-label": `Edit ${label}`,
7878
+ variant: "solid"
7879
+ }, () => t("userProfile.actions.cancel", "Cancel"))] : hasValue ? (0, vue.h)(Button_default, {
7788
7880
  class: px("user-profile__field-edit-btn"),
7881
+ color: "secondary",
7789
7882
  onClick: () => startEditing(name, value),
7790
- type: "button"
7791
- }, [(0, vue.h)(PencilIcon)]) : null])])]);
7883
+ size: "small",
7884
+ startIcon: (0, vue.h)(PencilIcon),
7885
+ title: t("userProfile.actions.edit", "Edit"),
7886
+ variant: "ghost"
7887
+ }) : null]) : null]);
7792
7888
  }
7793
7889
  function renderProfileWithoutSchemas() {
7794
7890
  const data = props.flattenedProfile || props.profile;
@@ -7799,21 +7895,20 @@ const BaseUserProfile = (0, vue.defineComponent)({
7799
7895
  }).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => (0, vue.h)("div", {
7800
7896
  class: px("user-profile__field"),
7801
7897
  key
7802
- }, [(0, vue.h)("div", { class: px("user-profile__field-label-col") }, [(0, vue.h)(Typography_default, {
7803
- class: px("user-profile__field-label"),
7804
- variant: "body2"
7805
- }, () => formatLabel(key))]), (0, vue.h)("div", { class: px("user-profile__field-value-col") }, [(0, vue.h)(Typography_default, {
7806
- class: px("user-profile__field-value"),
7807
- variant: "body1"
7808
- }, () => typeof value === "object" ? JSON.stringify(value) : String(value))])]));
7898
+ }, [(0, vue.h)("div", { class: px("user-profile__field-inner") }, [(0, vue.h)("span", { class: px("user-profile__field-label") }, formatLabel(key)), (0, vue.h)("span", { class: px("user-profile__field-value") }, typeof value === "object" ? JSON.stringify(value) : String(value))])]));
7809
7899
  }
7810
7900
  function renderHero(currentUser) {
7811
7901
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser);
7812
7902
  const email = getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser) || getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser);
7903
+ const picture = getMappedUserProfileValue_default("picture", DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser) || null;
7813
7904
  const avatarGradient = getAvatarGradient$1(String(currentUser["username"] || currentUser["userName"] || currentUser["email"] || currentUser["sub"] || displayName));
7814
7905
  const initials = displayName.split(" ").map((w) => w.charAt(0)).slice(0, 2).join("").toUpperCase() || "?";
7815
7906
  const avatarSizeClass = px(`user-profile__avatar--${props.avatarSize ?? "lg"}`);
7816
- return (0, vue.h)("div", { class: px("user-profile__hero") }, [(0, vue.h)("div", { class: px("user-profile__avatar-wrapper") }, [(0, vue.h)("div", {
7907
+ return (0, vue.h)("div", { class: px("user-profile__hero") }, [(0, vue.h)("div", { class: px("user-profile__avatar-wrapper") }, [picture ? (0, vue.h)("img", {
7908
+ alt: displayName,
7909
+ class: [px("user-profile__avatar"), avatarSizeClass].join(" "),
7910
+ src: picture
7911
+ }) : (0, vue.h)("div", {
7817
7912
  class: [px("user-profile__avatar"), avatarSizeClass].join(" "),
7818
7913
  style: { background: avatarGradient }
7819
7914
  }, [(0, vue.h)("span", { class: px("user-profile__avatar-initials") }, initials)])]), (0, vue.h)("div", { class: px("user-profile__hero-info") }, [(0, vue.h)("span", { class: px("user-profile__hero-name") }, displayName), email ? (0, vue.h)("span", { class: px("user-profile__hero-subtitle") }, String(email)) : null])]);
@@ -7839,15 +7934,31 @@ const BaseUserProfile = (0, vue.defineComponent)({
7839
7934
  props.className ?? ""
7840
7935
  ].filter(Boolean).join(" ");
7841
7936
  const children = [];
7842
- children.push((0, vue.h)("div", { class: px("user-profile__header") }, [(0, vue.h)("span", { class: px("user-profile__title") }, props.title ?? "Profile")]));
7843
- children.push((0, vue.h)(Divider_default, { class: px("user-profile__header-divider") }));
7844
7937
  if (props.showAvatar !== false && currentUser) children.push(renderHero(currentUser));
7845
7938
  if (props.error) children.push((0, vue.h)(Alert_default, {
7846
7939
  class: px("user-profile__error"),
7847
7940
  severity: "error"
7848
7941
  }, () => props.error));
7849
7942
  if (props.isLoading) children.push((0, vue.h)("div", { class: px("user-profile__loading") }, [(0, vue.h)(Spinner_default)]));
7850
- else if (hasSchemas) {
7943
+ else if (props.userSchema && typeof props.userSchema === "object" && Object.keys(props.userSchema).length > 0) {
7944
+ const fieldRows = Object.entries(props.userSchema).filter(([key, metaAttr]) => {
7945
+ if (metaAttr?.credential) return false;
7946
+ return shouldShowField(key, true);
7947
+ }).map(([key, metaAttr]) => {
7948
+ const val = editedValues.value?.[key] ?? currentUser?.attributes?.[key] ?? currentUser?.[key] ?? "";
7949
+ const isReadonly = metaAttr.readOnly === true || metaAttr.mutability === "READ_ONLY" || READONLY_FIELDS.includes(key);
7950
+ return {
7951
+ displayName: metaAttr.displayName ?? (key ? (0, __thunderid_browser.startCase)(key) : ""),
7952
+ mutability: isReadonly ? "READ_ONLY" : "READ_WRITE",
7953
+ name: key,
7954
+ regex: metaAttr.regex,
7955
+ required: !!metaAttr.required,
7956
+ type: (metaAttr.type ?? "STRING").toUpperCase(),
7957
+ value: val
7958
+ };
7959
+ }).map((schema) => renderSchemaFieldRow(schema)).filter((node) => node !== null);
7960
+ children.push((0, vue.h)("div", { class: px("user-profile__fields") }, fieldRows));
7961
+ } else if (hasSchemas) {
7851
7962
  const fieldRows = schemas.filter((s) => s.name && shouldShowField(s.name)).sort((a, b) => {
7852
7963
  return (a.displayOrder ? parseInt(a.displayOrder, 10) : 999) - (b.displayOrder ? parseInt(b.displayOrder, 10) : 999);
7853
7964
  }).map((schema) => {
@@ -7877,7 +7988,7 @@ const updateMeProfile = async ({ fetcher, instanceId = 0,...requestConfig }) =>
7877
7988
  const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
7878
7989
  data: config.body ? JSON.parse(config.body) : void 0,
7879
7990
  headers: config.headers,
7880
- method: config.method || "PATCH",
7991
+ method: config.method || "PUT",
7881
7992
  url
7882
7993
  });
7883
7994
  return {
@@ -7928,6 +8039,10 @@ const UserProfile = (0, vue.defineComponent)({
7928
8039
  default: () => [],
7929
8040
  type: Array
7930
8041
  },
8042
+ preferences: {
8043
+ default: void 0,
8044
+ type: Object
8045
+ },
7931
8046
  showAvatar: {
7932
8047
  default: true,
7933
8048
  type: Boolean
@@ -7942,19 +8057,37 @@ const UserProfile = (0, vue.defineComponent)({
7942
8057
  }
7943
8058
  },
7944
8059
  setup(props, { slots }) {
7945
- const { baseUrl, endpoints, instanceId } = useThunderID_default();
7946
- const { flattenedProfile, profile, onUpdateProfile } = useUser_default();
8060
+ const { baseUrl, endpoints, instanceId, preferences: contextPreferences } = useThunderID_default();
8061
+ const { flattenedProfile, profile, onUpdateProfile, updateProfile, userSchema } = useUser_default();
7947
8062
  const { t } = useI18n_default();
8063
+ const resolvedPreferences = (0, vue.computed)(() => ({
8064
+ ...contextPreferences,
8065
+ ...props.preferences,
8066
+ user: {
8067
+ ...contextPreferences?.user,
8068
+ ...props.preferences?.user
8069
+ }
8070
+ }));
8071
+ const isEditableProfile = (0, vue.computed)(() => resolvedPreferences.value?.user?.fetchUserProfile === false ? false : props.editable);
7948
8072
  const error = (0, vue.ref)(null);
7949
8073
  async function handleProfileUpdate(payload) {
7950
- if (!baseUrl) return;
7951
8074
  error.value = null;
7952
8075
  try {
8076
+ const updatedAttributes = (0, __thunderid_browser.deepMerge)((profile?.value?.profile ?? profile?.value)?.["attributes"] ?? {}, payload);
8077
+ Object.keys(updatedAttributes).forEach((key) => {
8078
+ if (updatedAttributes[key] === void 0 || updatedAttributes[key] === null) delete updatedAttributes[key];
8079
+ });
8080
+ if (updateProfile) {
8081
+ const res = await updateProfile({ payload: updatedAttributes });
8082
+ if (res && !res.success && res.error) error.value = res.error;
8083
+ return;
8084
+ }
8085
+ if (!baseUrl) return;
7953
8086
  onUpdateProfile(await updateMeProfile_default({
7954
8087
  baseUrl,
7955
8088
  url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMe", { endpoints }),
7956
8089
  instanceId,
7957
- payload
8090
+ payload: updatedAttributes
7958
8091
  }));
7959
8092
  } catch (caughtError) {
7960
8093
  let message = t("user.profile.update.generic.error") || "Failed to update profile. Please try again.";
@@ -7969,15 +8102,18 @@ const UserProfile = (0, vue.defineComponent)({
7969
8102
  class: (0, __thunderid_browser.withVendorCSSClassPrefix)("user-profile--styled"),
7970
8103
  className: props.className,
7971
8104
  compact: props.compact,
7972
- editable: props.editable,
8105
+ editable: isEditableProfile.value,
7973
8106
  error: error.value,
7974
8107
  flattenedProfile: flattenedProfile?.value,
7975
8108
  hideFields: props.hideFields,
7976
- onUpdate: handleProfileUpdate,
8109
+ onUpdate: isEditableProfile.value ? handleProfileUpdate : void 0,
8110
+ preferences: resolvedPreferences.value,
7977
8111
  profile: profile?.value?.profile ?? flattenedProfile?.value,
7978
8112
  showAvatar: props.showAvatar,
7979
8113
  showFields: props.showFields,
7980
- title: props.title
8114
+ t,
8115
+ title: props.title,
8116
+ userSchema: userSchema?.value
7981
8117
  }, slots);
7982
8118
  }
7983
8119
  });
@@ -7989,18 +8125,18 @@ const DEFAULT_ATTRIBUTE_MAPPINGS = {
7989
8125
  email: ["emails", "email"],
7990
8126
  firstName: ["name.givenName", "given_name"],
7991
8127
  lastName: ["name.familyName", "family_name"],
8128
+ picture: [
8129
+ "picture",
8130
+ "avatar",
8131
+ "pictureUrl",
8132
+ "attributes.picture"
8133
+ ],
7992
8134
  username: [
7993
8135
  "userName",
7994
8136
  "username",
7995
8137
  "user_name"
7996
8138
  ]
7997
8139
  };
7998
- /** Approximate min-width for each size, used for auto-alignment decisions. */
7999
- const MENU_MIN_WIDTHS = {
8000
- lg: 280,
8001
- md: 220,
8002
- sm: 180
8003
- };
8004
8140
  const AVATAR_GRADIENTS = [
8005
8141
  "linear-gradient(135deg, #4b6ef5 0%, #7c3aed 100%)",
8006
8142
  "linear-gradient(135deg, #0ea5e9 0%, #4b6ef5 100%)",
@@ -8022,16 +8158,19 @@ function resolveUserInfo(user) {
8022
8158
  displayName: "User",
8023
8159
  gradient: AVATAR_GRADIENTS[0],
8024
8160
  initials: "?",
8161
+ picture: null,
8025
8162
  subtitle: ""
8026
8163
  };
8027
8164
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS, user) || "User";
8028
8165
  const initials = displayName.split(" ").map((w) => w.charAt(0)).slice(0, 2).join("").toUpperCase() || "?";
8166
+ const picture = getMappedUserProfileValue_default("picture", DEFAULT_ATTRIBUTE_MAPPINGS, user) || null;
8029
8167
  const seed = String(getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || displayName);
8030
8168
  const subtitle = String(getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || "");
8031
8169
  return {
8032
8170
  displayName,
8033
8171
  gradient: getAvatarGradient(seed),
8034
8172
  initials,
8173
+ picture,
8035
8174
  subtitle
8036
8175
  };
8037
8176
  }
@@ -8087,13 +8226,46 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8087
8226
  setup(props, { slots }) {
8088
8227
  const isOpen = (0, vue.ref)(false);
8089
8228
  const containerRef = (0, vue.ref)(null);
8229
+ const modalOverlayRef = (0, vue.ref)(null);
8230
+ const avatarImageError = (0, vue.ref)(false);
8090
8231
  const px = __thunderid_browser.withVendorCSSClassPrefix;
8232
+ (0, vue.watch)(() => resolveUserInfo(props.user ?? null).picture, () => {
8233
+ avatarImageError.value = false;
8234
+ });
8091
8235
  function handleClickOutside(event) {
8092
8236
  if (containerRef.value && !containerRef.value.contains(event.target)) isOpen.value = false;
8093
8237
  }
8238
+ function handleModalClose() {
8239
+ props.onProfileModalClose?.();
8240
+ (containerRef.value?.querySelector(`.${px("user-dropdown__trigger")}`))?.focus();
8241
+ }
8094
8242
  function handleKeyDown(event) {
8095
- if (event.key === "Escape") isOpen.value = false;
8243
+ if (props.isProfileModalOpen) {
8244
+ if (event.key === "Escape") handleModalClose();
8245
+ else if (event.key === "Tab") {
8246
+ const overlay = modalOverlayRef.value;
8247
+ if (overlay) {
8248
+ const focusables = overlay.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
8249
+ if (focusables.length > 0) {
8250
+ const first = focusables[0];
8251
+ const last = focusables[focusables.length - 1];
8252
+ if (event.shiftKey && document.activeElement === first) {
8253
+ event.preventDefault();
8254
+ last.focus();
8255
+ } else if (!event.shiftKey && document.activeElement === last) {
8256
+ event.preventDefault();
8257
+ first.focus();
8258
+ }
8259
+ }
8260
+ }
8261
+ }
8262
+ } else if (event.key === "Escape") isOpen.value = false;
8096
8263
  }
8264
+ (0, vue.watch)(() => props.isProfileModalOpen, (open) => {
8265
+ if (open) (0, vue.nextTick)(() => {
8266
+ (modalOverlayRef.value?.querySelector(`.${px("user-dropdown__modal-close")}`))?.focus();
8267
+ });
8268
+ });
8097
8269
  (0, vue.onMounted)(() => {
8098
8270
  document.addEventListener("click", handleClickOutside);
8099
8271
  document.addEventListener("keydown", handleKeyDown);
@@ -8106,8 +8278,7 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8106
8278
  if (props.menuAlign !== "auto") return props.menuAlign ?? "right";
8107
8279
  if (!containerRef.value) return "right";
8108
8280
  const rect = containerRef.value.getBoundingClientRect();
8109
- const menuWidth = MENU_MIN_WIDTHS[props.size ?? "md"] ?? 220;
8110
- return window.innerWidth - rect.right >= menuWidth ? "right" : "left";
8281
+ return window.innerWidth - rect.left >= rect.right ? "left" : "right";
8111
8282
  }
8112
8283
  return () => {
8113
8284
  if (slots.default) return slots.default({
@@ -8117,7 +8288,7 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8117
8288
  },
8118
8289
  user: props.user
8119
8290
  });
8120
- const { displayName, initials, gradient, subtitle } = resolveUserInfo(props.user ?? null);
8291
+ const { displayName, initials, gradient, picture, subtitle } = resolveUserInfo(props.user ?? null);
8121
8292
  const size = props.size ?? "md";
8122
8293
  const avatarSizeClass = size !== "md" ? px(`user-dropdown__avatar--${size}`) : "";
8123
8294
  const triggerClass = [px("user-dropdown__trigger"), isOpen.value ? px("user-dropdown__trigger--open") : ""].filter(Boolean).join(" ");
@@ -8130,7 +8301,14 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8130
8301
  isOpen.value = !isOpen.value;
8131
8302
  },
8132
8303
  type: "button"
8133
- }, [(0, vue.h)("span", {
8304
+ }, [picture && !avatarImageError.value ? (0, vue.h)("img", {
8305
+ alt: displayName,
8306
+ class: [px("user-dropdown__avatar"), avatarSizeClass].filter(Boolean).join(" "),
8307
+ onError: () => {
8308
+ avatarImageError.value = true;
8309
+ },
8310
+ src: picture
8311
+ }) : (0, vue.h)("span", {
8134
8312
  class: [px("user-dropdown__avatar"), avatarSizeClass].filter(Boolean).join(" "),
8135
8313
  style: { background: gradient }
8136
8314
  }, initials), props.showChevron ? (0, vue.h)("span", { class: px("user-dropdown__chevron") }, [(0, vue.h)(ChevronDownIcon, { size: 14 })]) : null]);
@@ -8144,7 +8322,11 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8144
8322
  sizeClass
8145
8323
  ].filter(Boolean).join(" ");
8146
8324
  const menuChildren = [];
8147
- menuChildren.push((0, vue.h)("div", { class: px("user-dropdown__menu-header") }, [(0, vue.h)("div", {
8325
+ menuChildren.push((0, vue.h)("div", { class: px("user-dropdown__menu-header") }, [picture ? (0, vue.h)("img", {
8326
+ alt: displayName,
8327
+ class: px("user-dropdown__menu-header-avatar"),
8328
+ src: picture
8329
+ }) : (0, vue.h)("div", {
8148
8330
  class: px("user-dropdown__menu-header-avatar"),
8149
8331
  style: { background: gradient }
8150
8332
  }, initials), (0, vue.h)("div", { class: px("user-dropdown__menu-header-info") }, [(0, vue.h)("span", { class: px("user-dropdown__menu-header-name") }, displayName), subtitle ? (0, vue.h)("span", { class: px("user-dropdown__menu-header-subtitle") }, subtitle) : null])]));
@@ -8190,17 +8372,21 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8190
8372
  class: [px("user-dropdown"), props.className].filter(Boolean).join(" "),
8191
8373
  ref: containerRef
8192
8374
  }, [trigger, menu]);
8193
- if (props.isProfileModalOpen) return (0, vue.h)("div", [container, (0, vue.h)("div", {
8375
+ if (props.isProfileModalOpen) return (0, vue.h)("div", [container, (0, vue.h)(vue.Teleport, { to: "body" }, [(0, vue.h)("div", {
8376
+ "aria-label": "User profile",
8377
+ "aria-modal": "true",
8194
8378
  class: px("user-dropdown__modal-overlay"),
8379
+ ref: modalOverlayRef,
8380
+ role: "dialog",
8195
8381
  onClick: (e) => {
8196
- if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) props.onProfileModalClose?.();
8382
+ if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) handleModalClose();
8197
8383
  }
8198
8384
  }, [(0, vue.h)("div", { class: px("user-dropdown__modal-content") }, [(0, vue.h)("button", {
8199
8385
  "aria-label": "Close profile",
8200
8386
  class: px("user-dropdown__modal-close"),
8201
- onClick: props.onProfileModalClose,
8387
+ onClick: handleModalClose,
8202
8388
  type: "button"
8203
- }, [(0, vue.h)(XIcon, { size: 18 })]), props.profileContent])])]);
8389
+ }, [(0, vue.h)(XIcon, { size: 18 })]), props.profileContent])])])]);
8204
8390
  return container;
8205
8391
  };
8206
8392
  }
@@ -9704,6 +9890,7 @@ Object.defineProperty(exports, 'getActiveTheme', {
9704
9890
  }
9705
9891
  });
9706
9892
  exports.getAuthComponentHeadings = getAuthComponentHeadings_default;
9893
+ exports.getUsersMeMeta = getUsersMeMeta_default;
9707
9894
  Object.defineProperty(exports, 'handleWebAuthnAuthentication', {
9708
9895
  enumerable: true,
9709
9896
  get: function () {