Skip to content

Commit 0541bca

Browse files
committed
feat(ui): add dNowrap for both td and th
1 parent 2b86dde commit 0541bca

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

packages/ui/src/components/table/Cell.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface DCellProps extends React.TdHTMLAttributes<HTMLTableCellElement>
2727
| undefined;
2828
dAlign: 'left' | 'right' | 'center';
2929
dEllipsis: boolean;
30+
dNowrap: boolean;
3031
}
3132

3233
export function DCell(props: DCellProps): JSX.Element | null {
@@ -37,6 +38,7 @@ export function DCell(props: DCellProps): JSX.Element | null {
3738
dFixed,
3839
dAlign,
3940
dEllipsis,
41+
dNowrap,
4042

4143
...restProps
4244
} = props;
@@ -100,6 +102,7 @@ export function DCell(props: DCellProps): JSX.Element | null {
100102
[`${dPrefix}table__cell--fixed-left`]: fixedLeft,
101103
[`${dPrefix}table__cell--fixed-right`]: fixedRight,
102104
[`${dPrefix}table__cell--ellipsis`]: ellipsis,
105+
[`${dPrefix}table__cell--nowrap`]: dNowrap,
103106
}),
104107
style: {
105108
...restProps.style,

packages/ui/src/components/table/TableTd.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function DTableTd(props: DTableTdProps): JSX.Element | null {
3535
//#endregion
3636

3737
return (
38-
<DCell {...restProps} dTag="td" dWidth={dWidth} dFixed={dFixed} dAlign={dAlign} dEllipsis={dEllipsis}>
38+
<DCell {...restProps} dTag="td" dWidth={dWidth} dFixed={dFixed} dAlign={dAlign} dEllipsis={dEllipsis} dNowrap={dNowrap}>
3939
{dNowrap ? children : <div className={`${dPrefix}table__cell-text`}>{children}</div>}
4040
</DCell>
4141
);

packages/ui/src/components/table/TableTh.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface DTableThProps extends React.ThHTMLAttributes<HTMLTableCellEleme
2525
};
2626
dAlign?: 'left' | 'right' | 'center';
2727
dEllipsis?: boolean;
28+
dNowrap?: boolean;
2829
}
2930

3031
const { COMPONENT_NAME } = registerComponentMate({ COMPONENT_NAME: 'DTable.Th' as const });
@@ -37,6 +38,7 @@ export function DTableTh(props: DTableThProps): JSX.Element | null {
3738
dFixed,
3839
dAlign = 'left',
3940
dEllipsis = false,
41+
dNowrap = true,
4042

4143
...restProps
4244
} = useComponentConfig(COMPONENT_NAME, props);
@@ -66,6 +68,7 @@ export function DTableTh(props: DTableThProps): JSX.Element | null {
6668
dFixed={dFixed}
6769
dAlign={dAlign}
6870
dEllipsis={dEllipsis}
71+
dNowrap={dNowrap}
6972
>
7073
<div className={`${dPrefix}table__cell-text`}>{children}</div>
7174
{(dSort || dActions.length > 0) && (

packages/ui/src/styles/components/table.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ $table-filter-option-height: 32px;
164164
}
165165
}
166166

167+
@include m(nowrap) {
168+
white-space: nowrap;
169+
}
170+
167171
@include m(th-sort) {
168172
cursor: pointer;
169173
}
@@ -180,7 +184,6 @@ $table-filter-option-height: 32px;
180184

181185
display: flex;
182186
align-items: center;
183-
white-space: nowrap;
184187

185188
@at-root {
186189
th #{$selector} {
@@ -191,7 +194,6 @@ $table-filter-option-height: 32px;
191194

192195
@include e(cell-text) {
193196
overflow-wrap: break-word;
194-
white-space: normal;
195197
}
196198

197199
@include e(th-actions) {

0 commit comments

Comments
 (0)