File tree 7 files changed +109
-23
lines changed
7 files changed +109
-23
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const bem = buildBem('aui-table');
8
8
/** Cell template container that adds the right classes and role. */
9
9
@Directive ( {
10
10
// eslint-disable-next-line @angular-eslint/directive-selector
11
- selector : 'aui-table-cell' ,
11
+ selector : 'aui-table-cell,[aui-table-cell] ' ,
12
12
host : {
13
13
class : 'aui-table__cell' ,
14
14
role : 'gridcell' ,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const bem = buildBem('aui-table');
8
8
/** Header cell template container that adds the right classes and role. */
9
9
@Directive ( {
10
10
// eslint-disable-next-line @angular-eslint/directive-selector
11
- selector : 'aui-table-header-cell' ,
11
+ selector : 'aui-table-header-cell,[aui-table-header-cell] ' ,
12
12
host : {
13
13
class : 'aui-table__header-cell' ,
14
14
role : 'columnheader' ,
Original file line number Diff line number Diff line change 7
7
8
8
/** Header template container that contains the cell outlet. Adds the right class and role. */
9
9
@Component ( {
10
- selector : 'aui-table-header-row' ,
10
+ selector : 'aui-table-header-row,[aui-table-header-row] ' ,
11
11
template : CDK_ROW_TEMPLATE ,
12
12
host : {
13
13
class : 'aui-table__header-row' ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
11
11
12
12
/** Data row template container that contains the cell outlet. Adds the right class and role. */
13
13
@Component ( {
14
- selector : 'aui-table-row' ,
14
+ selector : 'aui-table-row,[aui-table-row] ' ,
15
15
template : CDK_ROW_TEMPLATE ,
16
16
host : {
17
17
class : 'aui-table__row' ,
Original file line number Diff line number Diff line change 135
135
}
136
136
}
137
137
}
138
+
139
+ // 作为table组件,使用原生table是常见的,所以提供内置的样式适配
140
+ table .aui-table {
141
+ display : table ;
142
+ width : 100% ;
143
+ border-spacing : 0 ;
144
+
145
+ .aui-table {
146
+ & __row ,
147
+ & __header-row {
148
+ display : table-row ;
149
+ }
150
+
151
+ & __cell ,
152
+ & __header-cell {
153
+ display : table-cell ;
154
+ }
155
+
156
+ & __cell {
157
+ border-bottom-width : 1px ;
158
+ border-bottom-style : solid ;
159
+ border-color : use-rgb (n-8 );
160
+ }
161
+ }
162
+
163
+ tbody {
164
+ tr :first-child td {
165
+ border-top-width : 1px ;
166
+ border-top-style : solid ;
167
+
168
+ & :first-child {
169
+ border-top-left-radius : use-var (border-radius-l );
170
+ }
171
+
172
+ & :last-child {
173
+ border-top-right-radius : use-var (border-radius-l );
174
+ }
175
+ }
176
+
177
+ tr td :first-child {
178
+ border-left-width : 1px ;
179
+ border-left-style : solid ;
180
+ }
181
+
182
+ tr td :last-child {
183
+ border-right-width : 1px ;
184
+ border-right-style : solid ;
185
+ }
186
+
187
+ tr :last-child td {
188
+ & :first-child {
189
+ border-bottom-left-radius : use-var (border-radius-l );
190
+ }
191
+
192
+ & :last-child {
193
+ border-bottom-right-radius : use-var (border-radius-l );
194
+ }
195
+ }
196
+ }
197
+
198
+ [rowspan = ' 0' ] {
199
+ display : none ;
200
+ }
201
+ }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
26
26
} from './table-placeholder.directive' ;
27
27
28
28
@Component ( {
29
- selector : 'aui-table' ,
29
+ selector : 'aui-table,[aui-table] ' ,
30
30
exportAs : 'auiTable' ,
31
31
encapsulation : ViewEncapsulation . None ,
32
32
styleUrls : [ 'table.component.scss' , 'table-scroll.scss' ] ,
Original file line number Diff line number Diff line change @@ -54,44 +54,66 @@ Table 组件基于 CdkTable 开发, 加了一些 alauda 自定义的表格样式
54
54
>
55
55
{ {
56
56
template: /* HTML */ `
57
- <aui-table [dataSource]="dataSource">
57
+ <table
58
+ aui-table
59
+ [dataSource]="dataSource"
60
+ >
58
61
<ng-container auiTableColumnDef="id">
59
- <aui-table-header-cell *auiTableHeaderCellDef>
62
+ <th
63
+ aui-table-header-cell
64
+ *auiTableHeaderCellDef
65
+ >
60
66
No.
61
- </aui-table-header-cell>
62
- <aui-table-cell *auiTableCellDef="let item">
67
+ </th>
68
+ <td
69
+ aui-table-cell
70
+ *auiTableCellDef="let item"
71
+ [attr.rowspan]="item.id === 1 ? 2 : item.id === 2 ? 0 : 1"
72
+ >
63
73
<div>{{ item.id }}</div>
64
- </aui-table-cell >
74
+ </td >
65
75
</ng-container>
66
76
<ng-container auiTableColumnDef="name">
67
- <aui-table-header-cell *auiTableHeaderCellDef>
77
+ <th
78
+ aui-table-header-cell
79
+ *auiTableHeaderCellDef
80
+ >
68
81
Name
69
- </aui-table-header-cell>
70
- <aui-table-cell
82
+ </th>
83
+ <td
84
+ aui-table-cell
71
85
*auiTableCellDef="let item"
72
86
direction="column"
73
87
>
74
88
{{ item.name }}
75
89
<div style="font-size: 12px;color: #96989b;line-height: 16px;">
76
90
{{ item.displayName }}
77
91
</div>
78
- </aui-table-cell >
92
+ </td >
79
93
</ng-container>
80
94
<ng-container auiTableColumnDef="value">
81
- <aui-table-header-cell *auiTableHeaderCellDef>
95
+ <th
96
+ aui-table-header-cell
97
+ *auiTableHeaderCellDef
98
+ >
82
99
Value
83
- </aui-table-header-cell>
84
- <aui-table-cell *auiTableCellDef="let item">
100
+ </th>
101
+ <td
102
+ aui-table-cell
103
+ *auiTableCellDef="let item"
104
+ >
85
105
{{ item.value }}
86
- </aui-table-cell >
106
+ </td >
87
107
</ng-container>
88
- <aui-table-header-row
108
+ <tr
109
+ aui-table-header-row
89
110
*auiTableHeaderRowDef="['id', 'name', 'value']; sticky: sticky"
90
- ></aui-table-header-row>
91
- <aui-table-row
111
+ ></tr>
112
+ <tr
113
+ aui-table-row
92
114
*auiTableRowDef="let row; columns: ['id', 'name', 'value'];"
93
- ></aui-table-row >
94
- </aui- table>
115
+ ></tr >
116
+ </table>
95
117
` ,
96
118
props: {
97
119
dataSource: DATA_SOURCE ,
You can’t perform that action at this time.
0 commit comments