Skip to content

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

TypeScript

fix(Table): remove dead code — columnWidthToCSS and _lastBodyRowStyles (#797)

Cindy Zhang2c1fdb866a25
diff --git a/packages/core/src/Table/XDSTable.test.tsx b/packages/core/src/Table/XDSTable.test.tsx
index 1dd7d5a60d..551dc7c3f3 100644
--- a/packages/core/src/Table/XDSTable.test.tsx
+++ b/packages/core/src/Table/XDSTable.test.tsx
@@ -13,13 +13,7 @@ import {XDSBaseTable} from './XDSBaseTable';
import {XDSTable} from './XDSTable';
import {XDSTableRow} from './XDSTableRow';
import {XDSTableCell} from './XDSTableCell';
-import {
- proportional,
- pixel,
- generateColumns,
- columnWidthToCSS,
- capitalize,
-} from './columnUtils';
+import {proportional, pixel, generateColumns, capitalize} from './columnUtils';
import type {TablePlugin, XDSTableColumn} from './types';
// =============================================================================
@@ -68,20 +62,6 @@ describe('columnUtils', () => {
});
});
- describe('columnWidthToCSS', () => {
- it('converts pixel width to px string', () => {
- expect(columnWidthToCSS(pixel(100), 3)).toBe('100px');
- });
-
- it('converts proportional width to percentage', () => {
- expect(columnWidthToCSS(proportional(1), 4)).toBe('25%');
- });
-
- it('handles proportional(2) out of 4', () => {
- expect(columnWidthToCSS(proportional(2), 4)).toBe('50%');
- });
- });
-
describe('capitalize', () => {
it('capitalizes first letter', () => {
expect(capitalize('name')).toBe('Name');
diff --git a/packages/core/src/Table/columnUtils.ts b/packages/core/src/Table/columnUtils.ts
index fb7140cde3..edf85e3eb9 100644
--- a/packages/core/src/Table/columnUtils.ts
+++ b/packages/core/src/Table/columnUtils.ts
@@ -1,6 +1,6 @@
/**
* @file columnUtils.ts
- * @input XDSTableColumn, ColumnWidth types from types.ts
+ * @input XDSTableColumn types from types.ts
* @output Pure utility functions for column width and auto-generation
* @position Utility layer; consumed by XDSBaseTable.tsx
*
@@ -10,12 +10,7 @@
*/
import type {ReactNode} from 'react';
-import type {
- XDSTableColumn,
- ColumnWidth,
- ProportionalWidth,
- PixelWidth,
-} from './types';
+import type {XDSTableColumn, ProportionalWidth, PixelWidth} from './types';
/**
* Create a proportional column width (fr-like).
@@ -42,24 +37,6 @@ export function pixel(value: number): PixelWidth {
return {type: 'pixel', value};
}
-/**
- * Convert a ColumnWidth to a CSS width string for `<col>`.
- *
- * Proportional widths are converted to percentages relative to the
- * total proportional units across all columns.
- */
-export function columnWidthToCSS(
- width: ColumnWidth,
- totalProportional: number,
-): string {
- if (width.type === 'pixel') {
- return `${width.value}px`;
- }
- // Convert proportional to percentage
- const pct = (width.value / totalProportional) * 100;
- return `${pct}%`;
-}
-
/**
* Capitalize the first letter of a string.
* Used for auto-generating header text from data keys.
diff --git a/packages/core/src/Table/index.ts b/packages/core/src/Table/index.ts
index 1c9f210741..6b20534b1b 100644
--- a/packages/core/src/Table/index.ts
+++ b/packages/core/src/Table/index.ts
@@ -15,12 +15,7 @@ export {XDSTableHeaderCell} from './XDSTableHeaderCell';
export {XDSTableContext} from './XDSTableContext';
export {useXDSTableSelection} from './plugins/selection';
export {useXDSBaseTablePlugins} from './useXDSBaseTablePlugins';
-export {
- proportional,
- pixel,
- generateColumns,
- columnWidthToCSS,
-} from './columnUtils';
+export {proportional, pixel, generateColumns} from './columnUtils';
export type {
XDSTableColumn,
ColumnWidth,