Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix: hardening audit — AlertDialog BaseProps, CheckboxList className, Table xdsClassName, use-client directives (#1518)

Cindy Zhang4b8e25f73882
diff --git a/packages/core/src/AlertDialog/XDSAlertDialog.tsx b/packages/core/src/AlertDialog/XDSAlertDialog.tsx
index 40f818ece4..011b21df2a 100644
--- a/packages/core/src/AlertDialog/XDSAlertDialog.tsx
+++ b/packages/core/src/AlertDialog/XDSAlertDialog.tsx
@@ -22,9 +22,10 @@ import {XDSHStack} from '../Stack';
import {XDSHeading} from '../Text/XDSHeading';
import {XDSText} from '../Text/XDSText';
import {XDSButton, type XDSButtonVariant} from '../Button';
+import type {XDSBaseProps} from '../XDSBaseProps';
import {xdsClassName} from '../utils';
-export interface XDSAlertDialogProps {
+export interface XDSAlertDialogProps extends XDSBaseProps<HTMLDivElement> {
/**
* Whether the dialog is open.
*/
@@ -113,6 +114,10 @@ export function XDSAlertDialog({
isActionLoading,
onAction,
width = 400,
+ xstyle,
+ className,
+ style,
+ 'data-testid': testId,
}: XDSAlertDialogProps) {
const titleId = useId();
const descriptionId = useId();
@@ -130,7 +135,12 @@ export function XDSAlertDialog({
role="alertdialog"
aria-labelledby={titleId}
aria-describedby={descriptionId}
- className={xdsClassName('alert-dialog')}>
+ className={
+ xdsClassName('alert-dialog') + (className ? ` ${className}` : '')
+ }
+ xstyle={xstyle}
+ style={style}
+ data-testid={testId}>
<XDSLayout
content={
<XDSLayoutContent>
diff --git a/packages/core/src/Carousel/index.ts b/packages/core/src/Carousel/index.ts
index 7d1c445832..6db94dea40 100644
--- a/packages/core/src/Carousel/index.ts
+++ b/packages/core/src/Carousel/index.ts
@@ -1,3 +1,5 @@
+'use client';
+
/**
* @file index.ts
* @input XDSCarousel component
diff --git a/packages/core/src/CheckboxList/XDSCheckboxList.tsx b/packages/core/src/CheckboxList/XDSCheckboxList.tsx
index 2844768c01..0cdbd19b9f 100644
--- a/packages/core/src/CheckboxList/XDSCheckboxList.tsx
+++ b/packages/core/src/CheckboxList/XDSCheckboxList.tsx
@@ -19,6 +19,7 @@ import {XDSField} from '../Field/XDSField';
import type {XDSInputStatus} from '../Field/types';
import {XDSList} from '../List/XDSList';
import type {XDSListDensity} from '../List/XDSListContext';
+import {xdsClassName} from '../utils';
import {
XDSCheckboxListContext,
type XDSCheckboxListContextValue,
@@ -205,7 +206,9 @@ export function XDSCheckboxList({
}
statusVariant="detached"
xstyle={xstyle}
- className={className}
+ className={
+ xdsClassName('checkbox-list') + (className ? ` ${className}` : '')
+ }
style={style}>
<XDSCheckboxListContext.Provider value={contextValue}>
<XDSList density={density} hasDividers={hasDividers}>
diff --git a/packages/core/src/Table/XDSBaseTable.tsx b/packages/core/src/Table/XDSBaseTable.tsx
index 38e013571d..bf2a223984 100644
--- a/packages/core/src/Table/XDSBaseTable.tsx
+++ b/packages/core/src/Table/XDSBaseTable.tsx
@@ -396,7 +396,10 @@ function XDSBaseTableInner<T extends Record<string, unknown>>({
ref={ref}
{...tableRenderProps.htmlProps}
{...mergeProps(
- xdsClassName('base-table'),
+ xdsClassName('base-table') +
+ (tableRenderProps.htmlProps.className
+ ? ` ${tableRenderProps.htmlProps.className}`
+ : ''),
stylex.props(...tableRenderProps.styles),
)}
style={tableStyle}>
diff --git a/packages/core/src/Table/XDSTable.tsx b/packages/core/src/Table/XDSTable.tsx
index 6544c527ce..6c09f03518 100644
--- a/packages/core/src/Table/XDSTable.tsx
+++ b/packages/core/src/Table/XDSTable.tsx
@@ -22,6 +22,7 @@ import {XDSTableCell} from './XDSTableCell';
import {XDSTableHeaderCell} from './XDSTableHeaderCell';
import {XDSTableContext} from './XDSTableContext';
import {useXDSBaseTablePlugins} from './useXDSBaseTablePlugins';
+import {xdsClassName} from '../utils';
import type {
XDSBaseTableProps,
XDSTableVerticalAlign,
@@ -120,8 +121,16 @@ function buildTableStylePlugin<
>(): TablePlugin<T> {
return {
transformTable(props: TableRenderProps): TableRenderProps {
+ const existingClass = props.htmlProps.className ?? '';
+ const tableClass = xdsClassName('table');
return {
...props,
+ htmlProps: {
+ ...props.htmlProps,
+ className: existingClass
+ ? `${existingClass} ${tableClass}`
+ : tableClass,
+ },
styles: [...props.styles, tableStyles.base, tableStyles.containerBleed],
};
},
diff --git a/packages/core/src/Thumbnail/index.ts b/packages/core/src/Thumbnail/index.ts
index fe96fe5741..42224ad4b4 100644
--- a/packages/core/src/Thumbnail/index.ts
+++ b/packages/core/src/Thumbnail/index.ts
@@ -1,3 +1,5 @@
+'use client';
+
/**
* @file Thumbnail component barrel export
*/