@@ -3,6 +3,13 @@ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
3
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js" ;
4
4
import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation.js" ;
5
5
import NavigationMode from "@ui5/webcomponents-base/dist/types/NavigationMode.js" ;
6
+ import { isSpace , isEnter } from "@ui5/webcomponents-base/dist/Keys.js" ;
7
+ import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
8
+
9
+ // Texts
10
+ import { TABLE_LOAD_MORE_TEXT } from "./generated/i18n/i18n-defaults.js" ;
11
+
12
+ // Template
6
13
import TableTemplate from "./generated/templates/TableTemplate.lit.js" ;
7
14
8
15
// Styles
@@ -62,6 +69,39 @@ const metadata = {
62
69
type : String ,
63
70
} ,
64
71
72
+ /**
73
+ * Defines the text that will be displayed inside the additional row at the bottom of the table,
74
+ * meant for loading more rows upon press.
75
+ *
76
+ * <br><br>
77
+ * <b>Note:</b> If not specified a built-in text will be displayed.
78
+ * <br>
79
+ * <b>Note:</b> This property takes effect if <code>hasMore</code> is set.
80
+ *
81
+ * @type {string }
82
+ * @defaultvalue ""
83
+ * @since 1.0.0-rc.11
84
+ * @public
85
+ */
86
+ loadMoreText : {
87
+ type : String ,
88
+ } ,
89
+
90
+ /**
91
+ * Defines the subtext that will be displayed under the <code>loadMoreText</code>.
92
+ *
93
+ * <br><br>
94
+ * <b>Note:</b> This property takes effect if <code>hasMore</code> is set.
95
+ *
96
+ * @type {string }
97
+ * @defaultvalue ""
98
+ * @since 1.0.0-rc.11
99
+ * @public
100
+ */
101
+ loadMoreSubtext : {
102
+ type : String ,
103
+ } ,
104
+
65
105
/**
66
106
* Defines if the value of <code>noDataText</code> will be diplayed when there is no rows present in the table.
67
107
*
@@ -72,6 +112,20 @@ const metadata = {
72
112
showNoData : {
73
113
type : Boolean ,
74
114
} ,
115
+
116
+ /**
117
+ * Defines if additonal row will be displayed at the bottom of the table.
118
+ * Pressing on the row will fire the <code>load-more</code> event.
119
+ *
120
+ * @type {boolean }
121
+ * @defaultvalue false
122
+ * @since 1.0.0-rc.11
123
+ * @public
124
+ */
125
+ hasMore : {
126
+ type : Boolean ,
127
+ } ,
128
+
75
129
/**
76
130
* Determines whether the column headers remain fixed at the top of the page during
77
131
* vertical scrolling as long as the Web Component is in the viewport.
@@ -111,6 +165,14 @@ const metadata = {
111
165
type : Boolean ,
112
166
} ,
113
167
168
+ /**
169
+ * Defines the active state of the "load more" row.
170
+ * @private
171
+ */
172
+ _loadMoreActive : {
173
+ type : Boolean ,
174
+ } ,
175
+
114
176
/**
115
177
* Used to represent the table column header for the purpose of the item navigation as it does not work with DOM objects directly
116
178
* @private
@@ -146,6 +208,15 @@ const metadata = {
146
208
poppedColumns : { } ,
147
209
} ,
148
210
} ,
211
+
212
+ /**
213
+ * Fired when the user presses the <code>showMore</code> row of the table.
214
+ * <br><br>
215
+ * @event sap.ui.webcomponents.main.Table#load-more
216
+ * @public
217
+ * @since 1.0.0-rc.11
218
+ */
219
+ "load-more" : { } ,
149
220
} ,
150
221
} ;
151
222
@@ -199,6 +270,10 @@ class Table extends UI5Element {
199
270
return TableTemplate ;
200
271
}
201
272
273
+ static async onDefine ( ) {
274
+ await fetchI18nBundle ( "@ui5/webcomponents" ) ;
275
+ }
276
+
202
277
constructor ( ) {
203
278
super ( ) ;
204
279
@@ -217,6 +292,8 @@ class Table extends UI5Element {
217
292
this . fnOnRowFocused = this . onRowFocused . bind ( this ) ;
218
293
219
294
this . _handleResize = this . popinContent . bind ( this ) ;
295
+
296
+ this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
220
297
}
221
298
222
299
onBeforeRendering ( ) {
@@ -259,6 +336,29 @@ class Table extends UI5Element {
259
336
this . _itemNavigation . update ( this . _columnHeader ) ;
260
337
}
261
338
339
+ _onLoadMoreKeydown ( event ) {
340
+ if ( isSpace ( event ) ) {
341
+ event . preventDefault ( ) ;
342
+ this . _loadMoreActive = true ;
343
+ }
344
+
345
+ if ( isEnter ( event ) ) {
346
+ this . _onLoadMoreClick ( ) ;
347
+ this . _loadMoreActive = true ;
348
+ }
349
+ }
350
+
351
+ _onLoadMoreKeyup ( event ) {
352
+ if ( isSpace ( event ) ) {
353
+ this . _onLoadMoreClick ( ) ;
354
+ }
355
+ this . _loadMoreActive = false ;
356
+ }
357
+
358
+ _onLoadMoreClick ( ) {
359
+ this . fireEvent ( "load-more" ) ;
360
+ }
361
+
262
362
getColumnHeader ( ) {
263
363
return this . getDomRef ( ) && this . getDomRef ( ) . querySelector ( `#${ this . _id } -columnHeader` ) ;
264
364
}
@@ -316,6 +416,18 @@ class Table extends UI5Element {
316
416
} ;
317
417
} , this ) ;
318
418
}
419
+
420
+ get _loadMoreText ( ) {
421
+ return this . loadMoreText || this . i18nBundle . getText ( TABLE_LOAD_MORE_TEXT ) ;
422
+ }
423
+
424
+ get loadMoreAriaLabelledBy ( ) {
425
+ if ( this . moreDataText ) {
426
+ return `${ this . _id } -showMore-text ${ this . _id } -showMore-desc` ;
427
+ }
428
+
429
+ return `${ this . _id } -showMore-text` ;
430
+ }
319
431
}
320
432
321
433
Table . define ( ) ;
0 commit comments