ai-design-system 0.1.22 → 0.1.24
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/blocks/FormReportsSection/FormReportsSection.tsx +4 -0
- package/components/blocks/SectionLayout/SectionLayout.tsx +2 -2
- package/components/composites/DataTable/EnhancedDataTable.tsx +42 -17
- package/components/composites/DataTable/index.ts +1 -0
- package/components/composites/DataTable/table-types.ts +6 -0
- package/components/composites/DataTable/useEnhancedDataTable.ts +25 -4
- package/components/composites/FormReports/FormReportsTable.tsx +6 -1
- package/components/composites/FormReports/index.ts +1 -0
- package/components/features/FormReportsFeature/FormReportsFeature.tsx +4 -0
- package/components/features/FormReportsFeature/useFormReportsFeature.d.ts +2 -0
- package/components/features/PageLayout/PageLayout.tsx +1 -1
- package/components/features/WorkflowObservabilityFeature/WorkflowObservabilityFeature.tsx +2 -2
- package/dist/index.cjs +66 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +66 -29
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type FormReportsEntity,
|
|
6
6
|
type FormReportsRowAction,
|
|
7
7
|
type FormReportsTableHandlers,
|
|
8
|
+
type DashboardPaginationState,
|
|
8
9
|
} from "@/components/composites/FormReports"
|
|
9
10
|
|
|
10
11
|
export interface FormReportsSectionProps {
|
|
@@ -13,6 +14,7 @@ export interface FormReportsSectionProps {
|
|
|
13
14
|
items: FormReportsEntity[]
|
|
14
15
|
columns: FormReportsColumn[]
|
|
15
16
|
rowActions?: FormReportsRowAction[]
|
|
17
|
+
pagination?: DashboardPaginationState
|
|
16
18
|
tableHandlers?: FormReportsTableHandlers
|
|
17
19
|
tableLeftActions?: React.ReactNode
|
|
18
20
|
}
|
|
@@ -24,6 +26,7 @@ export const FormReportsSection = React.memo<FormReportsSectionProps>(
|
|
|
24
26
|
items,
|
|
25
27
|
columns,
|
|
26
28
|
rowActions,
|
|
29
|
+
pagination,
|
|
27
30
|
tableHandlers,
|
|
28
31
|
tableLeftActions,
|
|
29
32
|
}) => {
|
|
@@ -33,6 +36,7 @@ export const FormReportsSection = React.memo<FormReportsSectionProps>(
|
|
|
33
36
|
items={items}
|
|
34
37
|
columns={columns}
|
|
35
38
|
rowActions={rowActions}
|
|
39
|
+
pagination={pagination}
|
|
36
40
|
handlers={tableHandlers}
|
|
37
41
|
leftActions={tableLeftActions}
|
|
38
42
|
onCreateClick={onCreateClick}
|
|
@@ -26,11 +26,11 @@ export const SectionLayout = React.memo<SectionLayoutProps>(
|
|
|
26
26
|
const transformedSections = sections.map(section => ({
|
|
27
27
|
...section,
|
|
28
28
|
content: (
|
|
29
|
-
<div className="h-full min-h-0 flex flex-col">
|
|
29
|
+
<div className="h-full min-h-0 flex flex-col overflow-hidden">
|
|
30
30
|
{section.header && (
|
|
31
31
|
<AppHeader {...section.header} />
|
|
32
32
|
)}
|
|
33
|
-
<div className="min-h-0 flex-1">
|
|
33
|
+
<div className="min-h-0 flex-1 overflow-auto">
|
|
34
34
|
{section.content}
|
|
35
35
|
</div>
|
|
36
36
|
</div>
|
|
@@ -37,6 +37,7 @@ import { DragHandleCell } from "./DragHandleCell"
|
|
|
37
37
|
import { DraggableRow } from "./DraggableRow"
|
|
38
38
|
import { createTableSelectColumn } from "./TableSelectColumn"
|
|
39
39
|
import type {
|
|
40
|
+
DashboardPaginationState,
|
|
40
41
|
DashboardRow,
|
|
41
42
|
DashboardRowAction,
|
|
42
43
|
DashboardTableActionHandlers,
|
|
@@ -46,6 +47,7 @@ import { useEnhancedDataTable } from "./useEnhancedDataTable"
|
|
|
46
47
|
export interface EnhancedDataTableProps {
|
|
47
48
|
data: DashboardRow[]
|
|
48
49
|
tableSchema: DynamicTableSchema
|
|
50
|
+
pagination?: DashboardPaginationState
|
|
49
51
|
className?: string
|
|
50
52
|
handlers?: DashboardTableActionHandlers
|
|
51
53
|
leftActions?: React.ReactNode
|
|
@@ -86,6 +88,7 @@ function toNumberValue(value: unknown): number {
|
|
|
86
88
|
export function EnhancedDataTable({
|
|
87
89
|
data: initialData,
|
|
88
90
|
tableSchema,
|
|
91
|
+
pagination,
|
|
89
92
|
className,
|
|
90
93
|
handlers,
|
|
91
94
|
leftActions,
|
|
@@ -384,8 +387,30 @@ export function EnhancedDataTable({
|
|
|
384
387
|
data: filteredData,
|
|
385
388
|
columns,
|
|
386
389
|
onReorder: (rows) => handlers?.onRowReorder?.(rows),
|
|
390
|
+
serverPagination: pagination,
|
|
387
391
|
})
|
|
388
392
|
|
|
393
|
+
const totalPages = React.useMemo(() => {
|
|
394
|
+
if (!pagination) {
|
|
395
|
+
return table.getPageCount()
|
|
396
|
+
}
|
|
397
|
+
const safePageSize = Math.max(1, pagination.pageSize)
|
|
398
|
+
return Math.max(1, Math.ceil(Math.max(0, pagination.totalItems) / safePageSize))
|
|
399
|
+
}, [pagination, table])
|
|
400
|
+
|
|
401
|
+
const currentPageIndex = pagination ? pagination.pageIndex : table.getState().pagination.pageIndex
|
|
402
|
+
const currentPageSize = pagination ? pagination.pageSize : table.getState().pagination.pageSize
|
|
403
|
+
const canPreviousPage = currentPageIndex > 0
|
|
404
|
+
const canNextPage = currentPageIndex < totalPages - 1
|
|
405
|
+
|
|
406
|
+
React.useEffect(() => {
|
|
407
|
+
if (!pagination) {
|
|
408
|
+
return
|
|
409
|
+
}
|
|
410
|
+
table.setPageIndex(pagination.pageIndex)
|
|
411
|
+
table.setPageSize(pagination.pageSize)
|
|
412
|
+
}, [pagination, table])
|
|
413
|
+
|
|
389
414
|
React.useEffect(() => {
|
|
390
415
|
if (version > 0) {
|
|
391
416
|
table.resetRowSelection(false)
|
|
@@ -528,16 +553,16 @@ export function EnhancedDataTable({
|
|
|
528
553
|
Rows per page
|
|
529
554
|
</Label>
|
|
530
555
|
<Select
|
|
531
|
-
value={`${
|
|
556
|
+
value={`${currentPageSize}`}
|
|
532
557
|
onValueChange={(value) => {
|
|
533
558
|
const pageSize = Number(value)
|
|
534
559
|
table.setPageSize(pageSize)
|
|
535
560
|
handlers?.onPageSizeChange?.(pageSize)
|
|
536
|
-
emitPaginationChange(
|
|
561
|
+
emitPaginationChange(0, pageSize)
|
|
537
562
|
}}
|
|
538
563
|
>
|
|
539
564
|
<SelectTrigger className="w-20" id="rows-per-page">
|
|
540
|
-
<SelectValue placeholder={
|
|
565
|
+
<SelectValue placeholder={currentPageSize} />
|
|
541
566
|
</SelectTrigger>
|
|
542
567
|
<SelectContent side="top">
|
|
543
568
|
{[10, 20, 30, 40, 50].map((pageSize) => (
|
|
@@ -549,7 +574,7 @@ export function EnhancedDataTable({
|
|
|
549
574
|
</Select>
|
|
550
575
|
</div>
|
|
551
576
|
<div className="flex w-fit items-center justify-center text-sm font-medium">
|
|
552
|
-
Page {
|
|
577
|
+
Page {currentPageIndex + 1} of {totalPages}
|
|
553
578
|
</div>
|
|
554
579
|
<div className="ml-auto flex items-center gap-2 lg:ml-0">
|
|
555
580
|
<Button
|
|
@@ -558,9 +583,9 @@ export function EnhancedDataTable({
|
|
|
558
583
|
onClick={() => {
|
|
559
584
|
table.setPageIndex(0)
|
|
560
585
|
handlers?.onPageChange?.(0)
|
|
561
|
-
emitPaginationChange(0,
|
|
586
|
+
emitPaginationChange(0, currentPageSize)
|
|
562
587
|
}}
|
|
563
|
-
disabled={!
|
|
588
|
+
disabled={!canPreviousPage}
|
|
564
589
|
>
|
|
565
590
|
<span className="sr-only">Go to first page</span>
|
|
566
591
|
<ChevronsLeft className="size-4" />
|
|
@@ -569,12 +594,12 @@ export function EnhancedDataTable({
|
|
|
569
594
|
variant="outline"
|
|
570
595
|
className="size-8 p-0"
|
|
571
596
|
onClick={() => {
|
|
572
|
-
|
|
573
|
-
|
|
597
|
+
const nextIndex = Math.max(0, currentPageIndex - 1)
|
|
598
|
+
table.setPageIndex(nextIndex)
|
|
574
599
|
handlers?.onPageChange?.(nextIndex)
|
|
575
|
-
emitPaginationChange(nextIndex,
|
|
600
|
+
emitPaginationChange(nextIndex, currentPageSize)
|
|
576
601
|
}}
|
|
577
|
-
disabled={!
|
|
602
|
+
disabled={!canPreviousPage}
|
|
578
603
|
>
|
|
579
604
|
<span className="sr-only">Go to previous page</span>
|
|
580
605
|
<ChevronLeft className="size-4" />
|
|
@@ -583,12 +608,12 @@ export function EnhancedDataTable({
|
|
|
583
608
|
variant="outline"
|
|
584
609
|
className="size-8 p-0"
|
|
585
610
|
onClick={() => {
|
|
586
|
-
|
|
587
|
-
|
|
611
|
+
const nextIndex = Math.min(totalPages - 1, currentPageIndex + 1)
|
|
612
|
+
table.setPageIndex(nextIndex)
|
|
588
613
|
handlers?.onPageChange?.(nextIndex)
|
|
589
|
-
emitPaginationChange(nextIndex,
|
|
614
|
+
emitPaginationChange(nextIndex, currentPageSize)
|
|
590
615
|
}}
|
|
591
|
-
disabled={!
|
|
616
|
+
disabled={!canNextPage}
|
|
592
617
|
>
|
|
593
618
|
<span className="sr-only">Go to next page</span>
|
|
594
619
|
<ChevronRight className="size-4" />
|
|
@@ -597,12 +622,12 @@ export function EnhancedDataTable({
|
|
|
597
622
|
variant="outline"
|
|
598
623
|
className="hidden size-8 p-0 lg:flex"
|
|
599
624
|
onClick={() => {
|
|
600
|
-
const lastPage = Math.max(0,
|
|
625
|
+
const lastPage = Math.max(0, totalPages - 1)
|
|
601
626
|
table.setPageIndex(lastPage)
|
|
602
627
|
handlers?.onPageChange?.(lastPage)
|
|
603
|
-
emitPaginationChange(lastPage,
|
|
628
|
+
emitPaginationChange(lastPage, currentPageSize)
|
|
604
629
|
}}
|
|
605
|
-
disabled={!
|
|
630
|
+
disabled={!canNextPage}
|
|
606
631
|
>
|
|
607
632
|
<span className="sr-only">Go to last page</span>
|
|
608
633
|
<ChevronsRight className="size-4" />
|
|
@@ -20,6 +20,7 @@ export type { UseEnhancedDataTableOptions } from './useEnhancedDataTable'
|
|
|
20
20
|
export { dashboardRowSchema } from './table-types'
|
|
21
21
|
export type {
|
|
22
22
|
DashboardInlineEditableField,
|
|
23
|
+
DashboardPaginationState,
|
|
23
24
|
DashboardRow,
|
|
24
25
|
DashboardRowAction,
|
|
25
26
|
DashboardTableActionHandlers,
|
|
@@ -10,6 +10,12 @@ export type DashboardInlineEditableField = "target" | "limit"
|
|
|
10
10
|
|
|
11
11
|
export type DashboardRowAction = "edit" | "copy" | "favorite" | "delete"
|
|
12
12
|
|
|
13
|
+
export interface DashboardPaginationState {
|
|
14
|
+
pageIndex: number
|
|
15
|
+
pageSize: number
|
|
16
|
+
totalItems: number
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
export interface DashboardTableActionHandlers {
|
|
14
20
|
onCreateClick?: () => void
|
|
15
21
|
onAddSection?: () => void
|
|
@@ -16,27 +16,44 @@ import { arrayMove, type UniqueIdentifier } from "@dnd-kit/sortable"
|
|
|
16
16
|
|
|
17
17
|
import type { DashboardRow } from "./table-types"
|
|
18
18
|
|
|
19
|
+
export interface ServerPaginationOptions {
|
|
20
|
+
pageIndex: number
|
|
21
|
+
pageSize: number
|
|
22
|
+
totalItems: number
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
export interface UseEnhancedDataTableOptions {
|
|
20
26
|
data: DashboardRow[]
|
|
21
27
|
columns: ColumnDef<DashboardRow>[]
|
|
22
28
|
onReorder?: (rows: DashboardRow[]) => void
|
|
29
|
+
serverPagination?: ServerPaginationOptions
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
export function useEnhancedDataTable({ data: initialData, columns, onReorder }: UseEnhancedDataTableOptions) {
|
|
32
|
+
export function useEnhancedDataTable({ data: initialData, columns, onReorder, serverPagination }: UseEnhancedDataTableOptions) {
|
|
26
33
|
const [data, setData] = React.useState<DashboardRow[]>(() => initialData)
|
|
27
34
|
const [rowSelection, setRowSelection] = React.useState({})
|
|
28
35
|
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({})
|
|
29
36
|
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>([])
|
|
30
37
|
const [sorting, setSorting] = React.useState<SortingState>([])
|
|
31
38
|
const [pagination, setPagination] = React.useState({
|
|
32
|
-
pageIndex: 0,
|
|
33
|
-
pageSize: 10,
|
|
39
|
+
pageIndex: serverPagination?.pageIndex ?? 0,
|
|
40
|
+
pageSize: serverPagination?.pageSize ?? 10,
|
|
34
41
|
})
|
|
35
42
|
|
|
36
43
|
React.useEffect(() => {
|
|
37
44
|
setData(initialData)
|
|
38
45
|
}, [initialData])
|
|
39
46
|
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (!serverPagination) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
setPagination({
|
|
52
|
+
pageIndex: serverPagination.pageIndex,
|
|
53
|
+
pageSize: serverPagination.pageSize,
|
|
54
|
+
})
|
|
55
|
+
}, [serverPagination])
|
|
56
|
+
|
|
40
57
|
const dataIds = React.useMemo<UniqueIdentifier[]>(() => data.map((item) => item.id), [data])
|
|
41
58
|
|
|
42
59
|
const table = useReactTable({
|
|
@@ -56,9 +73,13 @@ export function useEnhancedDataTable({ data: initialData, columns, onReorder }:
|
|
|
56
73
|
onColumnFiltersChange: setColumnFilters,
|
|
57
74
|
onColumnVisibilityChange: setColumnVisibility,
|
|
58
75
|
onPaginationChange: setPagination,
|
|
76
|
+
manualPagination: Boolean(serverPagination),
|
|
77
|
+
pageCount: serverPagination
|
|
78
|
+
? Math.max(1, Math.ceil(serverPagination.totalItems / Math.max(1, serverPagination.pageSize)))
|
|
79
|
+
: undefined,
|
|
59
80
|
getCoreRowModel: getCoreRowModel(),
|
|
60
81
|
getFilteredRowModel: getFilteredRowModel(),
|
|
61
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
82
|
+
getPaginationRowModel: serverPagination ? undefined : getPaginationRowModel(),
|
|
62
83
|
getSortedRowModel: getSortedRowModel(),
|
|
63
84
|
getFacetedRowModel: getFacetedRowModel(),
|
|
64
85
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import {
|
|
3
3
|
EnhancedDataTable,
|
|
4
|
+
type DashboardPaginationState,
|
|
4
5
|
type DashboardRow,
|
|
5
6
|
type DashboardRowAction,
|
|
6
7
|
type DashboardTableActionHandlers,
|
|
@@ -43,6 +44,7 @@ export interface FormReportsTableProps {
|
|
|
43
44
|
items: FormReportsEntity[]
|
|
44
45
|
columns: FormReportsColumn[]
|
|
45
46
|
rowActions?: FormReportsRowAction[]
|
|
47
|
+
pagination?: DashboardPaginationState
|
|
46
48
|
handlers?: FormReportsTableHandlers
|
|
47
49
|
leftActions?: React.ReactNode
|
|
48
50
|
rightActions?: React.ReactNode
|
|
@@ -57,8 +59,10 @@ const dashboardToFormReportsActionMap: Record<DashboardRowAction, string> = {
|
|
|
57
59
|
delete: "delete",
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
export type { DashboardPaginationState }
|
|
63
|
+
|
|
60
64
|
export const FormReportsTable = React.memo<FormReportsTableProps>(
|
|
61
|
-
({ items, columns, handlers, leftActions, rightActions, onCreateClick, createButtonLabel }) => {
|
|
65
|
+
({ items, columns, pagination, handlers, leftActions, rightActions, onCreateClick, createButtonLabel }) => {
|
|
62
66
|
const { rows, originalById, tableSchema } = React.useMemo(() => {
|
|
63
67
|
const byId = new Map<string, FormReportsEntity>()
|
|
64
68
|
const tableColumns: DynamicTableSchema["columns"] = columns
|
|
@@ -168,6 +172,7 @@ export const FormReportsTable = React.memo<FormReportsTableProps>(
|
|
|
168
172
|
<EnhancedDataTable
|
|
169
173
|
data={rows}
|
|
170
174
|
tableSchema={tableSchema}
|
|
175
|
+
pagination={pagination}
|
|
171
176
|
handlers={adaptedHandlers}
|
|
172
177
|
leftActions={leftActions}
|
|
173
178
|
rightActions={rightActions}
|
|
@@ -2,6 +2,7 @@ import * as React from "react"
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
FormReportsDrawerForm,
|
|
5
|
+
type DashboardPaginationState,
|
|
5
6
|
type FormReportsColumn,
|
|
6
7
|
type FormReportsEntity,
|
|
7
8
|
type FormReportsFieldDefinition,
|
|
@@ -18,6 +19,7 @@ export interface FormReportsFeatureProps {
|
|
|
18
19
|
fields: FormReportsFieldDefinition[]
|
|
19
20
|
columns: FormReportsColumn[]
|
|
20
21
|
items: FormReportsEntity[]
|
|
22
|
+
pagination?: DashboardPaginationState
|
|
21
23
|
rowActions?: FormReportsRowAction[]
|
|
22
24
|
actionHandlers?: FormReportsFeatureActionHandlers
|
|
23
25
|
createButtonLabel?: string
|
|
@@ -39,6 +41,7 @@ export const FormReportsFeature = React.memo<FormReportsFeatureProps>(
|
|
|
39
41
|
fields,
|
|
40
42
|
columns,
|
|
41
43
|
items,
|
|
44
|
+
pagination,
|
|
42
45
|
rowActions,
|
|
43
46
|
actionHandlers,
|
|
44
47
|
createButtonLabel = "Create",
|
|
@@ -105,6 +108,7 @@ export const FormReportsFeature = React.memo<FormReportsFeatureProps>(
|
|
|
105
108
|
createButtonLabel={createButtonLabel}
|
|
106
109
|
items={items}
|
|
107
110
|
columns={columns}
|
|
111
|
+
pagination={pagination}
|
|
108
112
|
rowActions={rowActions}
|
|
109
113
|
tableHandlers={actionHandlers?.table}
|
|
110
114
|
/>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
DashboardPaginationState,
|
|
2
3
|
FormReportsColumn,
|
|
3
4
|
FormReportsEntity,
|
|
4
5
|
FormReportsFieldDefinition,
|
|
@@ -24,6 +25,7 @@ export interface UseFormReportsFeatureReturn {
|
|
|
24
25
|
columns: FormReportsColumn[]
|
|
25
26
|
rowActions?: FormReportsRowAction[]
|
|
26
27
|
items: FormReportsEntity[]
|
|
28
|
+
pagination?: DashboardPaginationState
|
|
27
29
|
actionHandlers?: FormReportsFeatureActionHandlers
|
|
28
30
|
createButtonLabel?: string
|
|
29
31
|
}
|
|
@@ -136,7 +136,7 @@ export const PageLayout = React.memo<PageLayoutProps>(
|
|
|
136
136
|
<AppSidebar {...sidebar} />
|
|
137
137
|
<PageContainer className={`overflow-hidden ${className ?? ""}`}>
|
|
138
138
|
<AppHeader {...header} />
|
|
139
|
-
<div className=
|
|
139
|
+
<div className={`min-h-0 flex-1 overflow-x-hidden ${layoutSections ? "overflow-hidden" : "overflow-y-auto"}`}>
|
|
140
140
|
{contentArea}
|
|
141
141
|
</div>
|
|
142
142
|
</PageContainer>
|
|
@@ -65,7 +65,7 @@ function buildObservabilitySections({
|
|
|
65
65
|
return [
|
|
66
66
|
{
|
|
67
67
|
...traceSection,
|
|
68
|
-
defaultSize:
|
|
68
|
+
defaultSize: 66.67,
|
|
69
69
|
minSize: 55,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
@@ -80,7 +80,7 @@ function buildObservabilitySections({
|
|
|
80
80
|
spans={spans}
|
|
81
81
|
/>
|
|
82
82
|
),
|
|
83
|
-
defaultSize:
|
|
83
|
+
defaultSize: 33.33,
|
|
84
84
|
minSize: 25,
|
|
85
85
|
},
|
|
86
86
|
]
|
package/dist/index.cjs
CHANGED
|
@@ -6985,19 +6985,29 @@ function createTableSelectColumn() {
|
|
|
6985
6985
|
enableHiding: false
|
|
6986
6986
|
};
|
|
6987
6987
|
}
|
|
6988
|
-
function useEnhancedDataTable({ data: initialData, columns, onReorder }) {
|
|
6988
|
+
function useEnhancedDataTable({ data: initialData, columns, onReorder, serverPagination }) {
|
|
6989
|
+
var _a, _b;
|
|
6989
6990
|
const [data, setData] = React33__namespace.useState(() => initialData);
|
|
6990
6991
|
const [rowSelection, setRowSelection] = React33__namespace.useState({});
|
|
6991
6992
|
const [columnVisibility, setColumnVisibility] = React33__namespace.useState({});
|
|
6992
6993
|
const [columnFilters, setColumnFilters] = React33__namespace.useState([]);
|
|
6993
6994
|
const [sorting, setSorting] = React33__namespace.useState([]);
|
|
6994
6995
|
const [pagination, setPagination] = React33__namespace.useState({
|
|
6995
|
-
pageIndex: 0,
|
|
6996
|
-
pageSize: 10
|
|
6996
|
+
pageIndex: (_a = serverPagination == null ? void 0 : serverPagination.pageIndex) != null ? _a : 0,
|
|
6997
|
+
pageSize: (_b = serverPagination == null ? void 0 : serverPagination.pageSize) != null ? _b : 10
|
|
6997
6998
|
});
|
|
6998
6999
|
React33__namespace.useEffect(() => {
|
|
6999
7000
|
setData(initialData);
|
|
7000
7001
|
}, [initialData]);
|
|
7002
|
+
React33__namespace.useEffect(() => {
|
|
7003
|
+
if (!serverPagination) {
|
|
7004
|
+
return;
|
|
7005
|
+
}
|
|
7006
|
+
setPagination({
|
|
7007
|
+
pageIndex: serverPagination.pageIndex,
|
|
7008
|
+
pageSize: serverPagination.pageSize
|
|
7009
|
+
});
|
|
7010
|
+
}, [serverPagination]);
|
|
7001
7011
|
const dataIds = React33__namespace.useMemo(() => data.map((item) => item.id), [data]);
|
|
7002
7012
|
const table = reactTable.useReactTable({
|
|
7003
7013
|
data,
|
|
@@ -7016,9 +7026,11 @@ function useEnhancedDataTable({ data: initialData, columns, onReorder }) {
|
|
|
7016
7026
|
onColumnFiltersChange: setColumnFilters,
|
|
7017
7027
|
onColumnVisibilityChange: setColumnVisibility,
|
|
7018
7028
|
onPaginationChange: setPagination,
|
|
7029
|
+
manualPagination: Boolean(serverPagination),
|
|
7030
|
+
pageCount: serverPagination ? Math.max(1, Math.ceil(serverPagination.totalItems / Math.max(1, serverPagination.pageSize))) : void 0,
|
|
7019
7031
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
7020
7032
|
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
7021
|
-
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
7033
|
+
getPaginationRowModel: serverPagination ? void 0 : reactTable.getPaginationRowModel(),
|
|
7022
7034
|
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
7023
7035
|
getFacetedRowModel: reactTable.getFacetedRowModel(),
|
|
7024
7036
|
getFacetedUniqueValues: reactTable.getFacetedUniqueValues()
|
|
@@ -7082,6 +7094,7 @@ function toNumberValue(value) {
|
|
|
7082
7094
|
function EnhancedDataTable({
|
|
7083
7095
|
data: initialData,
|
|
7084
7096
|
tableSchema,
|
|
7097
|
+
pagination,
|
|
7085
7098
|
className,
|
|
7086
7099
|
handlers,
|
|
7087
7100
|
leftActions,
|
|
@@ -7346,8 +7359,27 @@ function EnhancedDataTable({
|
|
|
7346
7359
|
onReorder: (rows) => {
|
|
7347
7360
|
var _a2;
|
|
7348
7361
|
return (_a2 = handlers == null ? void 0 : handlers.onRowReorder) == null ? void 0 : _a2.call(handlers, rows);
|
|
7349
|
-
}
|
|
7362
|
+
},
|
|
7363
|
+
serverPagination: pagination
|
|
7350
7364
|
});
|
|
7365
|
+
const totalPages = React33__namespace.useMemo(() => {
|
|
7366
|
+
if (!pagination) {
|
|
7367
|
+
return table.getPageCount();
|
|
7368
|
+
}
|
|
7369
|
+
const safePageSize = Math.max(1, pagination.pageSize);
|
|
7370
|
+
return Math.max(1, Math.ceil(Math.max(0, pagination.totalItems) / safePageSize));
|
|
7371
|
+
}, [pagination, table]);
|
|
7372
|
+
const currentPageIndex = pagination ? pagination.pageIndex : table.getState().pagination.pageIndex;
|
|
7373
|
+
const currentPageSize = pagination ? pagination.pageSize : table.getState().pagination.pageSize;
|
|
7374
|
+
const canPreviousPage = currentPageIndex > 0;
|
|
7375
|
+
const canNextPage = currentPageIndex < totalPages - 1;
|
|
7376
|
+
React33__namespace.useEffect(() => {
|
|
7377
|
+
if (!pagination) {
|
|
7378
|
+
return;
|
|
7379
|
+
}
|
|
7380
|
+
table.setPageIndex(pagination.pageIndex);
|
|
7381
|
+
table.setPageSize(pagination.pageSize);
|
|
7382
|
+
}, [pagination, table]);
|
|
7351
7383
|
React33__namespace.useEffect(() => {
|
|
7352
7384
|
if (version > 0) {
|
|
7353
7385
|
table.resetRowSelection(false);
|
|
@@ -7455,16 +7487,16 @@ function EnhancedDataTable({
|
|
|
7455
7487
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7456
7488
|
Select2,
|
|
7457
7489
|
{
|
|
7458
|
-
value: `${
|
|
7490
|
+
value: `${currentPageSize}`,
|
|
7459
7491
|
onValueChange: (value) => {
|
|
7460
7492
|
var _a2;
|
|
7461
7493
|
const pageSize = Number(value);
|
|
7462
7494
|
table.setPageSize(pageSize);
|
|
7463
7495
|
(_a2 = handlers == null ? void 0 : handlers.onPageSizeChange) == null ? void 0 : _a2.call(handlers, pageSize);
|
|
7464
|
-
emitPaginationChange(
|
|
7496
|
+
emitPaginationChange(0, pageSize);
|
|
7465
7497
|
},
|
|
7466
7498
|
children: [
|
|
7467
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-20", id: "rows-per-page", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder:
|
|
7499
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-20", id: "rows-per-page", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: currentPageSize }) }),
|
|
7468
7500
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent2, { side: "top", children: [10, 20, 30, 40, 50].map((pageSize) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: `${pageSize}`, children: pageSize }, pageSize)) })
|
|
7469
7501
|
]
|
|
7470
7502
|
}
|
|
@@ -7472,9 +7504,9 @@ function EnhancedDataTable({
|
|
|
7472
7504
|
] }),
|
|
7473
7505
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-fit items-center justify-center text-sm font-medium", children: [
|
|
7474
7506
|
"Page ",
|
|
7475
|
-
|
|
7507
|
+
currentPageIndex + 1,
|
|
7476
7508
|
" of ",
|
|
7477
|
-
|
|
7509
|
+
totalPages
|
|
7478
7510
|
] }),
|
|
7479
7511
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-2 lg:ml-0", children: [
|
|
7480
7512
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -7486,9 +7518,9 @@ function EnhancedDataTable({
|
|
|
7486
7518
|
var _a2;
|
|
7487
7519
|
table.setPageIndex(0);
|
|
7488
7520
|
(_a2 = handlers == null ? void 0 : handlers.onPageChange) == null ? void 0 : _a2.call(handlers, 0);
|
|
7489
|
-
emitPaginationChange(0,
|
|
7521
|
+
emitPaginationChange(0, currentPageSize);
|
|
7490
7522
|
},
|
|
7491
|
-
disabled: !
|
|
7523
|
+
disabled: !canPreviousPage,
|
|
7492
7524
|
children: [
|
|
7493
7525
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Go to first page" }),
|
|
7494
7526
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "size-4" })
|
|
@@ -7502,12 +7534,12 @@ function EnhancedDataTable({
|
|
|
7502
7534
|
className: "size-8 p-0",
|
|
7503
7535
|
onClick: () => {
|
|
7504
7536
|
var _a2;
|
|
7505
|
-
|
|
7506
|
-
|
|
7537
|
+
const nextIndex = Math.max(0, currentPageIndex - 1);
|
|
7538
|
+
table.setPageIndex(nextIndex);
|
|
7507
7539
|
(_a2 = handlers == null ? void 0 : handlers.onPageChange) == null ? void 0 : _a2.call(handlers, nextIndex);
|
|
7508
|
-
emitPaginationChange(nextIndex,
|
|
7540
|
+
emitPaginationChange(nextIndex, currentPageSize);
|
|
7509
7541
|
},
|
|
7510
|
-
disabled: !
|
|
7542
|
+
disabled: !canPreviousPage,
|
|
7511
7543
|
children: [
|
|
7512
7544
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Go to previous page" }),
|
|
7513
7545
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "size-4" })
|
|
@@ -7521,12 +7553,12 @@ function EnhancedDataTable({
|
|
|
7521
7553
|
className: "size-8 p-0",
|
|
7522
7554
|
onClick: () => {
|
|
7523
7555
|
var _a2;
|
|
7524
|
-
|
|
7525
|
-
|
|
7556
|
+
const nextIndex = Math.min(totalPages - 1, currentPageIndex + 1);
|
|
7557
|
+
table.setPageIndex(nextIndex);
|
|
7526
7558
|
(_a2 = handlers == null ? void 0 : handlers.onPageChange) == null ? void 0 : _a2.call(handlers, nextIndex);
|
|
7527
|
-
emitPaginationChange(nextIndex,
|
|
7559
|
+
emitPaginationChange(nextIndex, currentPageSize);
|
|
7528
7560
|
},
|
|
7529
|
-
disabled: !
|
|
7561
|
+
disabled: !canNextPage,
|
|
7530
7562
|
children: [
|
|
7531
7563
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Go to next page" }),
|
|
7532
7564
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "size-4" })
|
|
@@ -7540,12 +7572,12 @@ function EnhancedDataTable({
|
|
|
7540
7572
|
className: "hidden size-8 p-0 lg:flex",
|
|
7541
7573
|
onClick: () => {
|
|
7542
7574
|
var _a2;
|
|
7543
|
-
const lastPage = Math.max(0,
|
|
7575
|
+
const lastPage = Math.max(0, totalPages - 1);
|
|
7544
7576
|
table.setPageIndex(lastPage);
|
|
7545
7577
|
(_a2 = handlers == null ? void 0 : handlers.onPageChange) == null ? void 0 : _a2.call(handlers, lastPage);
|
|
7546
|
-
emitPaginationChange(lastPage,
|
|
7578
|
+
emitPaginationChange(lastPage, currentPageSize);
|
|
7547
7579
|
},
|
|
7548
|
-
disabled: !
|
|
7580
|
+
disabled: !canNextPage,
|
|
7549
7581
|
children: [
|
|
7550
7582
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Go to last page" }),
|
|
7551
7583
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "size-4" })
|
|
@@ -7703,7 +7735,7 @@ var dashboardToFormReportsActionMap = {
|
|
|
7703
7735
|
delete: "delete"
|
|
7704
7736
|
};
|
|
7705
7737
|
var FormReportsTable = React33__namespace.memo(
|
|
7706
|
-
({ items, columns, handlers, leftActions, rightActions, onCreateClick, createButtonLabel }) => {
|
|
7738
|
+
({ items, columns, pagination, handlers, leftActions, rightActions, onCreateClick, createButtonLabel }) => {
|
|
7707
7739
|
const { rows, originalById, tableSchema } = React33__namespace.useMemo(() => {
|
|
7708
7740
|
const byId = /* @__PURE__ */ new Map();
|
|
7709
7741
|
const tableColumns = columns;
|
|
@@ -7834,6 +7866,7 @@ var FormReportsTable = React33__namespace.memo(
|
|
|
7834
7866
|
{
|
|
7835
7867
|
data: rows,
|
|
7836
7868
|
tableSchema,
|
|
7869
|
+
pagination,
|
|
7837
7870
|
handlers: adaptedHandlers,
|
|
7838
7871
|
leftActions,
|
|
7839
7872
|
rightActions,
|
|
@@ -9101,9 +9134,9 @@ var SectionLayout = React33__namespace.memo(
|
|
|
9101
9134
|
"className"
|
|
9102
9135
|
]);
|
|
9103
9136
|
const transformedSections = sections.map((section) => __spreadProps(__spreadValues({}, section), {
|
|
9104
|
-
content: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full min-h-0 flex flex-col", children: [
|
|
9137
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full min-h-0 flex flex-col overflow-hidden", children: [
|
|
9105
9138
|
section.header && /* @__PURE__ */ jsxRuntime.jsx(AppHeader, __spreadValues({}, section.header)),
|
|
9106
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: section.content })
|
|
9139
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: section.content })
|
|
9107
9140
|
] })
|
|
9108
9141
|
}));
|
|
9109
9142
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -9616,6 +9649,7 @@ var FormReportsSection = React33__namespace.memo(
|
|
|
9616
9649
|
items,
|
|
9617
9650
|
columns,
|
|
9618
9651
|
rowActions,
|
|
9652
|
+
pagination,
|
|
9619
9653
|
tableHandlers,
|
|
9620
9654
|
tableLeftActions
|
|
9621
9655
|
}) => {
|
|
@@ -9625,6 +9659,7 @@ var FormReportsSection = React33__namespace.memo(
|
|
|
9625
9659
|
items,
|
|
9626
9660
|
columns,
|
|
9627
9661
|
rowActions,
|
|
9662
|
+
pagination,
|
|
9628
9663
|
handlers: tableHandlers,
|
|
9629
9664
|
leftActions: tableLeftActions,
|
|
9630
9665
|
onCreateClick,
|
|
@@ -9668,7 +9703,7 @@ var PageLayout = React33__namespace.memo(
|
|
|
9668
9703
|
/* @__PURE__ */ jsxRuntime.jsx(AppSidebar, __spreadValues({}, sidebar)),
|
|
9669
9704
|
/* @__PURE__ */ jsxRuntime.jsxs(PageContainer, { className: `overflow-hidden ${className != null ? className : ""}`, children: [
|
|
9670
9705
|
/* @__PURE__ */ jsxRuntime.jsx(AppHeader, __spreadValues({}, header)),
|
|
9671
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
9706
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `min-h-0 flex-1 overflow-x-hidden ${layoutSections ? "overflow-hidden" : "overflow-y-auto"}`, children: contentArea })
|
|
9672
9707
|
] })
|
|
9673
9708
|
]
|
|
9674
9709
|
}
|
|
@@ -10201,6 +10236,7 @@ var FormReportsFeature = React33__namespace.memo(
|
|
|
10201
10236
|
fields,
|
|
10202
10237
|
columns,
|
|
10203
10238
|
items,
|
|
10239
|
+
pagination,
|
|
10204
10240
|
rowActions,
|
|
10205
10241
|
actionHandlers,
|
|
10206
10242
|
createButtonLabel = "Create",
|
|
@@ -10266,6 +10302,7 @@ var FormReportsFeature = React33__namespace.memo(
|
|
|
10266
10302
|
createButtonLabel,
|
|
10267
10303
|
items,
|
|
10268
10304
|
columns,
|
|
10305
|
+
pagination,
|
|
10269
10306
|
rowActions,
|
|
10270
10307
|
tableHandlers: actionHandlers == null ? void 0 : actionHandlers.table
|
|
10271
10308
|
}
|
|
@@ -10471,7 +10508,7 @@ function buildObservabilitySections({
|
|
|
10471
10508
|
}
|
|
10472
10509
|
return [
|
|
10473
10510
|
__spreadProps(__spreadValues({}, traceSection), {
|
|
10474
|
-
defaultSize:
|
|
10511
|
+
defaultSize: 66.67,
|
|
10475
10512
|
minSize: 55
|
|
10476
10513
|
}),
|
|
10477
10514
|
{
|
|
@@ -10487,7 +10524,7 @@ function buildObservabilitySections({
|
|
|
10487
10524
|
spans
|
|
10488
10525
|
}
|
|
10489
10526
|
),
|
|
10490
|
-
defaultSize:
|
|
10527
|
+
defaultSize: 33.33,
|
|
10491
10528
|
minSize: 25
|
|
10492
10529
|
}
|
|
10493
10530
|
];
|