Skip to content

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

TypeScript

fix(Timestamp,TreeList): extend XDSBaseProps, add xdsClassName to Timestamp (#963)

Cindy Zhangafb835961ea6
diff --git a/packages/core/src/Timestamp/XDSTimestamp.tsx b/packages/core/src/Timestamp/XDSTimestamp.tsx
index deb31c1713..0beabb006f 100644
--- a/packages/core/src/Timestamp/XDSTimestamp.tsx
+++ b/packages/core/src/Timestamp/XDSTimestamp.tsx
@@ -23,7 +23,7 @@ import type {
XDSTextWeight,
} from '../theme/types';
import {xdsClassName, mergeProps} from '../utils';
-import type {StyleXStyles} from '@stylexjs/stylex';
+import type {XDSBaseProps} from '../XDSBaseProps';
const LazyXDSTooltip = lazy(() =>
import('../Tooltip/XDSTooltip').then(mod => ({default: mod.XDSTooltip})),
@@ -43,8 +43,8 @@ export type XDSTimestampFormat =
| 'system_date_time'
| 'system_time';
-export interface XDSTimestampProps {
- /** Ref forwarded to the root element. */
+export interface XDSTimestampProps extends XDSBaseProps<HTMLTimeElement> {
+ /** Ref forwarded to the root `<time>` element. */
ref?: React.Ref<HTMLTimeElement>;
/** The date/time to display. Accepts Unix timestamps (seconds) or ISO 8601 strings. */
value: string | number;
@@ -100,18 +100,6 @@ export interface XDSTimestampProps {
* Font weight override.
*/
weight?: XDSTextWeight;
- /**
- * StyleX styles created via `stylex.create()`.
- */
- xstyle?: StyleXStyles;
- /**
- * CSS class name(s) appended to the root element.
- */
- className?: string;
- /**
- * Inline styles to apply to the root element.
- */
- style?: React.CSSProperties;
/** Test ID for testing frameworks. */
'data-testid'?: string;
}
@@ -382,6 +370,8 @@ export function XDSTimestamp({
const showTooltip = hasTooltip && effectiveFormat === 'relative';
+ const timestampClass = xdsClassName('timestamp', {format: effectiveFormat});
+
const timeElement = (
<XDSText
type={type}
@@ -389,7 +379,7 @@ export function XDSTimestamp({
color={color}
weight={weight}
xstyle={xstyle}
- className={className}
+ className={[timestampClass, className].filter(Boolean).join(' ')}
style={style}>
<time
ref={combinedRef}
diff --git a/packages/core/src/TreeList/XDSTreeList.tsx b/packages/core/src/TreeList/XDSTreeList.tsx
index 19a2689ebe..c8f9604fb7 100644
--- a/packages/core/src/TreeList/XDSTreeList.tsx
+++ b/packages/core/src/TreeList/XDSTreeList.tsx
@@ -12,12 +12,11 @@
* - /apps/storybook/stories/TreeList.stories.tsx
*/
-
import {useId, useState, useMemo, useCallback, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {StyleXStyles} from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
import {xdsClassName, mergeProps} from '../utils';
+import type {XDSBaseProps} from '../XDSBaseProps';
import {XDSTreeListItem} from './XDSTreeListItem';
import type {XDSTreeListItemData, XDSTreeListDensity} from './XDSTreeListTypes';
@@ -27,7 +26,7 @@ import type {XDSTreeListItemData, XDSTreeListDensity} from './XDSTreeListTypes';
export {type XDSTreeListDensity} from './XDSTreeListTypes';
-export interface XDSTreeListProps {
+export interface XDSTreeListProps extends XDSBaseProps<HTMLDivElement> {
/** Ref forwarded to the root element */
ref?: React.Ref<HTMLDivElement>;
@@ -52,24 +51,6 @@ export interface XDSTreeListProps {
*/
header?: ReactNode;
- /**
- * StyleX styles created via `stylex.create()`. Merged with the component's
- * base styles inside a single `stylex.props()` call for optimal deduplication.
- */
- xstyle?: StyleXStyles;
-
- /**
- * CSS class name(s) appended to the root element.
- * If you're using StyleX, prefer `xstyle` for optimal style deduplication.
- */
- className?: string;
-
- /**
- * Inline styles to apply to the root element. Spread after StyleX
- * inline styles, so these values take priority.
- */
- style?: React.CSSProperties;
-
/**
* Test ID for testing frameworks.
*/