@thunderid/vue 0.12.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;
@@ -3327,13 +3351,17 @@ const STYLES = [
3327
3351
  *
3328
3352
  * @param vendor - Vendor/brand namespace used to derive the dedupe `<style>` element id
3329
3353
  * (e.g. `${vendor}-vue-styles`). Defaults to `VendorConstants.VENDOR_PREFIX`.
3354
+ * @param nonce - CSP nonce applied to the injected `<style>` element via a `nonce` attribute,
3355
+ * so consuming apps can enforce a strict `style-src` Content-Security-Policy (i.e. without
3356
+ * `'unsafe-inline'`) for this runtime-injected stylesheet.
3330
3357
  */
3331
- function injectStyles(vendor) {
3358
+ function injectStyles(vendor, nonce) {
3332
3359
  if (typeof document === "undefined") return;
3333
3360
  const styleId = `${(0, __thunderid_browser.getVendorPrefix)(vendor)}-vue-styles`;
3334
3361
  if (document.getElementById(styleId)) return;
3335
3362
  const style = document.createElement("style");
3336
3363
  style.id = styleId;
3364
+ if (nonce) style.setAttribute("nonce", nonce);
3337
3365
  style.textContent = STYLES;
3338
3366
  document.head.appendChild(style);
3339
3367
  }
@@ -3367,7 +3395,7 @@ function injectStyles(vendor) {
3367
3395
  * ```
3368
3396
  */
3369
3397
  const ThunderIDPlugin = { install(app, options) {
3370
- injectStyles(options?.vendor);
3398
+ injectStyles(options?.vendor, options?.cspNonce);
3371
3399
  if (options?.mode === "delegated") return;
3372
3400
  app.component("ThunderIDProvider", ThunderIDProvider_default);
3373
3401
  } };
@@ -7546,22 +7574,31 @@ const FIELDS_TO_SKIP = [
7546
7574
  "verifiedEmailAddresses",
7547
7575
  "phoneNumbers.mobile",
7548
7576
  "emailAddresses",
7549
- "preferredMFAOption"
7577
+ "preferredMFAOption",
7578
+ "attributes",
7579
+ "isReadOnly",
7580
+ "isReadonly"
7550
7581
  ];
7551
7582
  const READONLY_FIELDS = [
7552
7583
  "username",
7553
7584
  "userName",
7554
- "user_name"
7585
+ "user_name",
7586
+ "sub",
7587
+ "id",
7588
+ "ouId",
7589
+ "attributes",
7590
+ "isReadOnly",
7591
+ "isReadonly"
7555
7592
  ];
7556
7593
  const DEFAULT_ATTRIBUTE_MAPPINGS$1 = {
7557
7594
  email: ["emails", "email"],
7558
7595
  firstName: ["name.givenName", "given_name"],
7559
7596
  lastName: ["name.familyName", "family_name"],
7560
7597
  picture: [
7561
- "profile",
7562
- "profileUrl",
7563
7598
  "picture",
7564
- "URL"
7599
+ "avatar",
7600
+ "pictureUrl",
7601
+ "attributes.picture"
7565
7602
  ],
7566
7603
  username: [
7567
7604
  "userName",
@@ -7648,6 +7685,10 @@ const BaseUserProfile = (0, vue.defineComponent)({
7648
7685
  default: void 0,
7649
7686
  type: Function
7650
7687
  },
7688
+ preferences: {
7689
+ default: void 0,
7690
+ type: Object
7691
+ },
7651
7692
  profile: {
7652
7693
  default: null,
7653
7694
  type: Object
@@ -7664,21 +7705,38 @@ const BaseUserProfile = (0, vue.defineComponent)({
7664
7705
  default: () => [],
7665
7706
  type: Array
7666
7707
  },
7708
+ t: {
7709
+ default: void 0,
7710
+ type: Function
7711
+ },
7667
7712
  title: {
7668
7713
  default: "Profile",
7669
7714
  type: String
7715
+ },
7716
+ userSchema: {
7717
+ default: null,
7718
+ type: Object
7670
7719
  }
7671
7720
  },
7672
7721
  setup(props, { slots }) {
7673
7722
  const editingFields = (0, vue.ref)({});
7674
7723
  const editedValues = (0, vue.ref)({});
7675
7724
  const px = __thunderid_browser.withVendorCSSClassPrefix;
7676
- function shouldShowField(fieldName) {
7677
- 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;
7678
7735
  if (props.hideFields && props.hideFields.length > 0 && props.hideFields.includes(fieldName)) return false;
7679
7736
  if (props.showFields && props.showFields.length > 0) return props.showFields.includes(fieldName);
7680
7737
  return true;
7681
7738
  }
7739
+ const fieldErrors = (0, vue.ref)({});
7682
7740
  function startEditing(fieldName, currentValue) {
7683
7741
  editedValues.value = {
7684
7742
  ...editedValues.value,
@@ -7688,9 +7746,14 @@ const BaseUserProfile = (0, vue.defineComponent)({
7688
7746
  ...editingFields.value,
7689
7747
  [fieldName]: true
7690
7748
  };
7749
+ fieldErrors.value = {
7750
+ ...fieldErrors.value,
7751
+ [fieldName]: ""
7752
+ };
7691
7753
  }
7692
7754
  function cancelEditing(fieldName) {
7693
- const originalValue = (props.flattenedProfile ?? props.profile ?? null)?.[fieldName] ?? "";
7755
+ const data = props.flattenedProfile ?? props.profile ?? null;
7756
+ const originalValue = data?.[fieldName] ?? data?.attributes?.[fieldName] ?? "";
7694
7757
  editedValues.value = {
7695
7758
  ...editedValues.value,
7696
7759
  [fieldName]: originalValue
@@ -7699,16 +7762,54 @@ const BaseUserProfile = (0, vue.defineComponent)({
7699
7762
  ...editingFields.value,
7700
7763
  [fieldName]: false
7701
7764
  };
7765
+ fieldErrors.value = {
7766
+ ...fieldErrors.value,
7767
+ [fieldName]: ""
7768
+ };
7702
7769
  }
7703
- function saveField(schema) {
7770
+ async function saveField(schema) {
7704
7771
  if (!props.onUpdate || !schema.name) return;
7705
- const value = editedValues.value[schema.name] ?? "";
7706
- const payload = buildPatchValue(schema.name, value, schema.schemaId, schema.multiValued);
7707
- props.onUpdate(payload);
7708
- editingFields.value = {
7709
- ...editingFields.value,
7710
- [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]: ""
7711
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 {}
7712
7813
  }
7713
7814
  function renderInput(schema) {
7714
7815
  const fieldName = schema.name ?? "";
@@ -7761,30 +7862,29 @@ const BaseUserProfile = (0, vue.defineComponent)({
7761
7862
  class: px("user-profile__field-placeholder"),
7762
7863
  onClick: () => startEditing(name, value)
7763
7864
  }, `Enter your ${label.toLowerCase()}`) : null;
7764
- const displayValueNode = hasValue ? (0, vue.h)(Typography_default, {
7765
- class: px("user-profile__field-value"),
7766
- variant: "body1"
7767
- }, () => String(value)) : editablePlaceholder;
7865
+ const displayValueNode = hasValue ? (0, vue.h)("span", { class: px("user-profile__field-value") }, String(value)) : editablePlaceholder;
7768
7866
  return (0, vue.h)("div", {
7769
7867
  class: px("user-profile__field"),
7770
7868
  key: name
7771
- }, [(0, vue.h)("div", { class: px("user-profile__field-label-col") }, [(0, vue.h)(Typography_default, {
7772
- class: px("user-profile__field-label"),
7773
- variant: "body2"
7774
- }, () => 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",
7775
7871
  onClick: () => saveField(schema),
7776
7872
  size: "small",
7777
7873
  variant: "solid"
7778
- }, () => "Save"), (0, vue.h)(Button_default, {
7874
+ }, () => t("userProfile.actions.save", "Save")), (0, vue.h)(Button_default, {
7875
+ color: "secondary",
7779
7876
  onClick: () => cancelEditing(name),
7780
7877
  size: "small",
7781
- variant: "text"
7782
- }, () => "Cancel")])]) : (0, vue.h)("div", { class: px("user-profile__field-display") }, [displayValueNode, isEditable ? (0, vue.h)("button", {
7783
- "aria-label": `Edit ${label}`,
7878
+ variant: "solid"
7879
+ }, () => t("userProfile.actions.cancel", "Cancel"))] : hasValue ? (0, vue.h)(Button_default, {
7784
7880
  class: px("user-profile__field-edit-btn"),
7881
+ color: "secondary",
7785
7882
  onClick: () => startEditing(name, value),
7786
- type: "button"
7787
- }, [(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]);
7788
7888
  }
7789
7889
  function renderProfileWithoutSchemas() {
7790
7890
  const data = props.flattenedProfile || props.profile;
@@ -7795,21 +7895,20 @@ const BaseUserProfile = (0, vue.defineComponent)({
7795
7895
  }).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => (0, vue.h)("div", {
7796
7896
  class: px("user-profile__field"),
7797
7897
  key
7798
- }, [(0, vue.h)("div", { class: px("user-profile__field-label-col") }, [(0, vue.h)(Typography_default, {
7799
- class: px("user-profile__field-label"),
7800
- variant: "body2"
7801
- }, () => formatLabel(key))]), (0, vue.h)("div", { class: px("user-profile__field-value-col") }, [(0, vue.h)(Typography_default, {
7802
- class: px("user-profile__field-value"),
7803
- variant: "body1"
7804
- }, () => 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))])]));
7805
7899
  }
7806
7900
  function renderHero(currentUser) {
7807
7901
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS$1, currentUser);
7808
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;
7809
7904
  const avatarGradient = getAvatarGradient$1(String(currentUser["username"] || currentUser["userName"] || currentUser["email"] || currentUser["sub"] || displayName));
7810
7905
  const initials = displayName.split(" ").map((w) => w.charAt(0)).slice(0, 2).join("").toUpperCase() || "?";
7811
7906
  const avatarSizeClass = px(`user-profile__avatar--${props.avatarSize ?? "lg"}`);
7812
- 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", {
7813
7912
  class: [px("user-profile__avatar"), avatarSizeClass].join(" "),
7814
7913
  style: { background: avatarGradient }
7815
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])]);
@@ -7835,15 +7934,31 @@ const BaseUserProfile = (0, vue.defineComponent)({
7835
7934
  props.className ?? ""
7836
7935
  ].filter(Boolean).join(" ");
7837
7936
  const children = [];
7838
- children.push((0, vue.h)("div", { class: px("user-profile__header") }, [(0, vue.h)("span", { class: px("user-profile__title") }, props.title ?? "Profile")]));
7839
- children.push((0, vue.h)(Divider_default, { class: px("user-profile__header-divider") }));
7840
7937
  if (props.showAvatar !== false && currentUser) children.push(renderHero(currentUser));
7841
7938
  if (props.error) children.push((0, vue.h)(Alert_default, {
7842
7939
  class: px("user-profile__error"),
7843
7940
  severity: "error"
7844
7941
  }, () => props.error));
7845
7942
  if (props.isLoading) children.push((0, vue.h)("div", { class: px("user-profile__loading") }, [(0, vue.h)(Spinner_default)]));
7846
- 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) {
7847
7962
  const fieldRows = schemas.filter((s) => s.name && shouldShowField(s.name)).sort((a, b) => {
7848
7963
  return (a.displayOrder ? parseInt(a.displayOrder, 10) : 999) - (b.displayOrder ? parseInt(b.displayOrder, 10) : 999);
7849
7964
  }).map((schema) => {
@@ -7873,7 +7988,7 @@ const updateMeProfile = async ({ fetcher, instanceId = 0,...requestConfig }) =>
7873
7988
  const response = await __thunderid_browser.FetchHttpClient.getInstance(instanceId).request({
7874
7989
  data: config.body ? JSON.parse(config.body) : void 0,
7875
7990
  headers: config.headers,
7876
- method: config.method || "PATCH",
7991
+ method: config.method || "PUT",
7877
7992
  url
7878
7993
  });
7879
7994
  return {
@@ -7924,6 +8039,10 @@ const UserProfile = (0, vue.defineComponent)({
7924
8039
  default: () => [],
7925
8040
  type: Array
7926
8041
  },
8042
+ preferences: {
8043
+ default: void 0,
8044
+ type: Object
8045
+ },
7927
8046
  showAvatar: {
7928
8047
  default: true,
7929
8048
  type: Boolean
@@ -7938,19 +8057,37 @@ const UserProfile = (0, vue.defineComponent)({
7938
8057
  }
7939
8058
  },
7940
8059
  setup(props, { slots }) {
7941
- const { baseUrl, endpoints, instanceId } = useThunderID_default();
7942
- const { flattenedProfile, profile, onUpdateProfile } = useUser_default();
8060
+ const { baseUrl, endpoints, instanceId, preferences: contextPreferences } = useThunderID_default();
8061
+ const { flattenedProfile, profile, onUpdateProfile, updateProfile, userSchema } = useUser_default();
7943
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);
7944
8072
  const error = (0, vue.ref)(null);
7945
8073
  async function handleProfileUpdate(payload) {
7946
- if (!baseUrl) return;
7947
8074
  error.value = null;
7948
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;
7949
8086
  onUpdateProfile(await updateMeProfile_default({
7950
8087
  baseUrl,
7951
8088
  url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMe", { endpoints }),
7952
8089
  instanceId,
7953
- payload
8090
+ payload: updatedAttributes
7954
8091
  }));
7955
8092
  } catch (caughtError) {
7956
8093
  let message = t("user.profile.update.generic.error") || "Failed to update profile. Please try again.";
@@ -7965,15 +8102,18 @@ const UserProfile = (0, vue.defineComponent)({
7965
8102
  class: (0, __thunderid_browser.withVendorCSSClassPrefix)("user-profile--styled"),
7966
8103
  className: props.className,
7967
8104
  compact: props.compact,
7968
- editable: props.editable,
8105
+ editable: isEditableProfile.value,
7969
8106
  error: error.value,
7970
8107
  flattenedProfile: flattenedProfile?.value,
7971
8108
  hideFields: props.hideFields,
7972
- onUpdate: handleProfileUpdate,
8109
+ onUpdate: isEditableProfile.value ? handleProfileUpdate : void 0,
8110
+ preferences: resolvedPreferences.value,
7973
8111
  profile: profile?.value?.profile ?? flattenedProfile?.value,
7974
8112
  showAvatar: props.showAvatar,
7975
8113
  showFields: props.showFields,
7976
- title: props.title
8114
+ t,
8115
+ title: props.title,
8116
+ userSchema: userSchema?.value
7977
8117
  }, slots);
7978
8118
  }
7979
8119
  });
@@ -7985,18 +8125,18 @@ const DEFAULT_ATTRIBUTE_MAPPINGS = {
7985
8125
  email: ["emails", "email"],
7986
8126
  firstName: ["name.givenName", "given_name"],
7987
8127
  lastName: ["name.familyName", "family_name"],
8128
+ picture: [
8129
+ "picture",
8130
+ "avatar",
8131
+ "pictureUrl",
8132
+ "attributes.picture"
8133
+ ],
7988
8134
  username: [
7989
8135
  "userName",
7990
8136
  "username",
7991
8137
  "user_name"
7992
8138
  ]
7993
8139
  };
7994
- /** Approximate min-width for each size, used for auto-alignment decisions. */
7995
- const MENU_MIN_WIDTHS = {
7996
- lg: 280,
7997
- md: 220,
7998
- sm: 180
7999
- };
8000
8140
  const AVATAR_GRADIENTS = [
8001
8141
  "linear-gradient(135deg, #4b6ef5 0%, #7c3aed 100%)",
8002
8142
  "linear-gradient(135deg, #0ea5e9 0%, #4b6ef5 100%)",
@@ -8018,16 +8158,19 @@ function resolveUserInfo(user) {
8018
8158
  displayName: "User",
8019
8159
  gradient: AVATAR_GRADIENTS[0],
8020
8160
  initials: "?",
8161
+ picture: null,
8021
8162
  subtitle: ""
8022
8163
  };
8023
8164
  const displayName = getDisplayName_default(DEFAULT_ATTRIBUTE_MAPPINGS, user) || "User";
8024
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;
8025
8167
  const seed = String(getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || displayName);
8026
8168
  const subtitle = String(getMappedUserProfileValue_default("email", DEFAULT_ATTRIBUTE_MAPPINGS, user) || getMappedUserProfileValue_default("username", DEFAULT_ATTRIBUTE_MAPPINGS, user) || "");
8027
8169
  return {
8028
8170
  displayName,
8029
8171
  gradient: getAvatarGradient(seed),
8030
8172
  initials,
8173
+ picture,
8031
8174
  subtitle
8032
8175
  };
8033
8176
  }
@@ -8083,13 +8226,46 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8083
8226
  setup(props, { slots }) {
8084
8227
  const isOpen = (0, vue.ref)(false);
8085
8228
  const containerRef = (0, vue.ref)(null);
8229
+ const modalOverlayRef = (0, vue.ref)(null);
8230
+ const avatarImageError = (0, vue.ref)(false);
8086
8231
  const px = __thunderid_browser.withVendorCSSClassPrefix;
8232
+ (0, vue.watch)(() => resolveUserInfo(props.user ?? null).picture, () => {
8233
+ avatarImageError.value = false;
8234
+ });
8087
8235
  function handleClickOutside(event) {
8088
8236
  if (containerRef.value && !containerRef.value.contains(event.target)) isOpen.value = false;
8089
8237
  }
8238
+ function handleModalClose() {
8239
+ props.onProfileModalClose?.();
8240
+ (containerRef.value?.querySelector(`.${px("user-dropdown__trigger")}`))?.focus();
8241
+ }
8090
8242
  function handleKeyDown(event) {
8091
- 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;
8092
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
+ });
8093
8269
  (0, vue.onMounted)(() => {
8094
8270
  document.addEventListener("click", handleClickOutside);
8095
8271
  document.addEventListener("keydown", handleKeyDown);
@@ -8102,8 +8278,7 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8102
8278
  if (props.menuAlign !== "auto") return props.menuAlign ?? "right";
8103
8279
  if (!containerRef.value) return "right";
8104
8280
  const rect = containerRef.value.getBoundingClientRect();
8105
- const menuWidth = MENU_MIN_WIDTHS[props.size ?? "md"] ?? 220;
8106
- return window.innerWidth - rect.right >= menuWidth ? "right" : "left";
8281
+ return window.innerWidth - rect.left >= rect.right ? "left" : "right";
8107
8282
  }
8108
8283
  return () => {
8109
8284
  if (slots.default) return slots.default({
@@ -8113,7 +8288,7 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8113
8288
  },
8114
8289
  user: props.user
8115
8290
  });
8116
- const { displayName, initials, gradient, subtitle } = resolveUserInfo(props.user ?? null);
8291
+ const { displayName, initials, gradient, picture, subtitle } = resolveUserInfo(props.user ?? null);
8117
8292
  const size = props.size ?? "md";
8118
8293
  const avatarSizeClass = size !== "md" ? px(`user-dropdown__avatar--${size}`) : "";
8119
8294
  const triggerClass = [px("user-dropdown__trigger"), isOpen.value ? px("user-dropdown__trigger--open") : ""].filter(Boolean).join(" ");
@@ -8126,7 +8301,14 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8126
8301
  isOpen.value = !isOpen.value;
8127
8302
  },
8128
8303
  type: "button"
8129
- }, [(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", {
8130
8312
  class: [px("user-dropdown__avatar"), avatarSizeClass].filter(Boolean).join(" "),
8131
8313
  style: { background: gradient }
8132
8314
  }, initials), props.showChevron ? (0, vue.h)("span", { class: px("user-dropdown__chevron") }, [(0, vue.h)(ChevronDownIcon, { size: 14 })]) : null]);
@@ -8140,7 +8322,11 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8140
8322
  sizeClass
8141
8323
  ].filter(Boolean).join(" ");
8142
8324
  const menuChildren = [];
8143
- 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", {
8144
8330
  class: px("user-dropdown__menu-header-avatar"),
8145
8331
  style: { background: gradient }
8146
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])]));
@@ -8186,17 +8372,21 @@ const BaseUserDropdown = (0, vue.defineComponent)({
8186
8372
  class: [px("user-dropdown"), props.className].filter(Boolean).join(" "),
8187
8373
  ref: containerRef
8188
8374
  }, [trigger, menu]);
8189
- 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",
8190
8378
  class: px("user-dropdown__modal-overlay"),
8379
+ ref: modalOverlayRef,
8380
+ role: "dialog",
8191
8381
  onClick: (e) => {
8192
- if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) props.onProfileModalClose?.();
8382
+ if (e.target.classList.contains(px("user-dropdown__modal-overlay"))) handleModalClose();
8193
8383
  }
8194
8384
  }, [(0, vue.h)("div", { class: px("user-dropdown__modal-content") }, [(0, vue.h)("button", {
8195
8385
  "aria-label": "Close profile",
8196
8386
  class: px("user-dropdown__modal-close"),
8197
- onClick: props.onProfileModalClose,
8387
+ onClick: handleModalClose,
8198
8388
  type: "button"
8199
- }, [(0, vue.h)(XIcon, { size: 18 })]), props.profileContent])])]);
8389
+ }, [(0, vue.h)(XIcon, { size: 18 })]), props.profileContent])])])]);
8200
8390
  return container;
8201
8391
  };
8202
8392
  }
@@ -9700,6 +9890,7 @@ Object.defineProperty(exports, 'getActiveTheme', {
9700
9890
  }
9701
9891
  });
9702
9892
  exports.getAuthComponentHeadings = getAuthComponentHeadings_default;
9893
+ exports.getUsersMeMeta = getUsersMeMeta_default;
9703
9894
  Object.defineProperty(exports, 'handleWebAuthnAuthentication', {
9704
9895
  enumerable: true,
9705
9896
  get: function () {