|
1 | 1 | <template> |
2 | | - <table class="files-list" data-cy-files-list> |
| 2 | + <div class="files-list" data-cy-files-list> |
3 | 3 | <!-- Header --> |
4 | 4 | <div ref="before" class="files-list__before"> |
5 | 5 | <slot name="before" /> |
6 | 6 | </div> |
7 | 7 |
|
8 | | - <!-- Header --> |
9 | | - <thead ref="thead" class="files-list__thead" data-cy-files-list-thead> |
10 | | - <slot name="header" /> |
11 | | - </thead> |
12 | | - |
13 | | - <!-- Body --> |
14 | | - <tbody :style="tbodyStyle" |
15 | | - class="files-list__tbody" |
16 | | - :class="gridMode ? 'files-list__tbody--grid' : 'files-list__tbody--list'" |
17 | | - data-cy-files-list-tbody> |
18 | | - <component :is="dataComponent" |
19 | | - v-for="({key, item}, i) in renderedItems" |
20 | | - :key="key" |
21 | | - :source="item" |
22 | | - :index="i" |
23 | | - v-bind="extraProps" /> |
24 | | - </tbody> |
25 | | - |
26 | | - <!-- Footer --> |
27 | | - <tfoot v-show="isReady" |
28 | | - class="files-list__tfoot" |
29 | | - data-cy-files-list-tfoot> |
30 | | - <slot name="footer" /> |
31 | | - </tfoot> |
32 | | - </table> |
| 8 | + <table class="files-list__table"> |
| 9 | + <!-- Accessibility table caption for screen readers --> |
| 10 | + <caption v-if="caption" class="hidden-visually"> |
| 11 | + {{ caption }} |
| 12 | + </caption> |
| 13 | + |
| 14 | + <!-- Header --> |
| 15 | + <thead ref="thead" class="files-list__thead" data-cy-files-list-thead> |
| 16 | + <slot name="header" /> |
| 17 | + </thead> |
| 18 | + |
| 19 | + <!-- Body --> |
| 20 | + <tbody :style="tbodyStyle" |
| 21 | + class="files-list__tbody" |
| 22 | + :class="gridMode ? 'files-list__tbody--grid' : 'files-list__tbody--list'" |
| 23 | + data-cy-files-list-tbody> |
| 24 | + <component :is="dataComponent" |
| 25 | + v-for="({key, item}, i) in renderedItems" |
| 26 | + :key="key" |
| 27 | + :source="item" |
| 28 | + :index="i" |
| 29 | + v-bind="extraProps" /> |
| 30 | + </tbody> |
| 31 | + |
| 32 | + <!-- Footer --> |
| 33 | + <tfoot v-show="isReady" |
| 34 | + class="files-list__tfoot" |
| 35 | + data-cy-files-list-tfoot> |
| 36 | + <slot name="footer" /> |
| 37 | + </tfoot> |
| 38 | + </table> |
| 39 | + </div> |
33 | 40 | </template> |
34 | 41 |
|
35 | 42 | <script lang="ts"> |
@@ -75,6 +82,13 @@ export default Vue.extend({ |
75 | 82 | type: Boolean, |
76 | 83 | default: false, |
77 | 84 | }, |
| 85 | + /** |
| 86 | + * Visually hidden caption for the table accesibility |
| 87 | + */ |
| 88 | + caption: { |
| 89 | + type: String, |
| 90 | + default: '', |
| 91 | + }, |
78 | 92 | }, |
79 | 93 |
|
80 | 94 | data() { |
@@ -232,13 +246,13 @@ export default Vue.extend({ |
232 | 246 |
|
233 | 247 | onScroll() { |
234 | 248 | this._onScrollHandle ??= requestAnimationFrame(() => { |
235 | | - this._onScrollHandle = null; |
| 249 | + this._onScrollHandle = null |
236 | 250 | const topScroll = this.$el.scrollTop - this.beforeHeight |
237 | 251 | const index = Math.floor(topScroll / this.itemHeight) * this.columnCount |
238 | 252 | // Max 0 to prevent negative index |
239 | 253 | this.index = Math.max(0, index) |
240 | 254 | this.$emit('scroll') |
241 | | - }); |
| 255 | + }) |
242 | 256 | }, |
243 | 257 | }, |
244 | 258 | }) |
|
0 commit comments