@broberg/app-shell 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/preact.d.cts CHANGED
@@ -444,6 +444,13 @@ interface AccountPageProps {
444
444
  * reauth: that is a normal state here, not an error.
445
445
  */
446
446
  reauthHref?: string;
447
+ /**
448
+ * F095.5 — called with the profile AS THE SERVER NOW HOLDS IT after every
449
+ * successful change (name saved, picture uploaded, picture removed), so the
450
+ * host can update the shell's user menu at once. Not called on load or on a
451
+ * failed save.
452
+ */
453
+ onProfileChange?: (profile: AccountProfile) => void;
447
454
  }
448
455
  /** `/auth/login?returnTo=<this page>` — back here after signing in. */
449
456
  declare function defaultReauthHref(): string;
@@ -455,6 +462,6 @@ declare function defaultReauthHref(): string;
455
462
  * changes the name, the field shows that. On a failed save the field keeps the
456
463
  * typed text, so nothing is lost and the error says why.
457
464
  */
458
- declare function AccountPage({ lang, adapter, reauthHref }: AccountPageProps): JSX.Element;
465
+ declare function AccountPage({ lang, adapter, reauthHref, onProfileChange }: AccountPageProps): JSX.Element;
459
466
 
460
467
  export { AVATAR_MAX_BYTES, AVATAR_TYPES, type AccountAdapter, AccountError, AccountPage, type AccountPageProps, type AccountProfile, AppShell, type AppShellProps, Avatar, type Lang, type NavGroup, type NavItem, type Navigate, NotificationBell, type NotificationBellProps, type NotificationSource, PageHeader, type PageTab, PageTabs, type PreactNavGroup, type PreactNavItem, type ShellUser, Sidebar, type SidebarProps, TEXT, TopBar, type TopBarProps, UserMenu, type UserMenuItem, type UserMenuProps, accountErrorKind, activeNavLabel, badgeLabel, checkAvatarFile, createFetchAccountAdapter, createFetchNotificationSource, createMemoryNotificationSource, defaultReauthHref, initials, isActivePath, isExternal, readFlag, readSet, relativeTime, safeNavigate, useIsMobile, writeFlag, writeSet };
package/dist/preact.d.ts CHANGED
@@ -444,6 +444,13 @@ interface AccountPageProps {
444
444
  * reauth: that is a normal state here, not an error.
445
445
  */
446
446
  reauthHref?: string;
447
+ /**
448
+ * F095.5 — called with the profile AS THE SERVER NOW HOLDS IT after every
449
+ * successful change (name saved, picture uploaded, picture removed), so the
450
+ * host can update the shell's user menu at once. Not called on load or on a
451
+ * failed save.
452
+ */
453
+ onProfileChange?: (profile: AccountProfile) => void;
447
454
  }
448
455
  /** `/auth/login?returnTo=<this page>` — back here after signing in. */
449
456
  declare function defaultReauthHref(): string;
@@ -455,6 +462,6 @@ declare function defaultReauthHref(): string;
455
462
  * changes the name, the field shows that. On a failed save the field keeps the
456
463
  * typed text, so nothing is lost and the error says why.
457
464
  */
458
- declare function AccountPage({ lang, adapter, reauthHref }: AccountPageProps): JSX.Element;
465
+ declare function AccountPage({ lang, adapter, reauthHref, onProfileChange }: AccountPageProps): JSX.Element;
459
466
 
460
467
  export { AVATAR_MAX_BYTES, AVATAR_TYPES, type AccountAdapter, AccountError, AccountPage, type AccountPageProps, type AccountProfile, AppShell, type AppShellProps, Avatar, type Lang, type NavGroup, type NavItem, type Navigate, NotificationBell, type NotificationBellProps, type NotificationSource, PageHeader, type PageTab, PageTabs, type PreactNavGroup, type PreactNavItem, type ShellUser, Sidebar, type SidebarProps, TEXT, TopBar, type TopBarProps, UserMenu, type UserMenuItem, type UserMenuProps, accountErrorKind, activeNavLabel, badgeLabel, checkAvatarFile, createFetchAccountAdapter, createFetchNotificationSource, createMemoryNotificationSource, defaultReauthHref, initials, isActivePath, isExternal, readFlag, readSet, relativeTime, safeNavigate, useIsMobile, writeFlag, writeSet };
package/dist/preact.js CHANGED
@@ -1002,7 +1002,7 @@ function defaultReauthHref() {
1002
1002
  const here = typeof location === "undefined" ? "/" : location.pathname + location.search;
1003
1003
  return `/auth/login?returnTo=${encodeURIComponent(here)}`;
1004
1004
  }
1005
- function AccountPage({ lang, adapter, reauthHref }) {
1005
+ function AccountPage({ lang, adapter, reauthHref, onProfileChange }) {
1006
1006
  const t = TEXT[lang];
1007
1007
  const api = useMemo(() => adapter ?? createFetchAccountAdapter(), [adapter]);
1008
1008
  const [profile, setProfile] = useState(null);
@@ -1041,7 +1041,9 @@ function AccountPage({ lang, adapter, reauthHref }) {
1041
1041
  setBusy(what);
1042
1042
  setNotice(null);
1043
1043
  try {
1044
- apply(await op());
1044
+ const p = await op();
1045
+ apply(p);
1046
+ onProfileChange?.(p);
1045
1047
  setNotice({ kind: "ok", text: okText });
1046
1048
  } catch (e) {
1047
1049
  fail(e, t.couldNotSave);
@@ -1051,7 +1053,7 @@ function AccountPage({ lang, adapter, reauthHref }) {
1051
1053
  };
1052
1054
  const onSaveName = (e) => {
1053
1055
  e.preventDefault();
1054
- if (busy || reauth) return;
1056
+ if (busy || reauth || unchanged) return;
1055
1057
  void run("name", () => api.saveName(draft), t.saved);
1056
1058
  };
1057
1059
  const onFile = (e) => {
@@ -1071,6 +1073,7 @@ function AccountPage({ lang, adapter, reauthHref }) {
1071
1073
  void run("avatar", () => api.removeAvatar(), t.pictureRemoved);
1072
1074
  };
1073
1075
  const locked = reauth || busy !== null || profile === null;
1076
+ const unchanged = draft.trim() === (profile?.name ?? "").trim();
1074
1077
  const user = { name: profile?.name ?? void 0, email: profile?.email ?? void 0, picture: profile?.picture ?? void 0 };
1075
1078
  return /* @__PURE__ */ jsxs("section", { class: "bas-account", "data-testid": "account-page", "aria-busy": busy !== null, children: [
1076
1079
  reauth ? /* @__PURE__ */ jsxs("div", { class: "bas-account__note is-reauth", role: "alert", "data-testid": "account-reauth", children: [
@@ -1145,7 +1148,7 @@ function AccountPage({ lang, adapter, reauthHref }) {
1145
1148
  "data-testid": "account-name-input"
1146
1149
  }
1147
1150
  ),
1148
- /* @__PURE__ */ jsx("button", { type: "submit", class: "bas-account__btn is-primary", disabled: locked, "data-testid": "account-name-save", children: busy === "name" ? t.saving : t.save })
1151
+ /* @__PURE__ */ jsx("button", { type: "submit", class: "bas-account__btn is-primary", disabled: locked || unchanged, "data-testid": "account-name-save", children: busy === "name" ? t.saving : t.save })
1149
1152
  ] })
1150
1153
  ] }),
1151
1154
  profile.account_url ? /* @__PURE__ */ jsx(NavLink, { href: profile.account_url, class: "bas-account__link", "data-testid": "account-bid-link", children: t.bidSecurity }) : null