@tsed/react-formio 2.1.4 → 2.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
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.4",
35
- "@tsed/tailwind-formio": "2.1.4"
34
+ "@tsed/tailwind": "2.2.0",
35
+ "@tsed/tailwind-formio": "2.2.0"
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?: any;
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")}&nbsp;</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";
@@ -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";