Skip to content

Commit c475bd7

Browse files
committed
feat: add more additional class wrapper for style usage
1 parent 9abc6c4 commit c475bd7

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

assets/index.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@
9090
white-space: nowrap;
9191
overflow: hidden;
9292
text-overflow: ellipsis;
93+
94+
// Fixed first or last should special process
95+
&.@{tablePrefixCls}-cell-fix-left-last,
96+
&.@{tablePrefixCls}-cell-fix-right-first {
97+
overflow: visible;
98+
99+
.@{tablePrefixCls}-cell-content {
100+
overflow: hidden;
101+
text-overflow: ellipsis;
102+
display: block;
103+
}
104+
}
93105
}
94106
}
95107

examples/fixedColumns.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface RecordType {
1313

1414
const columns: ColumnType<RecordType>[] = [
1515
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' },
16-
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left' },
16+
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left', ellipsis: true },
1717
{ title: 'title3', dataIndex: 'c', key: 'c' },
1818
{ title: 'title4', dataIndex: 'b', key: 'd' },
1919
{ title: 'title5', dataIndex: 'b', key: 'e' },
@@ -39,7 +39,12 @@ const columns: ColumnType<RecordType>[] = [
3939
];
4040

4141
const data: RecordType[] = [
42-
{ a: '123', b: 'xxxxxxxx', d: 3, key: '1' },
42+
{
43+
a: '123',
44+
b: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
45+
d: 3,
46+
key: '1',
47+
},
4348
{ a: 'cdd', b: 'edd12221', d: 3, key: '2' },
4449
{ a: '133', c: 'edd12221', d: 2, key: '3' },
4550
{ a: '133', c: 'edd12221', d: 2, key: '4' },

src/Cell/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ function Cell<RecordType extends DefaultRecordType>(
7676
}: CellProps<RecordType>,
7777
ref: React.Ref<any>,
7878
): React.ReactElement {
79+
const cellPrefixCls = `${prefixCls}-cell`;
80+
7981
// ==================== Child Node ====================
8082
let cellProps: CellType<RecordType>;
8183
let childNode: React.ReactNode;
@@ -104,6 +106,10 @@ function Cell<RecordType extends DefaultRecordType>(
104106
childNode = null;
105107
}
106108

109+
if (ellipsis && (lastFixLeft || firstFixRight)) {
110+
childNode = <span className={`${cellPrefixCls}-content`}>{childNode}</span>;
111+
}
112+
107113
const { colSpan: cellColSpan, rowSpan: cellRowSpan } = cellProps || {};
108114
const mergedColSpan = cellColSpan !== undefined ? cellColSpan : colSpan;
109115
const mergedRowSpan = cellRowSpan !== undefined ? cellRowSpan : rowSpan;
@@ -142,8 +148,6 @@ function Cell<RecordType extends DefaultRecordType>(
142148
}
143149
}
144150

145-
const cellPrefixCls = `${prefixCls}-cell`;
146-
147151
const componentProps = {
148152
title,
149153
...additionalProps,
@@ -158,6 +162,7 @@ function Cell<RecordType extends DefaultRecordType>(
158162
[`${cellPrefixCls}-fix-right`]: isFixRight,
159163
[`${cellPrefixCls}-fix-right-first`]: firstFixRight,
160164
[`${cellPrefixCls}-ellipsis`]: ellipsis,
165+
[`${cellPrefixCls}-with-append`]: appendNode,
161166
},
162167
additionalProps.className,
163168
),

tests/__snapshots__/ExpandRow.spec.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
3333
class="rc-table-row rc-table-row-level-0"
3434
>
3535
<td
36-
class="rc-table-cell"
36+
class="rc-table-cell rc-table-cell-with-append"
3737
>
3838
<span
3939
class="rc-table-row-indent indent-level-0"
@@ -53,7 +53,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
5353
class="rc-table-row rc-table-row-level-1"
5454
>
5555
<td
56-
class="rc-table-cell"
56+
class="rc-table-cell rc-table-cell-with-append"
5757
>
5858
<span
5959
class="rc-table-row-indent indent-level-1"
@@ -73,7 +73,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
7373
class="rc-table-row rc-table-row-level-0"
7474
>
7575
<td
76-
class="rc-table-cell"
76+
class="rc-table-cell rc-table-cell-with-append"
7777
>
7878
<span
7979
class="rc-table-row-indent indent-level-0"
@@ -271,7 +271,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
271271
class="rc-table-row rc-table-row-level-0"
272272
>
273273
<td
274-
class="rc-table-cell"
274+
class="rc-table-cell rc-table-cell-with-append"
275275
>
276276
<span
277277
class="rc-table-row-indent indent-level-0"
@@ -291,7 +291,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
291291
class="rc-table-row rc-table-row-level-1"
292292
>
293293
<td
294-
class="rc-table-cell"
294+
class="rc-table-cell rc-table-cell-with-append"
295295
>
296296
<span
297297
class="rc-table-row-indent indent-level-1"
@@ -311,7 +311,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
311311
class="rc-table-row rc-table-row-level-0"
312312
>
313313
<td
314-
class="rc-table-cell"
314+
class="rc-table-cell rc-table-cell-with-append"
315315
>
316316
<span
317317
class="rc-table-row-indent indent-level-0"

0 commit comments

Comments
 (0)