@innertia-solutions/nuxt-theme-spark 0.1.44 → 0.1.46
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.
- package/components/Table.vue +17 -6
- package/package.json +1 -1
package/components/Table.vue
CHANGED
|
@@ -34,10 +34,13 @@ const tableData = ref([])
|
|
|
34
34
|
const rowCount = ref(0)
|
|
35
35
|
const loading = ref(false)
|
|
36
36
|
const isDataFromCache = ref(false)
|
|
37
|
-
const lastDataLength = ref(
|
|
37
|
+
const lastDataLength = ref(-1)
|
|
38
38
|
const lastRowHeight = ref(48)
|
|
39
39
|
const tableBodyRef = ref(null)
|
|
40
|
-
const skeletonRows = computed(() =>
|
|
40
|
+
const skeletonRows = computed(() => {
|
|
41
|
+
const count = lastDataLength.value < 0 ? pagination.value.pageSize : lastDataLength.value
|
|
42
|
+
return Array.from({ length: count })
|
|
43
|
+
})
|
|
41
44
|
const isGridView = computed(() => props.viewMode === 'grid')
|
|
42
45
|
|
|
43
46
|
// ─── TanStack state ───────────────────────────────────────────────────────────
|
|
@@ -141,10 +144,6 @@ const buildRequestParams = () => {
|
|
|
141
144
|
const fetchData = async () => {
|
|
142
145
|
if (tableData.value.length > 0) {
|
|
143
146
|
lastDataLength.value = tableData.value.length
|
|
144
|
-
if (tableBodyRef.value?.children[0]) {
|
|
145
|
-
const h = tableBodyRef.value.children[0].getBoundingClientRect().height
|
|
146
|
-
if (h > 0) lastRowHeight.value = h
|
|
147
|
-
}
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
tableData.value = []
|
|
@@ -248,6 +247,17 @@ const loadFromCacheOnMount = async () => {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
// ─── Watchers ─────────────────────────────────────────────────────────────────
|
|
250
|
+
watch(tableData, (newData) => {
|
|
251
|
+
if (newData.length > 0 && tableBodyRef.value) {
|
|
252
|
+
const firstDataRow = Array.from(tableBodyRef.value.children).find(el => el.dataset.rowType === 'data')
|
|
253
|
+
if (firstDataRow) {
|
|
254
|
+
const h = firstDataRow.getBoundingClientRect().height
|
|
255
|
+
if (h > 0) lastRowHeight.value = h
|
|
256
|
+
lastDataLength.value = newData.length
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}, { flush: 'post' })
|
|
260
|
+
|
|
251
261
|
watch(pagination, () => { if (!isRestoring.value) scheduleFetch(0) }, { deep: true })
|
|
252
262
|
watch(sorting, () => { if (!isRestoring.value) scheduleFetch(0) }, { deep: true })
|
|
253
263
|
watch(columnFilters, () => { if (!isRestoring.value) scheduleFetch(300) }, { deep: true })
|
|
@@ -569,6 +579,7 @@ defineExpose({
|
|
|
569
579
|
v-else
|
|
570
580
|
v-for="row in table.getRowModel().rows"
|
|
571
581
|
:key="row.id"
|
|
582
|
+
data-row-type="data"
|
|
572
583
|
@click="(e) => handleRowClick(row, e)"
|
|
573
584
|
@keydown="(e) => handleRowKeydown(row, e)"
|
|
574
585
|
:tabindex="isRowClickEnabled ? 0 : undefined"
|