From 1c08463a5c0cd8c91e5df01e671dde96ac046cb4 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Tue, 17 Nov 2026 15:35:11 -0500 Subject: [PATCH] refactor(mosaic): export one props type per component --- .changeset/mosaic-profile-component.md | 2 +- .changeset/mosaic-switcher.md | 2 +- .../organization-switcher/organization-switcher.tsx | 2 ++ .../mosaic/src/features/profile/profile.test-d.tsx | 4 ++-- packages/mosaic/src/features/profile/profile.tsx | 3 --- packages/mosaic/src/features/switcher/switcher.tsx | 3 +-- .../mosaic/src/features/user-button/user-button.tsx | 2 ++ packages/mosaic/src/index.ts | 11 ++++------- 8 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.changeset/mosaic-profile-component.md b/.changeset/mosaic-profile-component.md index ec3e0d7209f..1376e158e74 100644 --- a/.changeset/mosaic-profile-component.md +++ b/.changeset/mosaic-profile-component.md @@ -27,4 +27,4 @@ To find the code to update, run: git grep -n '` | `` or `` | | `` | `` | | Organization props on `UserButton` (`hidePersonal`, `afterSelectOrganizationUrl`, `createOrganizationUrl`, ...) | The same props on `Switcher` | -| `UserButtonProps` (combined menu) | `CombinedSwitcherProps` | +| `UserButtonProps` (combined menu) | `SwitcherProps` | | `UserButtonProps` (user-only menu) | `UserButtonProps`, which now takes account options only | | `.cl-user-button-*` classes on the combined menu | `.cl-switcher-*`; `UserButton` keeps `.cl-user-button-*` | diff --git a/packages/mosaic/src/features/organization-switcher/organization-switcher.tsx b/packages/mosaic/src/features/organization-switcher/organization-switcher.tsx index a6c6a8b5f07..edcd3eae503 100644 --- a/packages/mosaic/src/features/organization-switcher/organization-switcher.tsx +++ b/packages/mosaic/src/features/organization-switcher/organization-switcher.tsx @@ -5,6 +5,8 @@ import type { ReactElement } from 'react'; import type { OrganizationSwitcherProps } from '../switcher/switcher'; import { Switcher } from '../switcher/switcher'; +export type { OrganizationSwitcherProps }; + /** * The active organization's avatar, and the menu behind it: switch organization or back to the * personal account, join a suggested or invited one, create one, invite members, and open the diff --git a/packages/mosaic/src/features/profile/profile.test-d.tsx b/packages/mosaic/src/features/profile/profile.test-d.tsx index 4039d20120f..c3d658b1e17 100644 --- a/packages/mosaic/src/features/profile/profile.test-d.tsx +++ b/packages/mosaic/src/features/profile/profile.test-d.tsx @@ -2,7 +2,7 @@ import { describe, test } from 'vitest'; import { OrganizationProfile } from '../organization-profile/organization-profile'; import { UserProfile } from '../user-profile/user-profile'; -import type { ProfileMode, ProfileProps } from './profile'; +import type { ProfileProps } from './profile'; import { Profile } from './profile'; describe('Profile props', () => { @@ -85,6 +85,6 @@ describe('UserProfile and OrganizationProfile props', () => { }); }); -function pickMode(): ProfileMode { +function pickMode(): NonNullable { return 'user'; } diff --git a/packages/mosaic/src/features/profile/profile.tsx b/packages/mosaic/src/features/profile/profile.tsx index 1312ea5fc04..055152963ff 100644 --- a/packages/mosaic/src/features/profile/profile.tsx +++ b/packages/mosaic/src/features/profile/profile.tsx @@ -29,9 +29,6 @@ import { UserProfileProfilePanel } from '../user-profile/user-profile-profile-pa import { UserProfileSecurityPanel } from '../user-profile/user-profile-security-panel'; import { useUserProfileUserModel } from '../user-profile/user-profile-user.model'; -/** Which pages the profile carries: the account's and the active organization's, or one of them alone. */ -export type ProfileMode = 'combined' | 'user' | 'organization'; - /** Everything `` takes in `combined` mode. */ export interface CombinedProfileProps extends UserProfileProps { /** diff --git a/packages/mosaic/src/features/switcher/switcher.tsx b/packages/mosaic/src/features/switcher/switcher.tsx index 64f50e4950c..2f9737ad6c1 100644 --- a/packages/mosaic/src/features/switcher/switcher.tsx +++ b/packages/mosaic/src/features/switcher/switcher.tsx @@ -26,8 +26,7 @@ type SwitcherBaseProps = SwitcherTriggerProps & fallback?: ReactNode; }; -/** Everything `` takes in `combined` mode. */ -export type CombinedSwitcherProps = SwitcherBaseProps & +type CombinedSwitcherProps = SwitcherBaseProps & SwitcherModelOptions & { /** * How much the labelled trigger carries: `full` badges the active organization with the account at a diff --git a/packages/mosaic/src/features/user-button/user-button.tsx b/packages/mosaic/src/features/user-button/user-button.tsx index 72bd4c3dbf9..a1e796889af 100644 --- a/packages/mosaic/src/features/user-button/user-button.tsx +++ b/packages/mosaic/src/features/user-button/user-button.tsx @@ -5,6 +5,8 @@ import type { ReactElement } from 'react'; import type { UserButtonProps } from '../switcher/switcher'; import { Switcher } from '../switcher/switcher'; +export type { UserButtonProps }; + /** * The signed-in user's avatar, and the account menu behind it: switch or add an account, open the * profile, and sign out. It never lists an organization, even when one is active. It is diff --git a/packages/mosaic/src/index.ts b/packages/mosaic/src/index.ts index f32a982c34b..b78ec944947 100644 --- a/packages/mosaic/src/index.ts +++ b/packages/mosaic/src/index.ts @@ -2,20 +2,17 @@ export type { OAuthConsentProps } from './features/oauth-consent/oauth-consent'; export { OAuthConsent } from './features/oauth-consent/oauth-consent'; -export type { - CombinedSwitcherProps, - OrganizationSwitcherProps, - SwitcherProps, - UserButtonProps, -} from './features/switcher/switcher'; +export type { SwitcherProps } from './features/switcher/switcher'; export { Switcher } from './features/switcher/switcher'; +export type { UserButtonProps } from './features/user-button/user-button'; export { UserButton } from './features/user-button/user-button'; export type { UserAvatarProps } from './features/user-avatar/user-avatar'; export { UserAvatar } from './features/user-avatar/user-avatar'; +export type { OrganizationSwitcherProps } from './features/organization-switcher/organization-switcher'; export { OrganizationSwitcher } from './features/organization-switcher/organization-switcher'; export type { OrganizationProfileProps } from './features/organization-profile/organization-profile'; export { OrganizationProfile } from './features/organization-profile/organization-profile'; -export type { CombinedProfileProps, ProfileMode, ProfileProps } from './features/profile/profile'; +export type { ProfileProps } from './features/profile/profile'; export { Profile } from './features/profile/profile'; export type { UserProfileProps } from './features/user-profile/user-profile'; export { UserProfile } from './features/user-profile/user-profile';