@polymarbot/nuxt-layer-shadcn-ui 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts" generic="TData extends Record<string, any>">
|
|
2
2
|
import type { InfiniteDataTableFetchParams, InfiniteDataTableProps } from './types'
|
|
3
|
+
import { useEventListener } from '@vueuse/core'
|
|
3
4
|
|
|
4
5
|
const props = withDefaults(defineProps<InfiniteDataTableProps<TData>>(), {
|
|
5
6
|
columns: () => [],
|
|
@@ -37,12 +38,28 @@ const isInitialLoad = computed(() => loading.value && internalData.value.length
|
|
|
37
38
|
// -- IntersectionObserver root: only when internal scroll is active --
|
|
38
39
|
|
|
39
40
|
const dataTableRef = ref<{ scrollEl?: HTMLElement } | null>(null)
|
|
41
|
+
const scrollEl = computed<HTMLElement | undefined>(() => dataTableRef.value?.scrollEl)
|
|
40
42
|
const intersectionOptions = computed<IntersectionObserverInit | undefined>(() => { // eslint-disable-line no-undef
|
|
41
43
|
if (!props.height) return undefined
|
|
42
|
-
const root =
|
|
44
|
+
const root = scrollEl.value
|
|
43
45
|
return root ? { root } : undefined
|
|
44
46
|
})
|
|
45
47
|
|
|
48
|
+
// -- Scroll-to-top availability --
|
|
49
|
+
|
|
50
|
+
const { isOverflowing, atStart } = useScrollState(scrollEl)
|
|
51
|
+
const isWindowAboveTable = ref(false)
|
|
52
|
+
|
|
53
|
+
function updateWindowPosition () {
|
|
54
|
+
const el = scrollEl.value
|
|
55
|
+
isWindowAboveTable.value = !!el && el.getBoundingClientRect().top < 0
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
useEventListener(window, 'scroll', updateWindowPosition, { passive: true })
|
|
59
|
+
onMounted(() => nextTick(updateWindowPosition))
|
|
60
|
+
|
|
61
|
+
const isAtTop = computed(() => isOverflowing.value ? atStart.value : !isWindowAboveTable.value)
|
|
62
|
+
|
|
46
63
|
// -- Helpers --
|
|
47
64
|
|
|
48
65
|
function getFilters (): Record<string, any> {
|
|
@@ -99,9 +116,9 @@ async function refresh () {
|
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
function scrollToTop () {
|
|
102
|
-
const el =
|
|
119
|
+
const el = scrollEl.value
|
|
103
120
|
if (!el) return
|
|
104
|
-
if (
|
|
121
|
+
if (isOverflowing.value) {
|
|
105
122
|
el.scrollTo({ top: 0, behavior: 'smooth' })
|
|
106
123
|
} else {
|
|
107
124
|
el.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
@@ -207,19 +224,21 @@ onMounted(() => {
|
|
|
207
224
|
<template #footer>
|
|
208
225
|
<slot name="footer">
|
|
209
226
|
<div class="gap-2 text-xs flex items-center justify-between">
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
<div>
|
|
228
|
+
<span
|
|
229
|
+
v-if="total != null"
|
|
230
|
+
class="text-muted-foreground"
|
|
231
|
+
>
|
|
232
|
+
{{ T('count', { loaded: internalData.length, total }) }}
|
|
233
|
+
</span>
|
|
234
|
+
</div>
|
|
216
235
|
<div class="gap-2 flex items-center">
|
|
217
236
|
<Tooltip :text="T('scrollToTop')">
|
|
218
237
|
<Button
|
|
219
238
|
variant="ghost"
|
|
220
239
|
size="icon-sm"
|
|
221
240
|
icon="arrow-up-to-line"
|
|
222
|
-
:disabled="loading || internalData.length === 0"
|
|
241
|
+
:disabled="loading || internalData.length === 0 || isAtTop"
|
|
223
242
|
@click="scrollToTop"
|
|
224
243
|
/>
|
|
225
244
|
</Tooltip>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/nuxt-layer-shadcn-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "Nuxt layer providing shadcn-vue based UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"vue-i18n": "^11",
|
|
43
43
|
"vue-router": "^4 || ^5"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e053ea4dd7358d5974b1118be8588d88be36e376"
|
|
46
46
|
}
|