@polymarbot/nuxt-layer-shadcn-ui 0.7.0 → 0.7.2
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.
|
@@ -32,7 +32,7 @@ const columns: DataTableColumn[] = [
|
|
|
32
32
|
{ field: 'createdAt', title: 'Created', width: '140px', type: 'date' },
|
|
33
33
|
]
|
|
34
34
|
|
|
35
|
-
/** Mock fetch using offset as the opaque
|
|
35
|
+
/** Mock fetch using offset as the opaque cursor */
|
|
36
36
|
function mockFetch (params: InfiniteDataTableFetchParams): Promise<InfiniteDataTableFetchResult<User>> {
|
|
37
37
|
return new Promise(resolve => {
|
|
38
38
|
setTimeout(() => {
|
|
@@ -53,7 +53,7 @@ function mockFetch (params: InfiniteDataTableFetchParams): Promise<InfiniteDataT
|
|
|
53
53
|
})
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const offset = params.
|
|
56
|
+
const offset = params.cursor ? Number(params.cursor) : 0
|
|
57
57
|
const items = data.slice(offset, offset + params.limit)
|
|
58
58
|
const nextOffset = offset + items.length
|
|
59
59
|
resolve({
|
|
@@ -22,7 +22,7 @@ const T = useTranslations('components.ui.InfiniteDataTable')
|
|
|
22
22
|
|
|
23
23
|
const loading = ref(false)
|
|
24
24
|
const internalData = ref<TData[]>([]) as Ref<TData[]>
|
|
25
|
-
const
|
|
25
|
+
const cursor = ref<string | undefined>(undefined)
|
|
26
26
|
const hasMore = ref(true)
|
|
27
27
|
const total = ref<number | undefined>(undefined)
|
|
28
28
|
const requestVersion = ref(0)
|
|
@@ -56,14 +56,14 @@ function getFilters (): Record<string, any> {
|
|
|
56
56
|
function buildFetchParams (): InfiniteDataTableFetchParams {
|
|
57
57
|
return {
|
|
58
58
|
...getFilters(),
|
|
59
|
-
|
|
59
|
+
cursor: cursor.value,
|
|
60
60
|
limit: props.pageSize,
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function resetState () {
|
|
65
65
|
internalData.value = []
|
|
66
|
-
|
|
66
|
+
cursor.value = undefined
|
|
67
67
|
hasMore.value = true
|
|
68
68
|
total.value = undefined
|
|
69
69
|
}
|
|
@@ -82,7 +82,7 @@ async function loadMore () {
|
|
|
82
82
|
|
|
83
83
|
internalData.value = [ ...internalData.value, ...result.items ]
|
|
84
84
|
if (result.total != null) total.value = result.total
|
|
85
|
-
|
|
85
|
+
cursor.value = result.next
|
|
86
86
|
hasMore.value = !!result.next
|
|
87
87
|
} catch (error) {
|
|
88
88
|
if (currentVersion !== requestVersion.value) return
|
|
@@ -141,6 +141,7 @@ watch(() => props.filters, (newVal, oldVal) => {
|
|
|
141
141
|
// -- Expose --
|
|
142
142
|
|
|
143
143
|
defineExpose({
|
|
144
|
+
data: internalData,
|
|
144
145
|
refresh,
|
|
145
146
|
loadMore,
|
|
146
147
|
scrollToTop,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DataTableColumn } from '../DataTable/types'
|
|
2
2
|
|
|
3
3
|
export interface InfiniteDataTableFetchParams {
|
|
4
|
-
/** Opaque
|
|
5
|
-
|
|
4
|
+
/** Opaque cursor pointing at the next page; absent on the first page */
|
|
5
|
+
cursor?: string
|
|
6
6
|
/** Page size requested */
|
|
7
7
|
limit: number
|
|
8
8
|
/** Filter / sort fields are spread onto the params object */
|
|
@@ -11,7 +11,7 @@ export interface InfiniteDataTableFetchParams {
|
|
|
11
11
|
|
|
12
12
|
export interface InfiniteDataTableFetchResult<T = Record<string, any>> {
|
|
13
13
|
items: T[]
|
|
14
|
-
/**
|
|
14
|
+
/** Cursor for the next page; pass back as `cursor` on the next request. Absent signals "no more". */
|
|
15
15
|
next?: string
|
|
16
16
|
/** Optional total count */
|
|
17
17
|
total?: number
|
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.2",
|
|
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": "8d49adcf52aef39f5c2d412efb2cd03915d876d0"
|
|
46
46
|
}
|