1
- import type { UmbUfmRenderElement } from '../../../ufm/components/ufm-render/index.js' ;
2
- import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
3
1
import {
4
2
css ,
5
3
customElement ,
@@ -11,6 +9,8 @@ import {
11
9
when ,
12
10
LitElement ,
13
11
} from '@umbraco-cms/backoffice/external/lit' ;
12
+ import type { UmbUfmRenderElement } from '../../../ufm/components/ufm-render/index.js' ;
13
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
14
14
15
15
// TODO: move to UI Library - entity actions should NOT be moved to UI Library but stay in an UmbTable element
16
16
export interface UmbTableItem {
@@ -163,17 +163,19 @@ export class UmbTableElement extends LitElement {
163
163
}
164
164
165
165
override render ( ) {
166
- return html `<uui- table class= "uui-text" >
167
- <uui- table-column
168
- .style = ${ when (
169
- ! ( this . config . allowSelection === false && this . config . hideIcon === true ) ,
170
- ( ) => 'width: 60px' ,
171
- ) } > </ uui- table-column>
172
- <uui- table-head>
173
- ${ this . _renderHeaderCheckboxCell ( ) } ${ this . columns . map ( ( column ) => this . _renderHeaderCell ( column ) ) }
174
- </ uui- table-head>
175
- ${ repeat ( this . items , ( item ) => item . id , this . _renderRow ) }
176
- </ uui- table> ` ;
166
+ return html `
167
+ <uui- table class= "uui-text" >
168
+ <uui- table-column
169
+ .style = ${ when (
170
+ ! ( this . config . allowSelection === false && this . config . hideIcon === true ) ,
171
+ ( ) => 'width: 60px' ,
172
+ ) } > </ uui- table-column>
173
+ <uui- table-head>
174
+ ${ this . _renderHeaderCheckboxCell ( ) } ${ this . columns . map ( ( column ) => this . _renderHeaderCell ( column ) ) }
175
+ </ uui- table-head>
176
+ ${ repeat ( this . items , ( item ) => item . id , this . _renderRow ) }
177
+ </ uui- table>
178
+ ` ;
177
179
}
178
180
179
181
private _renderHeaderCell ( column : UmbTableColumn ) {
@@ -201,48 +203,54 @@ export class UmbTableElement extends LitElement {
201
203
private _renderHeaderCheckboxCell ( ) {
202
204
if ( this . config . hideIcon && ! this . config . allowSelection ) return ;
203
205
204
- return html ` <uui- table-head- cell style= "--uui-table-cell-padding: 0" >
205
- ${ when (
206
- this . config . allowSelection ,
207
- ( ) =>
208
- html ` <uui- checkbox
209
- label= "Select All"
210
- style = "padding: var(- - uui- size-4) var(- - uui- size-5);"
211
- @change = "${ this . _handleAllRowsCheckboxChange } "
212
- ?checked= "${ this . selection . length === this . items . length } ">
213
- </ uui- checkbox> ` ,
214
- ) }
215
- </ uui- table-head- cell> ` ;
206
+ return html `
207
+ <uui- table-head- cell style= "--uui-table-cell-padding: 0" >
208
+ ${ when (
209
+ this . config . allowSelection ,
210
+ ( ) =>
211
+ html ` <uui- checkbox
212
+ label= "Select All"
213
+ style = "padding: var(- - uui- size-4) var(- - uui- size-5);"
214
+ @change = "${ this . _handleAllRowsCheckboxChange } "
215
+ ?checked= "${ this . selection . length === this . items . length } ">
216
+ </ uui- checkbox> ` ,
217
+ ) }
218
+ </ uui- table-head- cell>
219
+ ` ;
216
220
}
217
221
218
222
private _renderRow = ( item : UmbTableItem ) => {
219
- return html `<uui- table-row
220
- ?selectable= "${ this . config . allowSelection } "
221
- ?select- only = ${ this . _selectionMode }
222
- ?selected= ${ this . _isSelected ( item . id ) }
223
- @selected = ${ ( ) => this . _selectRow ( item . id ) }
224
- @deselected = ${ ( ) => this . _deselectRow ( item . id ) } >
225
- ${ this . _renderRowCheckboxCell ( item ) } ${ this . columns . map ( ( column ) => this . _renderRowCell ( column , item ) ) }
226
- </ uui- table-row> ` ;
223
+ return html `
224
+ <uui- table-row
225
+ ?selectable= "${ this . config . allowSelection } "
226
+ ?select- only = ${ this . _selectionMode }
227
+ ?selected= ${ this . _isSelected ( item . id ) }
228
+ @selected = ${ ( ) => this . _selectRow ( item . id ) }
229
+ @deselected = ${ ( ) => this . _deselectRow ( item . id ) } >
230
+ ${ this . _renderRowCheckboxCell ( item ) } ${ this . columns . map ( ( column ) => this . _renderRowCell ( column , item ) ) }
231
+ </ uui- table-row>
232
+ ` ;
227
233
} ;
228
234
229
235
private _renderRowCheckboxCell ( item : UmbTableItem ) {
230
236
if ( this . config . hideIcon && ! this . config . allowSelection ) return ;
231
237
232
- return html `<uui- table-cell>
233
- ${ when ( ! this . config . hideIcon , ( ) => html `<umb- icon name= "${ ifDefined ( item . icon ?? undefined ) } " > </ umb- icon> ` ) }
234
- ${ when (
235
- this . config . allowSelection ,
236
- ( ) => html `
237
- <uui- checkbox
238
- label= "Select Row"
239
- @click = ${ ( e : PointerEvent ) => e . stopPropagation ( ) }
240
- @change = ${ ( event : Event ) => this . _handleRowCheckboxChange ( event , item ) }
241
- ?checked= "${ this . _isSelected ( item . id ) } " >
242
- </ uui- checkbox>
243
- ` ,
244
- ) }
245
- </ uui- table-cell> ` ;
238
+ return html `
239
+ <uui- table-cell>
240
+ ${ when ( ! this . config . hideIcon , ( ) => html `<umb- icon name= "${ ifDefined ( item . icon ?? undefined ) } " > </ umb- icon> ` ) }
241
+ ${ when (
242
+ this . config . allowSelection ,
243
+ ( ) => html `
244
+ <uui- checkbox
245
+ label= "Select Row"
246
+ @click = ${ ( e : PointerEvent ) => e . stopPropagation ( ) }
247
+ @change = ${ ( event : Event ) => this . _handleRowCheckboxChange ( event , item ) }
248
+ ?checked= "${ this . _isSelected ( item . id ) } " >
249
+ </ uui- checkbox>
250
+ ` ,
251
+ ) }
252
+ </ uui- table-cell>
253
+ ` ;
246
254
}
247
255
248
256
private _renderRowCell ( column : UmbTableColumn , item : UmbTableItem ) {
@@ -251,7 +259,8 @@ export class UmbTableElement extends LitElement {
251
259
style= "--uui-table-cell-padding: 0 var(--uui-size-5); text-align:${ column . align ?? 'left' } ; width: ${ column . width || 'auto' } ;" >
252
260
${ this . _renderCellContent ( column , item ) }
253
261
</ uui- table-cell>
254
- </ uui- table-cell> ` ;
262
+ </ uui- table-cell>
263
+ ` ;
255
264
}
256
265
257
266
private _renderCellContent ( column : UmbTableColumn , item : UmbTableItem ) {
@@ -292,6 +301,7 @@ export class UmbTableElement extends LitElement {
292
301
position : sticky;
293
302
top : 0 ;
294
303
z-index : 1 ;
304
+ background-color : var (--uui-color-surface , # fff );
295
305
}
296
306
297
307
uui-table-row uui-checkbox {
@@ -331,6 +341,7 @@ export class UmbTableElement extends LitElement {
331
341
justify-content : space-between;
332
342
width : 100% ;
333
343
}
344
+
334
345
uui-table-head-cell button > span {
335
346
flex : 1 0 auto;
336
347
}
0 commit comments