diff --git a/.changeset/chilled-garlics-knock.md b/.changeset/chilled-garlics-knock.md
new file mode 100644
index 00000000000..962fa085af5
--- /dev/null
+++ b/.changeset/chilled-garlics-knock.md
@@ -0,0 +1,5 @@
+---
+'@clerk/clerk-js': patch
+---
+
+Add support for localizationKeys within commerce components.
diff --git a/packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx b/packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
index c44ff51e7ba..dea80762f82 100644
--- a/packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
+++ b/packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
@@ -1,7 +1,7 @@
import type { __experimental_CommerceCheckoutResource } from '@clerk/types';
import { useCheckoutContext } from '../../contexts';
-import { Box, Button, descriptors, Heading, Icon, Span, Text } from '../../customizables';
+import { Box, Button, descriptors, Heading, Icon, localizationKeys, Span, Text } from '../../customizables';
import { Drawer, LineItems } from '../../elements';
import { Check } from '../../icons';
@@ -98,30 +98,35 @@ export const CheckoutComplete = ({ checkout }: { checkout: __experimental_Commer
>
- Total paid
-
- {checkout.invoice
- ? `${checkout.invoice.totals.grandTotal.currencySymbol}${checkout.invoice.totals.grandTotal.amountFormatted}`
- : '–'}
-
+ {/* TODO(@COMMERCE): needs localization */}
+
+
{/* TODO(@COMMERCE): needs localization */}
- Payment method
-
- {checkout.paymentSource ? `${checkout.paymentSource.cardType} ⋯ ${checkout.paymentSource.last4}` : '–'}
-
+
+
{/* TODO(@COMMERCE): needs localization */}
- Invoice ID
- {checkout.invoice ? checkout.invoice.id : '–'}
+
+
-
+
>
);
diff --git a/packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx b/packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
index eeee8a29933..6edeb1167f1 100644
--- a/packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
+++ b/packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
@@ -40,40 +40,36 @@ export const CheckoutForm = ({
>
- {plan.name}
+
{/* TODO(@Commerce): needs localization */}
-
- {plan.currencySymbol}
- {planPeriod === 'month' ? plan.amountFormatted : plan.annualMonthlyAmountFormatted}
-
+
{/* TODO(@Commerce): needs localization */}
- Subtotal
-
- {totals.subtotal.currencySymbol}
- {totals.subtotal.amountFormatted}
-
+
+
{/* TODO(@Commerce): needs localization */}
- Tax
-
- {totals.taxTotal.currencySymbol}
- {totals.taxTotal.amountFormatted}
-
+
+
{/* TODO(@Commerce): needs localization */}
- Total{totals.totalDueNow ? ' Due Today' : ''}
-
- {totals.totalDueNow
- ? `${totals.totalDueNow.currencySymbol}${totals.totalDueNow.amountFormatted}`
- : `${totals.grandTotal.currencySymbol}${totals.grandTotal.amountFormatted}`}
-
+
+
@@ -201,7 +197,7 @@ const CheckoutFormElements = ({
onOpenChange={setOpenAccountFundsDropDown}
>
{/* TODO(@Commerce): needs localization */}
- Account Funds
+
{/* TODO(@Commerce): needs localization */}
- Add a New Payment Source
+
setPlanPeriod(value as PlanPeriod)}
>
- Monthly
- Annually
+
+
) : null}
diff --git a/packages/clerk-js/src/ui/elements/Disclosure.tsx b/packages/clerk-js/src/ui/elements/Disclosure.tsx
index 6731e394716..cf1a4a31749 100644
--- a/packages/clerk-js/src/ui/elements/Disclosure.tsx
+++ b/packages/clerk-js/src/ui/elements/Disclosure.tsx
@@ -1,6 +1,7 @@
import * as React from 'react';
-import { Box, descriptors, Icon, SimpleButton, useAppearance } from '../customizables';
+import type { LocalizationKey } from '../customizables';
+import { Box, descriptors, Icon, SimpleButton, Span, useAppearance } from '../customizables';
import { usePrefersReducedMotion } from '../hooks';
import { ChevronDown } from '../icons';
import type { ThemableCssProp } from '../styledSystem';
@@ -72,10 +73,10 @@ Root.displayName = 'Disclosure.Root';
* -----------------------------------------------------------------------------------------------*/
interface TriggerProps {
- children: React.ReactNode;
+ text: string | LocalizationKey;
}
-const Trigger = React.forwardRef(({ children }, ref) => {
+const Trigger = React.forwardRef(({ text }, ref) => {
const context = React.useContext(DisclosureContext);
if (!context) {
throw new Error('Disclosure.Trigger must be used within Disclosure.Root');
@@ -99,7 +100,7 @@ const Trigger = React.forwardRef(({ children },
zIndex: 2,
})}
>
- {children}
+
(({ title, children,
{title ? (
<>
- {title}
-
+ />
>
) : (
@@ -416,6 +416,9 @@ interface ConfirmationProps {
onOpenChange: (open: boolean) => void;
children: React.ReactNode;
actionsSlot: React.ReactNode;
+ /**
+ * @see https://floating-ui.com/docs/userole
+ */
roleProps?: UseRoleProps;
}
diff --git a/packages/clerk-js/src/ui/elements/LineItems.tsx b/packages/clerk-js/src/ui/elements/LineItems.tsx
index 9f6e6263ec5..4fb365953d4 100644
--- a/packages/clerk-js/src/ui/elements/LineItems.tsx
+++ b/packages/clerk-js/src/ui/elements/LineItems.tsx
@@ -1,5 +1,6 @@
import * as React from 'react';
+import type { LocalizationKey } from '../customizables';
import { Box, Dd, descriptors, Dl, Dt, Span } from '../customizables';
import { common } from '../styledSystem';
@@ -76,11 +77,11 @@ function Group({ children, borderTop = false, variant = 'primary' }: GroupProps)
* -----------------------------------------------------------------------------------------------*/
interface TitleProps {
- children: React.ReactNode;
- description?: React.ReactNode;
+ title: string | LocalizationKey;
+ description?: string | LocalizationKey;
}
-function Title({ children, description }: TitleProps) {
+function Title({ title, description }: TitleProps) {
const context = React.useContext(GroupContext);
if (!context) {
throw new Error('LineItems.Title must be used within LineItems.Group');
@@ -98,17 +99,16 @@ function Title({ children, description }: TitleProps) {
...common.textVariants(t)[textVariant],
})}
>
- {children}
+
{description ? (
({
fontSize: t.fontSizes.$sm,
color: t.colors.$colorTextSecondary,
})}
- >
- {description}
-
+ />
) : null}
);
@@ -119,18 +119,12 @@ function Title({ children, description }: TitleProps) {
* -----------------------------------------------------------------------------------------------*/
interface DescriptionProps {
- children: React.ReactNode;
- /**
- * Render a piece of text before the description text.
- */
- prefix?: React.ReactNode;
- /**
- * Render a note below the description text.
- */
- suffix?: React.ReactNode;
+ text: string | LocalizationKey;
+ prefix?: string | LocalizationKey;
+ suffix?: string | LocalizationKey;
}
-function Description({ children, prefix, suffix }: DescriptionProps) {
+function Description({ text, prefix, suffix }: DescriptionProps) {
const context = React.useContext(GroupContext);
if (!context) {
throw new Error('LineItems.Description must be used within LineItems.Group');
@@ -157,34 +151,31 @@ function Description({ children, prefix, suffix }: DescriptionProps) {
>
{prefix ? (
({
color: t.colors.$colorTextSecondary,
...common.textVariants(t).caption,
})}
- >
- {prefix}
-
+ />
) : null}
({
...common.textVariants(t).body,
})}
- >
- {children}
-
+ />
{suffix ? (
({
color: t.colors.$colorTextSecondary,
...common.textVariants(t).caption,
})}
- >
- {suffix}
-
+ />
) : null}
);
diff --git a/packages/clerk-js/src/ui/elements/SegmentedControl.tsx b/packages/clerk-js/src/ui/elements/SegmentedControl.tsx
index c3f9d2d03ae..44f3d637bfb 100644
--- a/packages/clerk-js/src/ui/elements/SegmentedControl.tsx
+++ b/packages/clerk-js/src/ui/elements/SegmentedControl.tsx
@@ -1,6 +1,7 @@
import { Composite, CompositeItem } from '@floating-ui/react';
import React, { createContext, useContext, useState } from 'react';
+import type { LocalizationKey } from '../customizables';
import { descriptors, Flex, SimpleButton } from '../customizables';
/* -------------------------------------------------------------------------------------------------
@@ -83,11 +84,11 @@ Root.displayName = 'SegmentedControl.Root';
* -----------------------------------------------------------------------------------------------*/
interface ButtonProps {
- children: React.ReactNode;
+ text: string | LocalizationKey;
value: string;
}
-const Button = React.forwardRef(({ children, value }, ref) => {
+const Button = React.forwardRef(({ text, value }, ref) => {
const { currentValue, onValueChange } = useSegmentedControlContext();
const isSelected = value === currentValue;
@@ -98,6 +99,7 @@ const Button = React.forwardRef(({ children, val
(({ children, val
zIndex: 2,
},
})}
- >
- {children}
-
+ />
);
}}
/>