@tsed/react-formio 2.1.4 → 2.2.1
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/dist/components/pagination/pagination.component.d.ts +2 -1
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +7 -2
- package/dist/components/table/index.d.ts +3 -0
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +14 -4
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
- package/src/components/pagination/pagination.component.spec.tsx +8 -0
- package/src/components/pagination/pagination.component.tsx +14 -2
- package/src/components/table/hooks/useCustomTable.hook.tsx +7 -12
- package/src/components/table/index.ts +3 -0
- package/src/components/table/table.component.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/react-formio",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Provide a react formio wrapper. Written in TypeScript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.modern.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"tooltip.js": ">=1.3.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tsed/tailwind": "2.1
|
|
35
|
-
"@tsed/tailwind-formio": "2.1
|
|
34
|
+
"@tsed/tailwind": "2.2.1",
|
|
35
|
+
"@tsed/tailwind-formio": "2.2.1"
|
|
36
36
|
},
|
|
37
37
|
"repository": "https://github.com/TypedProject/tsed-formio",
|
|
38
38
|
"bugs": {
|
|
@@ -111,4 +111,12 @@ describe("Pagination", () => {
|
|
|
111
111
|
expect(selectComp).toBeInTheDocument();
|
|
112
112
|
expect(selectChilds.length === pageSizes.length).toBeTruthy();
|
|
113
113
|
});
|
|
114
|
+
|
|
115
|
+
it("should display total length", () => {
|
|
116
|
+
const pageSizes = [10, 25, 50, 100, 200, 500];
|
|
117
|
+
|
|
118
|
+
render(<Sandbox {...Sandbox.args} pageSizes={pageSizes} totalLength={1000} />);
|
|
119
|
+
|
|
120
|
+
expect(screen.getByTestId("pagination-total-items")).toHaveTextContent("1,000 items");
|
|
121
|
+
});
|
|
114
122
|
});
|
|
@@ -38,9 +38,10 @@ export interface PaginationProps {
|
|
|
38
38
|
canNextPage: boolean;
|
|
39
39
|
pageCount: number;
|
|
40
40
|
pageIndex: number;
|
|
41
|
-
pageOptions?:
|
|
41
|
+
pageOptions?: number[];
|
|
42
42
|
pageSize: number;
|
|
43
43
|
setPageSize: any;
|
|
44
|
+
totalLength?: number;
|
|
44
45
|
i18n?: (f: string) => string;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -58,6 +59,7 @@ export function Pagination(props: PaginationProps) {
|
|
|
58
59
|
pageOptions,
|
|
59
60
|
pageSize,
|
|
60
61
|
setPageSize,
|
|
62
|
+
totalLength,
|
|
61
63
|
i18n = (f: string) => f
|
|
62
64
|
} = props;
|
|
63
65
|
|
|
@@ -115,11 +117,21 @@ export function Pagination(props: PaginationProps) {
|
|
|
115
117
|
<span className={"ml-3"}>{i18n("items per page")}</span>
|
|
116
118
|
</li>
|
|
117
119
|
{pageOptions && (
|
|
118
|
-
<li className={"mb-3 flex items-center"}>
|
|
120
|
+
<li className={"mb-3 mr-3 flex items-center"}>
|
|
119
121
|
<span>{i18n("Page")} </span>
|
|
120
122
|
<strong>
|
|
121
123
|
{pageIndex + 1} of {pageOptions.length}
|
|
122
124
|
</strong>
|
|
125
|
+
{totalLength !== undefined && (
|
|
126
|
+
<span className='ml-3'>
|
|
127
|
+
{i18n("Totals")}: <strong>{new Intl.NumberFormat(undefined).format(totalLength)}</strong> {i18n("items")}
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
130
|
+
</li>
|
|
131
|
+
)}
|
|
132
|
+
{totalLength !== undefined && (
|
|
133
|
+
<li className={"mb-3 flex items-center"} data-testid='pagination-total-items'>
|
|
134
|
+
{i18n("Totals")}: <strong>{new Intl.NumberFormat(undefined).format(totalLength)}</strong> {i18n("items")}
|
|
123
135
|
</li>
|
|
124
136
|
)}
|
|
125
137
|
</nav>
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import noop from "lodash/noop";
|
|
2
2
|
import React, { PropsWithChildren, useEffect, useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
CellProps,
|
|
5
|
-
FilterProps,
|
|
6
|
-
Renderer,
|
|
7
|
-
TableInstance,
|
|
8
|
-
TableOptions,
|
|
9
|
-
useFilters,
|
|
10
|
-
useGroupBy,
|
|
11
|
-
usePagination,
|
|
12
|
-
useSortBy,
|
|
13
|
-
useTable
|
|
14
|
-
} from "react-table";
|
|
3
|
+
import { CellProps, FilterProps, Renderer, TableOptions, useFilters, useGroupBy, usePagination, useSortBy, useTable } from "react-table";
|
|
15
4
|
|
|
16
5
|
import { OnClickOperation, Operation, QueryOptions } from "../../../interfaces";
|
|
17
6
|
import { Pagination as DefaultPagination } from "../../pagination/pagination.component";
|
|
@@ -36,6 +25,10 @@ export interface TableProps<Data extends object = any> extends TableOptions<Data
|
|
|
36
25
|
* Pagination steps list
|
|
37
26
|
*/
|
|
38
27
|
pageSizes?: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Total length of the data
|
|
30
|
+
*/
|
|
31
|
+
totalLength?: number;
|
|
39
32
|
/**
|
|
40
33
|
*
|
|
41
34
|
*/
|
|
@@ -137,6 +130,7 @@ export function useCustomTable<Data extends object = {}>(props: PropsWithChildre
|
|
|
137
130
|
filterId: controlledFilterId,
|
|
138
131
|
pageSize: controlledPageSize,
|
|
139
132
|
pageIndex: controlledPageIndex,
|
|
133
|
+
totalLength,
|
|
140
134
|
sortBy: controlledSortBy,
|
|
141
135
|
isLoading,
|
|
142
136
|
disableFilters,
|
|
@@ -236,6 +230,7 @@ export function useCustomTable<Data extends object = {}>(props: PropsWithChildre
|
|
|
236
230
|
pageIndex,
|
|
237
231
|
pageSize,
|
|
238
232
|
pageSizes,
|
|
233
|
+
totalLength,
|
|
239
234
|
setPageSize,
|
|
240
235
|
i18n,
|
|
241
236
|
children,
|
|
@@ -10,3 +10,6 @@ export * from "./filters/sliderColumnFilter.component";
|
|
|
10
10
|
export * from "./hooks/useCustomTable.hook";
|
|
11
11
|
export * from "./hooks/useOperations.hook";
|
|
12
12
|
export * from "./table.component";
|
|
13
|
+
export * from "./utils/getPageNumbers";
|
|
14
|
+
export * from "./utils/mapFormToColumns";
|
|
15
|
+
export * from "./utils/swapElements";
|
|
@@ -20,6 +20,7 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
20
20
|
pageSize,
|
|
21
21
|
pageSizes,
|
|
22
22
|
setPageSize,
|
|
23
|
+
totalLength,
|
|
23
24
|
i18n,
|
|
24
25
|
enableDragNDrop,
|
|
25
26
|
children,
|
|
@@ -81,6 +82,7 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
81
82
|
<div className={"overflow-hidden"}>
|
|
82
83
|
<Pagination
|
|
83
84
|
{...tableInstance}
|
|
85
|
+
totalLength={totalLength}
|
|
84
86
|
className={"text-sm"}
|
|
85
87
|
pageIndex={pageIndex}
|
|
86
88
|
pageSize={pageSize}
|