1
- import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js" ;
2
- import property from "@ui5/webcomponents-base/dist/decorators/property.js" ;
1
+ import { customElement , property , slot } from "@ui5/webcomponents-base/dist/decorators.js" ;
3
2
import TableCellBase from "./TableCellBase.js" ;
4
3
import TableHeaderCellTemplate from "./generated/templates/TableHeaderCellTemplate.lit.js" ;
5
4
import TableHeaderCellStyles from "./generated/themes/TableHeaderCell.css.js" ;
5
+ import Icon from "./Icon.js" ;
6
+ import TableSortOrder from "./types/TableSortOrder.js" ;
7
+ import type TableHeaderCellActionBase from "./TableHeaderCellActionBase.js" ;
8
+ import "@ui5/webcomponents-icons/dist/sort-ascending.js" ;
9
+ import "@ui5/webcomponents-icons/dist/sort-descending.js" ;
6
10
7
11
/**
8
12
* @class
@@ -28,6 +32,7 @@ import TableHeaderCellStyles from "./generated/themes/TableHeaderCell.css.js";
28
32
tag : "ui5-table-header-cell" ,
29
33
styles : [ TableCellBase . styles , TableHeaderCellStyles ] ,
30
34
template : TableHeaderCellTemplate ,
35
+ dependencies : [ Icon ] ,
31
36
} )
32
37
class TableHeaderCell extends TableCellBase {
33
38
/**
@@ -85,6 +90,27 @@ class TableHeaderCell extends TableCellBase {
85
90
@property ( )
86
91
popinText ?: string ;
87
92
93
+ /**
94
+ * Defines the sort indicator of the column.
95
+ *
96
+ * @default "None"
97
+ * @since 2.7.0
98
+ * @public
99
+ */
100
+ @property ( )
101
+ sortIndicator : `${TableSortOrder } ` = "None" ;
102
+
103
+ /**
104
+ * Defines the action of the column.
105
+ *
106
+ * **Note:** Only one `action` is allowed.
107
+ *
108
+ * @public
109
+ * @since 2.7.0
110
+ */
111
+ @slot ( )
112
+ action ! : Array < TableHeaderCellActionBase > ;
113
+
88
114
@property ( { type : Boolean , noAttribute : true } )
89
115
_popin = false ;
90
116
@@ -104,6 +130,17 @@ class TableHeaderCell extends TableCellBase {
104
130
// overwrite setting of TableCellBase so that the TableHeaderCell always uses the slot variable
105
131
this . style . justifyContent = `var(--horizontal-align-${ this . _individualSlot } )` ;
106
132
}
133
+ if ( this . sortIndicator !== TableSortOrder . None ) {
134
+ this . setAttribute ( "aria-sort" , this . sortIndicator . toLowerCase ( ) ) ;
135
+ } else if ( this . hasAttribute ( "aria-sort" ) ) {
136
+ this . removeAttribute ( "aria-sort" ) ;
137
+ }
138
+ }
139
+
140
+ get _sortIcon ( ) {
141
+ if ( this . sortIndicator !== TableSortOrder . None ) {
142
+ return `sort-${ this . sortIndicator . toLowerCase ( ) } ` ;
143
+ }
107
144
}
108
145
}
109
146
0 commit comments