@caido-utils/components 0.4.1 → 0.5.0
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.
|
@@ -12,11 +12,15 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
|
|
|
12
12
|
activeRow?: Record<string, unknown> | null;
|
|
13
13
|
scrollKey?: string;
|
|
14
14
|
dataKey?: string;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
loadingRows?: number;
|
|
15
17
|
}>, {
|
|
16
18
|
rowHeight: number;
|
|
17
19
|
selectable: boolean;
|
|
18
20
|
selection: () => never[];
|
|
19
21
|
activeRow: null;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
loadingRows: number;
|
|
20
24
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
21
25
|
items: Record<string, unknown>[];
|
|
22
26
|
columns: {
|
|
@@ -31,16 +35,22 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
|
|
|
31
35
|
activeRow?: Record<string, unknown> | null;
|
|
32
36
|
scrollKey?: string;
|
|
33
37
|
dataKey?: string;
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
loadingRows?: number;
|
|
34
40
|
}>, {
|
|
35
41
|
rowHeight: number;
|
|
36
42
|
selectable: boolean;
|
|
37
43
|
selection: () => never[];
|
|
38
44
|
activeRow: null;
|
|
45
|
+
loading: boolean;
|
|
46
|
+
loadingRows: number;
|
|
39
47
|
}>>>, {
|
|
48
|
+
loading: boolean;
|
|
40
49
|
rowHeight: number;
|
|
41
50
|
selectable: boolean | "single" | "multiple";
|
|
42
51
|
selection: Record<string, unknown>[] | null;
|
|
43
52
|
activeRow: Record<string, unknown> | null;
|
|
53
|
+
loadingRows: number;
|
|
44
54
|
}, {}>, {
|
|
45
55
|
[x: string]: ((props: {
|
|
46
56
|
item: any;
|
|
@@ -7,6 +7,7 @@ const ROW_HEIGHT = 25;
|
|
|
7
7
|
import DataTable from "primevue/datatable";
|
|
8
8
|
import Column from "primevue/column";
|
|
9
9
|
import Checkbox from "primevue/checkbox";
|
|
10
|
+
import Skeleton from "primevue/skeleton";
|
|
10
11
|
import {
|
|
11
12
|
ref,
|
|
12
13
|
computed,
|
|
@@ -34,12 +35,16 @@ const props = withDefaults(
|
|
|
34
35
|
activeRow?: Record<string, unknown> | null;
|
|
35
36
|
scrollKey?: string;
|
|
36
37
|
dataKey?: string;
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
loadingRows?: number;
|
|
37
40
|
}>(),
|
|
38
41
|
{
|
|
39
42
|
rowHeight: ROW_HEIGHT,
|
|
40
43
|
selectable: false,
|
|
41
44
|
selection: () => [],
|
|
42
45
|
activeRow: null,
|
|
46
|
+
loading: false,
|
|
47
|
+
loadingRows: 10,
|
|
43
48
|
},
|
|
44
49
|
);
|
|
45
50
|
|
|
@@ -62,7 +67,9 @@ let resizeObserver: ResizeObserver | undefined;
|
|
|
62
67
|
onMounted(() => {
|
|
63
68
|
if (!containerRef.value) return;
|
|
64
69
|
resizeObserver = new ResizeObserver((entries) => {
|
|
65
|
-
|
|
70
|
+
const height = entries[0]?.contentRect.height ?? 0;
|
|
71
|
+
if (height > 0) {
|
|
72
|
+
containerHeight.value = height;
|
|
66
73
|
tableKey.value++;
|
|
67
74
|
resizeObserver?.disconnect();
|
|
68
75
|
}
|
|
@@ -213,6 +220,18 @@ function activeRowClass(data: Record<string, unknown>): string {
|
|
|
213
220
|
return "";
|
|
214
221
|
}
|
|
215
222
|
|
|
223
|
+
const containerHeight = ref(0);
|
|
224
|
+
|
|
225
|
+
const autoLoadingRows = computed(() =>
|
|
226
|
+
containerHeight.value > 0
|
|
227
|
+
? Math.floor(containerHeight.value / props.rowHeight)
|
|
228
|
+
: props.loadingRows,
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const skeletonItems = computed(() =>
|
|
232
|
+
Array.from({ length: autoLoadingRows.value }, (_, i) => ({ _skeletonId: i })),
|
|
233
|
+
);
|
|
234
|
+
|
|
216
235
|
const tablePt = {};
|
|
217
236
|
|
|
218
237
|
const tablePtOptions = {
|
|
@@ -239,7 +258,7 @@ const columnPt = {
|
|
|
239
258
|
<div ref="containerRef" class="h-full min-h-0">
|
|
240
259
|
<DataTable
|
|
241
260
|
:key="tableKey"
|
|
242
|
-
:value="items"
|
|
261
|
+
:value="loading ? skeletonItems : items"
|
|
243
262
|
scrollable
|
|
244
263
|
scrollHeight="flex"
|
|
245
264
|
size="small"
|
|
@@ -284,8 +303,10 @@ const columnPt = {
|
|
|
284
303
|
]"
|
|
285
304
|
/>
|
|
286
305
|
</template>
|
|
287
|
-
<template
|
|
306
|
+
<template #body="{ data }">
|
|
307
|
+
<Skeleton v-if="loading" />
|
|
288
308
|
<slot
|
|
309
|
+
v-else-if="$slots[`cell-${col.field}`]"
|
|
289
310
|
:name="`cell-${col.field}`"
|
|
290
311
|
:item="data"
|
|
291
312
|
:value="data[col.field]"
|
|
@@ -12,11 +12,15 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
|
|
|
12
12
|
activeRow?: Record<string, unknown> | null;
|
|
13
13
|
scrollKey?: string;
|
|
14
14
|
dataKey?: string;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
loadingRows?: number;
|
|
15
17
|
}>, {
|
|
16
18
|
rowHeight: number;
|
|
17
19
|
selectable: boolean;
|
|
18
20
|
selection: () => never[];
|
|
19
21
|
activeRow: null;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
loadingRows: number;
|
|
20
24
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
21
25
|
items: Record<string, unknown>[];
|
|
22
26
|
columns: {
|
|
@@ -31,16 +35,22 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
|
|
|
31
35
|
activeRow?: Record<string, unknown> | null;
|
|
32
36
|
scrollKey?: string;
|
|
33
37
|
dataKey?: string;
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
loadingRows?: number;
|
|
34
40
|
}>, {
|
|
35
41
|
rowHeight: number;
|
|
36
42
|
selectable: boolean;
|
|
37
43
|
selection: () => never[];
|
|
38
44
|
activeRow: null;
|
|
45
|
+
loading: boolean;
|
|
46
|
+
loadingRows: number;
|
|
39
47
|
}>>>, {
|
|
48
|
+
loading: boolean;
|
|
40
49
|
rowHeight: number;
|
|
41
50
|
selectable: boolean | "single" | "multiple";
|
|
42
51
|
selection: Record<string, unknown>[] | null;
|
|
43
52
|
activeRow: Record<string, unknown> | null;
|
|
53
|
+
loadingRows: number;
|
|
44
54
|
}, {}>, {
|
|
45
55
|
[x: string]: ((props: {
|
|
46
56
|
item: any;
|