Skip to content
Merged
8 changes: 8 additions & 0 deletions .changeset/shaky-sloths-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@clerk/clerk-js': minor
'@clerk/types': minor
'@clerk/nextjs': minor
'@clerk/clerk-react': minor
---

[Billing Beta] Update `PlanDetailsProps` to reflect that either `planId` or `plan` is allowed.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('PlanDetails', () => {
currency: 'USD',
isDefault: false,
payerType: ['user'],
forPayerType: 'user' as const,
publiclyVisible: true,
slug: 'test-plan',
avatarUrl: 'https://example.com/avatar.png',
Expand Down
7 changes: 6 additions & 1 deletion packages/clerk-js/src/ui/lazyModules/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { lazy, Suspense } from 'react';
import type { FlowMetadata } from '../elements/contexts';
import type { Drawer } from '../elements/Drawer';
import type { ThemableCssProp } from '../styledSystem';
import type { AvailableComponentCtx } from '../types';
import type { ClerkComponentName } from './components';
import { ClerkComponents } from './components';

Expand Down Expand Up @@ -76,7 +77,11 @@ export const LazyComponentRenderer = (props: LazyComponentRendererProps) => {
>
<Portal
node={props.node}
component={ClerkComponents[props.componentName as ClerkComponentName]}
component={
ClerkComponents[props.componentName as ClerkComponentName] as React.ComponentType<
Omit<AvailableComponentCtx, 'componentName'>
>
}
props={props.componentProps}
componentName={props.componentName}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/PlanDetailsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { withClerk } from './withClerk';
export const PlanDetailsButton = withClerk(
({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<__experimental_PlanDetailsButtonProps>>) => {
const { plan, planId, initialPlanPeriod, planDetailsProps, ...rest } = props;

children = normalizeWithDefaultValue(children, 'Plan details');
const child = assertSingleChild(children)('PlanDetailsButton');

Expand All @@ -49,7 +50,7 @@ export const PlanDetailsButton = withClerk(
planId,
initialPlanPeriod,
...planDetailsProps,
});
} as __experimental_PlanDetailsButtonProps);
};

const wrappedChildClickHandler: React.MouseEventHandler = async e => {
Expand Down
32 changes: 26 additions & 6 deletions packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@
*/
windowNavigate: (to: URL | string) => void;
},
) => Promise<unknown> | unknown;

Check warning on line 1141 in packages/types/src/clerk.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'unknown' overrides all other types in this union type

export type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;

Expand Down Expand Up @@ -1886,10 +1886,20 @@
* <ClerkProvider clerkJsVersion="x.x.x" />
* ```
*/
export type __internal_PlanDetailsProps = {
export type __internal_PlanDetailsProps = (
| {
planId: string;
plan?: never;
}
| {
/**
* The plan object will be used as initial data until the plan is fetched from the server.
*/
plan: CommercePlanResource;
planId?: never;
}
) & {
appearance?: PlanDetailTheme;
plan?: CommercePlanResource;
planId?: string;
initialPlanPeriod?: CommerceSubscriptionPlanPeriod;
portalId?: string;
portalRoot?: PortalRoot;
Expand All @@ -1905,9 +1915,19 @@
* <ClerkProvider clerkJsVersion="x.x.x" />
* ```
*/
export type __experimental_PlanDetailsButtonProps = {
plan?: CommercePlanResource;
planId?: string;
export type __experimental_PlanDetailsButtonProps = (
| {
planId: string;
plan?: never;
}
| {
/**
* The plan object will be used as initial data until the plan is fetched from the server.
*/
plan: CommercePlanResource;
planId?: never;
}
) & {
initialPlanPeriod?: CommerceSubscriptionPlanPeriod;
planDetailsProps?: {
appearance?: PlanDetailTheme;
Expand Down
Loading