@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
|
@@ -9,9 +9,10 @@ export interface PaginationProps {
|
|
|
9
9
|
canNextPage: boolean;
|
|
10
10
|
pageCount: number;
|
|
11
11
|
pageIndex: number;
|
|
12
|
-
pageOptions?:
|
|
12
|
+
pageOptions?: number[];
|
|
13
13
|
pageSize: number;
|
|
14
14
|
setPageSize: any;
|
|
15
|
+
totalLength?: number;
|
|
15
16
|
i18n?: (f: string) => string;
|
|
16
17
|
}
|
|
17
18
|
export declare function Pagination(props: PaginationProps): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { CellProps, FilterProps, Renderer,
|
|
2
|
+
import { CellProps, FilterProps, Renderer, TableOptions } from "react-table";
|
|
3
3
|
import { OnClickOperation, Operation, QueryOptions } from "../../../interfaces";
|
|
4
4
|
import { Pagination as DefaultPagination } from "../../pagination/pagination.component";
|
|
5
5
|
import { DefaultCellHeaderProps } from "../components/defaultCellHeader.component";
|
|
@@ -18,6 +18,10 @@ export interface TableProps<Data extends object = any> extends TableOptions<Data
|
|
|
18
18
|
* Pagination steps list
|
|
19
19
|
*/
|
|
20
20
|
pageSizes?: number[];
|
|
21
|
+
/**
|
|
22
|
+
* Total length of the data
|
|
23
|
+
*/
|
|
24
|
+
totalLength?: number;
|
|
21
25
|
/**
|
|
22
26
|
*
|
|
23
27
|
*/
|
|
@@ -86,7 +90,7 @@ declare function DefaultLoader(): React.JSX.Element;
|
|
|
86
90
|
declare function DefaultEmptyData(): React.JSX.Element;
|
|
87
91
|
export declare function useCustomTable<Data extends object = {}>(props: PropsWithChildren<TableProps<Data>>): {
|
|
88
92
|
className: string;
|
|
89
|
-
tableInstance: TableInstance<Data>;
|
|
93
|
+
tableInstance: import("react-table").TableInstance<Data>;
|
|
90
94
|
CellHeader: any;
|
|
91
95
|
isLoading: boolean | undefined;
|
|
92
96
|
Loader: React.ComponentType<{}> | typeof DefaultLoader;
|
|
@@ -98,6 +102,7 @@ export declare function useCustomTable<Data extends object = {}>(props: PropsWit
|
|
|
98
102
|
pageIndex: number;
|
|
99
103
|
pageSize: number;
|
|
100
104
|
pageSizes: number[];
|
|
105
|
+
totalLength: number | undefined;
|
|
101
106
|
setPageSize: (pageSize: number) => void;
|
|
102
107
|
i18n: (f: string) => string;
|
|
103
108
|
children: React.ReactNode;
|
|
@@ -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";
|
package/dist/index.js
CHANGED
|
@@ -327,6 +327,7 @@ function Pagination(props) {
|
|
|
327
327
|
pageOptions = props.pageOptions,
|
|
328
328
|
pageSize = props.pageSize,
|
|
329
329
|
setPageSize = props.setPageSize,
|
|
330
|
+
totalLength = props.totalLength,
|
|
330
331
|
_props$i18n = props.i18n,
|
|
331
332
|
i18n = _props$i18n === void 0 ? function (f) {
|
|
332
333
|
return f;
|
|
@@ -395,8 +396,13 @@ function Pagination(props) {
|
|
|
395
396
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
396
397
|
className: "ml-3"
|
|
397
398
|
}, i18n("items per page"))), pageOptions && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
398
|
-
className: "mb-3 flex items-center"
|
|
399
|
-
}, /*#__PURE__*/React__default["default"].createElement("span", null, i18n("Page"), "\xA0"), /*#__PURE__*/React__default["default"].createElement("strong", null, pageIndex + 1, " of ", pageOptions.length)
|
|
399
|
+
className: "mb-3 mr-3 flex items-center"
|
|
400
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", null, i18n("Page"), "\xA0"), /*#__PURE__*/React__default["default"].createElement("strong", null, pageIndex + 1, " of ", pageOptions.length), totalLength !== undefined && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
401
|
+
className: "ml-3"
|
|
402
|
+
}, i18n("Totals"), ": ", /*#__PURE__*/React__default["default"].createElement("strong", null, new Intl.NumberFormat(undefined).format(totalLength)), " ", i18n("items"))), totalLength !== undefined && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
403
|
+
className: "mb-3 flex items-center",
|
|
404
|
+
"data-testid": "pagination-total-items"
|
|
405
|
+
}, i18n("Totals"), ": ", /*#__PURE__*/React__default["default"].createElement("strong", null, new Intl.NumberFormat(undefined).format(totalLength)), " ", i18n("items")));
|
|
400
406
|
}
|
|
401
407
|
|
|
402
408
|
function DefaultArrowSort(_ref) {
|
|
@@ -782,7 +788,7 @@ function useOperations(_ref) {
|
|
|
782
788
|
};
|
|
783
789
|
}
|
|
784
790
|
|
|
785
|
-
var _excluded$9 = ["children", "className", "columns", "data", "onChange", "onClick", "onDrag", "onDrop", "operations", "pageSizes", "filters", "filterId", "pageSize", "pageIndex", "sortBy", "isLoading", "disableFilters", "disablePagination", "ArrowSort", "ColumnFilter", "EmptyData", "Loader", "Pagination", "Row", "CellHeader", "CellOperations", "i18n"];
|
|
791
|
+
var _excluded$9 = ["children", "className", "columns", "data", "onChange", "onClick", "onDrag", "onDrop", "operations", "pageSizes", "filters", "filterId", "pageSize", "pageIndex", "totalLength", "sortBy", "isLoading", "disableFilters", "disablePagination", "ArrowSort", "ColumnFilter", "EmptyData", "Loader", "Pagination", "Row", "CellHeader", "CellOperations", "i18n"];
|
|
786
792
|
function getOperationCallback(operations, onClick) {
|
|
787
793
|
return function (data, action) {
|
|
788
794
|
var operation = operations.find(function (operation) {
|
|
@@ -826,6 +832,7 @@ function useCustomTable(props) {
|
|
|
826
832
|
controlledFilterId = props.filterId,
|
|
827
833
|
controlledPageSize = props.pageSize,
|
|
828
834
|
controlledPageIndex = props.pageIndex,
|
|
835
|
+
totalLength = props.totalLength,
|
|
829
836
|
controlledSortBy = props.sortBy,
|
|
830
837
|
isLoading = props.isLoading,
|
|
831
838
|
disableFilters = props.disableFilters,
|
|
@@ -927,6 +934,7 @@ function useCustomTable(props) {
|
|
|
927
934
|
pageIndex: pageIndex,
|
|
928
935
|
pageSize: pageSize,
|
|
929
936
|
pageSizes: pageSizes,
|
|
937
|
+
totalLength: totalLength,
|
|
930
938
|
setPageSize: setPageSize,
|
|
931
939
|
i18n: i18n,
|
|
932
940
|
children: children,
|
|
@@ -954,6 +962,7 @@ function Table(props) {
|
|
|
954
962
|
pageSize = _useCustomTable.pageSize,
|
|
955
963
|
pageSizes = _useCustomTable.pageSizes,
|
|
956
964
|
setPageSize = _useCustomTable.setPageSize,
|
|
965
|
+
totalLength = _useCustomTable.totalLength,
|
|
957
966
|
i18n = _useCustomTable.i18n,
|
|
958
967
|
enableDragNDrop = _useCustomTable.enableDragNDrop,
|
|
959
968
|
children = _useCustomTable.children,
|
|
@@ -995,6 +1004,7 @@ function Table(props) {
|
|
|
995
1004
|
})) : null), isLoading ? /*#__PURE__*/React__default["default"].createElement(Loader, null) : null, !data.length ? /*#__PURE__*/React__default["default"].createElement(EmptyData, null) : null, !isLoading && data.length && !disablePagination ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
996
1005
|
className: "overflow-hidden"
|
|
997
1006
|
}, /*#__PURE__*/React__default["default"].createElement(Pagination, _extends({}, tableInstance, {
|
|
1007
|
+
totalLength: totalLength,
|
|
998
1008
|
className: "text-sm",
|
|
999
1009
|
pageIndex: pageIndex,
|
|
1000
1010
|
pageSize: pageSize,
|
|
@@ -7739,9 +7749,11 @@ exports.FormSettings = FormSettings;
|
|
|
7739
7749
|
exports.FormsTable = FormsTable;
|
|
7740
7750
|
exports.InputTags = InputTags;
|
|
7741
7751
|
exports.InputText = InputText;
|
|
7752
|
+
exports.LEFT_PAGE = LEFT_PAGE;
|
|
7742
7753
|
exports.Loader = Loader;
|
|
7743
7754
|
exports.Modal = Modal;
|
|
7744
7755
|
exports.Pagination = Pagination;
|
|
7756
|
+
exports.RIGHT_PAGE = RIGHT_PAGE;
|
|
7745
7757
|
exports.ReactComponent = ReactComponent;
|
|
7746
7758
|
exports.RemoveModal = RemoveModal;
|
|
7747
7759
|
exports.Select = Select;
|
|
@@ -7753,9 +7765,12 @@ exports.Tabs = Tabs;
|
|
|
7753
7765
|
exports.callLast = callLast;
|
|
7754
7766
|
exports.defaultDisplayChoices = defaultDisplayChoices;
|
|
7755
7767
|
exports.getOperationCallback = getOperationCallback;
|
|
7768
|
+
exports.getPageNumbers = getPageNumbers;
|
|
7756
7769
|
exports.iconClass = iconClass;
|
|
7770
|
+
exports.mapFormToColumns = mapFormToColumns;
|
|
7757
7771
|
exports.mapPagination = mapPagination;
|
|
7758
7772
|
exports.stopPropagationWrapper = stopPropagationWrapper;
|
|
7773
|
+
exports.swapElements = swapElements;
|
|
7759
7774
|
exports.useCustomTable = useCustomTable;
|
|
7760
7775
|
exports.useForm = useForm;
|
|
7761
7776
|
exports.useFormEdit = useFormEdit;
|