Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-views-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/ui': patch
---

Fix minor internal issues with TypeScript types.
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"register"
],
"scripts": {
"build": "pnpm build:umd && pnpm build:esm && pnpm check:no-rhc",
"build": "pnpm build:umd && pnpm build:esm && pnpm check:no-rhc && pnpm type-check",
"build:analyze": "rspack build --config rspack.config.js --env production --env analyze --analyze",
"build:esm": "tsdown",
"build:rsdoctor": "RSDOCTOR=true rspack build --config rspack.config.js --env production",
Expand Down
35 changes: 20 additions & 15 deletions packages/ui/src/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import type {
__internal_UserVerificationProps,
Clerk,
ClerkOptions,
CreateOrganizationProps,
CreateOrganizationModalProps,
EnvironmentResource,
GoogleOneTapProps,
OrganizationProfileProps,
OrganizationProfileModalProps,
SignInProps,
SignInModalProps,
SignUpProps,
SignUpModalProps,
UserProfileModalProps,
UserProfileProps,
WaitlistProps,
WaitlistModalProps,
} from '@clerk/shared/types';
import { createDeferredPromise } from '@clerk/shared/utils';
import React, { Suspense, useCallback, useRef, useSyncExternalStore } from 'react';
Expand Down Expand Up @@ -161,16 +165,16 @@ interface ComponentsState {
appearance: Appearance | undefined;
options: ClerkOptions | undefined;
googleOneTapModal: null | GoogleOneTapProps;
signInModal: null | SignInProps;
signUpModal: null | SignUpProps;
userProfileModal: null | UserProfileProps;
signInModal: null | SignInModalProps;
signUpModal: null | SignUpModalProps;
userProfileModal: null | UserProfileModalProps;
userVerificationModal: null | __internal_UserVerificationProps;
organizationProfileModal: null | OrganizationProfileProps;
createOrganizationModal: null | CreateOrganizationProps;
organizationProfileModal: null | OrganizationProfileModalProps;
createOrganizationModal: null | CreateOrganizationModalProps;
enableOrganizationsPromptModal: null | __internal_EnableOrganizationsPromptProps;
blankCaptchaModal: null;
organizationSwitcherPrefetch: boolean;
waitlistModal: null | WaitlistProps;
waitlistModal: null | WaitlistModalProps;
checkoutDrawer: {
open: false;
props: null | __internal_CheckoutProps;
Expand Down Expand Up @@ -502,7 +506,7 @@ const Components = (props: ComponentsProps) => {
onClose={() => componentsControls.closeModal('signIn')}
onExternalNavigate={() => componentsControls.closeModal('signIn')}
startPath={buildVirtualRouterUrl({ base: '/sign-in', path: urlStateParam?.path })}
getContainer={signInModal?.getContainer}
getContainer={signInModal?.getContainer ?? (() => null)}
componentName={'SignInModal'}
>
<SignInModal {...signInModal} />
Expand All @@ -520,7 +524,7 @@ const Components = (props: ComponentsProps) => {
onClose={() => componentsControls.closeModal('signUp')}
onExternalNavigate={() => componentsControls.closeModal('signUp')}
startPath={buildVirtualRouterUrl({ base: '/sign-up', path: urlStateParam?.path })}
getContainer={signUpModal?.getContainer}
getContainer={signUpModal?.getContainer ?? (() => null)}
componentName={'SignUpModal'}
>
<SignInModal {...disambiguateRedirectOptions(signUpModal, 'signup')} />
Expand All @@ -541,7 +545,7 @@ const Components = (props: ComponentsProps) => {
base: '/user',
path: userProfileModal?.__experimental_startPath || urlStateParam?.path,
})}
getContainer={userProfileModal?.getContainer}
getContainer={userProfileModal?.getContainer ?? (() => null)}
componentName={'UserProfileModal'}
modalContainerSx={{ alignItems: 'center' }}
modalContentSx={t => ({ height: `min(${t.sizes.$176}, calc(100% - ${t.sizes.$12}))`, margin: 0 })}
Expand All @@ -559,7 +563,7 @@ const Components = (props: ComponentsProps) => {
onClose={() => componentsControls.closeModal('userVerification')}
onExternalNavigate={() => componentsControls.closeModal('userVerification')}
startPath={buildVirtualRouterUrl({ base: '/user-verification', path: urlStateParam?.path })}
getContainer={userVerificationModal?.getContainer}
getContainer={userVerificationModal?.getContainer ?? (() => null)}
componentName={'UserVerificationModal'}
modalContainerSx={{ alignItems: 'center' }}
>
Expand All @@ -579,7 +583,7 @@ const Components = (props: ComponentsProps) => {
base: '/organizationProfile',
path: organizationProfileModal?.__experimental_startPath || urlStateParam?.path,
})}
getContainer={organizationProfileModal?.getContainer}
getContainer={organizationProfileModal?.getContainer ?? (() => null)}
componentName={'OrganizationProfileModal'}
modalContainerSx={{ alignItems: 'center' }}
modalContentSx={t => ({ height: `min(${t.sizes.$176}, calc(100% - ${t.sizes.$12}))`, margin: 0 })}
Expand All @@ -597,7 +601,7 @@ const Components = (props: ComponentsProps) => {
onClose={() => componentsControls.closeModal('createOrganization')}
onExternalNavigate={() => componentsControls.closeModal('createOrganization')}
startPath={buildVirtualRouterUrl({ base: '/createOrganization', path: urlStateParam?.path })}
getContainer={createOrganizationModal?.getContainer}
getContainer={createOrganizationModal?.getContainer ?? (() => null)}
componentName={'CreateOrganizationModal'}
modalContainerSx={{ alignItems: 'center' }}
modalContentSx={t => ({ height: `min(${t.sizes.$120}, calc(100% - ${t.sizes.$12}))`, margin: 0 })}
Expand All @@ -615,7 +619,7 @@ const Components = (props: ComponentsProps) => {
onClose={() => componentsControls.closeModal('waitlist')}
onExternalNavigate={() => componentsControls.closeModal('waitlist')}
startPath={buildVirtualRouterUrl({ base: '/waitlist', path: urlStateParam?.path })}
getContainer={waitlistModal?.getContainer}
getContainer={waitlistModal?.getContainer ?? (() => null)}
componentName={'WaitlistModal'}
>
<WaitlistModal {...waitlistModal} />
Expand All @@ -638,6 +642,7 @@ const Components = (props: ComponentsProps) => {
canCloseModal={false}
modalId={'cl-modal-captcha-wrapper'}
modalStyle={{ visibility: 'hidden', pointerEvents: 'none' }}
getContainer={() => null}
>
<BlankCaptchaModal />
</LazyModalRenderer>
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/Checkout/CheckoutForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const CheckoutForm = withCardStateProvider(() => {

const fee =
planPeriod === 'month'
? plan.fee
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
plan.fee!
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
plan.annualMonthlyFee!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ function PaymentAttemptBody({ subscriptionItem }: { subscriptionItem: BillingSub

const fee =
subscriptionItem.planPeriod === 'month'
? subscriptionItem.plan.fee
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
subscriptionItem.plan.fee!
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
subscriptionItem.plan.annualMonthlyFee!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ export function PricingTableMatrix({
{plans.map(plan => {
const highlight = plan.slug === highlightedPlan;
const planFee = !plan.annualMonthlyFee
? plan.fee
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
plan.fee!
: planPeriod === 'annual'
? plan.annualMonthlyFee
: plan.fee;
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
plan.fee!;

return (
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { OrganizationCreationDefaultsAlert } from './OrganizationCreationDefault

type CreateOrganizationScreenProps = {
onCancel?: () => void;
organizationCreationDefaults?: OrganizationCreationDefaultsResource;
organizationCreationDefaults?: OrganizationCreationDefaultsResource | null;
};

export const CreateOrganizationScreen = (props: CreateOrganizationScreenProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { localizationKeys } from '@/localization';
export function OrganizationCreationDefaultsAlert({
organizationCreationDefaults,
}: {
organizationCreationDefaults?: OrganizationCreationDefaultsResource;
organizationCreationDefaults?: OrganizationCreationDefaultsResource | null;
}) {
const localizationKey = advisoryToLocalizationKey(organizationCreationDefaults?.advisory);
if (!localizationKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const SetupMfaStartScreen = withCardStateProvider((props: SetupMfaStartSc
})}
>
{availableMethods.map(method => {
const methodConfig = METHOD_CONFIG[method] ?? null;
const methodConfig = METHOD_CONFIG[method as keyof typeof METHOD_CONFIG] ?? null;

if (!methodConfig) {
return null;
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/components/SubscriptionDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ const SubscriptionCardActions = ({ subscription }: { subscription: BillingSubscr
currency: subscription.plan.annualFee!.currencySymbol,
})
: localizationKeys('billing.switchToMonthlyWithPrice', {
price: normalizeFormatted(subscription.plan.fee.amountFormatted),
currency: subscription.plan.fee.currencySymbol,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
price: normalizeFormatted(subscription.plan.fee!.amountFormatted),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
currency: subscription.plan.fee!.currencySymbol,
}),
onClick: () => {
openCheckout({
Expand Down Expand Up @@ -508,7 +510,8 @@ const SubscriptionCard = ({ subscription }: { subscription: BillingSubscriptionI

const fee =
subscription.planPeriod === 'month'
? subscription.plan.fee
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
subscription.plan.fee!
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
subscription.plan.annualFee!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function SubscriptionsList({

function SubscriptionRow({ subscription, length }: { subscription: BillingSubscriptionItemResource; length: number }) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const fee = subscription.planPeriod === 'annual' ? subscription.plan.annualFee! : subscription.plan.fee;
const fee = subscription.planPeriod === 'annual' ? subscription.plan.annualFee! : subscription.plan.fee!;
const { captionForSubscription } = usePlansContext();

const feeFormatted = useMemo(() => {
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/internal/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { ClerkUIConstructor } from '@clerk/shared/ui';

import type { Appearance } from './appearance';

export type { ComponentControls, MountComponentRenderer } from '../Components';
export type { WithInternalRouting } from './routing';

Expand Down
10 changes: 9 additions & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
"@/ui*": ["./src/*"]
}
},
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "**/__tests__/**"],
"exclude": [
"node_modules",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/__tests__/**",
"./src/test/**"
],
"include": ["src", "src/global.d.ts"]
}
Loading