@izumisy-tailor/tailor-data-viewer 0.1.12 → 0.1.14

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@izumisy-tailor/tailor-data-viewer",
3
3
  "private": false,
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
5
5
  "type": "module",
6
6
  "description": "Flexible data viewer component for Tailor Platform",
7
7
  "files": [
@@ -24,6 +24,7 @@ export interface PaginationState {
24
24
  first: number;
25
25
  after: string | null;
26
26
  hasNextPage: boolean;
27
+ endCursor: string | null;
27
28
  }
28
29
 
29
30
  export interface TableDataState {
@@ -102,6 +103,7 @@ export function useTableData(
102
103
  first: DEFAULT_PAGE_SIZE,
103
104
  after: null,
104
105
  hasNextPage: false,
106
+ endCursor: null,
105
107
  });
106
108
  const [cursorHistory, setCursorHistory] = useState<string[]>([]);
107
109
 
@@ -116,6 +118,7 @@ export function useTableData(
116
118
  first: DEFAULT_PAGE_SIZE,
117
119
  after: null,
118
120
  hasNextPage: false,
121
+ endCursor: null,
119
122
  });
120
123
  setCursorHistory([]);
121
124
  }, [table?.name]);
@@ -237,6 +240,7 @@ export function useTableData(
237
240
  setPagination((prev) => ({
238
241
  ...prev,
239
242
  hasNextPage: responseData.pageInfo.hasNextPage,
243
+ endCursor: responseData.pageInfo.endCursor,
240
244
  }));
241
245
  }
242
246
  } catch (err) {
@@ -280,19 +284,18 @@ export function useTableData(
280
284
  }, []);
281
285
 
282
286
  const nextPage = useCallback(() => {
283
- const responseData = data;
284
- if (pagination.hasNextPage && responseData.length > 0) {
287
+ if (pagination.hasNextPage && pagination.endCursor) {
285
288
  // Store current cursor for back navigation
286
289
  if (pagination.after) {
287
290
  setCursorHistory((prev) => [...prev, pagination.after!]);
288
291
  }
289
- // Get the cursor from the last item (using the GraphQL response's endCursor)
292
+ // Use endCursor from pageInfo for pagination
290
293
  setPagination((prev) => ({
291
294
  ...prev,
292
- after: (responseData[responseData.length - 1]?.id as string) ?? null,
295
+ after: prev.endCursor,
293
296
  }));
294
297
  }
295
- }, [data, pagination.hasNextPage, pagination.after]);
298
+ }, [pagination.hasNextPage, pagination.endCursor, pagination.after]);
296
299
 
297
300
  const previousPage = useCallback(() => {
298
301
  if (cursorHistory.length > 0) {
@@ -311,6 +314,7 @@ export function useTableData(
311
314
  first: DEFAULT_PAGE_SIZE,
312
315
  after: null,
313
316
  hasNextPage: false,
317
+ endCursor: null,
314
318
  });
315
319
  setCursorHistory([]);
316
320
  }, []);
@@ -202,7 +202,7 @@ export function SearchFilterForm({
202
202
  </Button>
203
203
  </CollapsibleTrigger>
204
204
 
205
- <CollapsibleContent className="absolute top-full left-0 z-10 mt-2">
205
+ <CollapsibleContent className="absolute top-full left-0 z-50 mt-2">
206
206
  <div className="bg-background w-96 rounded-md border p-4 shadow-md">
207
207
  <div className="space-y-4">
208
208
  <div className="flex items-center justify-between">