diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-11-15 01:51:28 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-11-20 19:08:21 +0100 |
commit | 675e7a953f15e22578da5e37054fe6a2f34f7de5 (patch) | |
tree | 0918e1438c9c9e34fd784ffdfe21a1932a958865 /apps/files/src/components/VirtualList.vue | |
parent | 3822db51742eb12c67b525cab80ec0699e011684 (diff) | |
download | nextcloud-server-675e7a953f15e22578da5e37054fe6a2f34f7de5.tar.gz nextcloud-server-675e7a953f15e22578da5e37054fe6a2f34f7de5.zip |
refactor(files): Provide `useFileListWidth` composable
Replace the mixin with a composable, this is better typed and works in
both: Options- and Composition API.
Also added component tests for it.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src/components/VirtualList.vue')
-rw-r--r-- | apps/files/src/components/VirtualList.vue | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/files/src/components/VirtualList.vue b/apps/files/src/components/VirtualList.vue index 4c047a76a4e..d2b436344a5 100644 --- a/apps/files/src/components/VirtualList.vue +++ b/apps/files/src/components/VirtualList.vue @@ -55,10 +55,9 @@ import type { File, Folder, Node } from '@nextcloud/files' import type { PropType } from 'vue' +import { useFileListWidth } from '../composables/useFileListWidth.ts' +import { defineComponent } from 'vue' import debounce from 'debounce' -import Vue from 'vue' - -import filesListWidthMixin from '../mixins/filesListWidth.ts' import logger from '../logger.ts' interface RecycledPoolItem { @@ -70,11 +69,9 @@ type DataSource = File | Folder type DataSourceKey = keyof DataSource -export default Vue.extend({ +export default defineComponent({ name: 'VirtualList', - mixins: [filesListWidthMixin], - props: { dataComponent: { type: [Object, Function], @@ -101,7 +98,7 @@ export default Vue.extend({ default: false, }, /** - * Visually hidden caption for the table accesibility + * Visually hidden caption for the table accessibility */ caption: { type: String, @@ -109,6 +106,14 @@ export default Vue.extend({ }, }, + setup() { + const fileListWidth = useFileListWidth() + + return { + fileListWidth, + } + }, + data() { return { index: this.scrollToIndex, @@ -151,7 +156,7 @@ export default Vue.extend({ if (!this.gridMode) { return 1 } - return Math.floor(this.filesListWidth / this.itemWidth) + return Math.floor(this.fileListWidth / this.itemWidth) }, /** |