@jobber/components 4.52.1 → 4.53.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.
|
@@ -7,51 +7,51 @@ export interface DataTableProps<T> {
|
|
|
7
7
|
* Typescript should infer T from typeof data.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
data: T[];
|
|
10
|
+
readonly data: T[];
|
|
11
11
|
/**
|
|
12
12
|
* Should follow the @tanstack/react-table [ColumnDef](https://tanstack.com/table/v8/docs/guide/column-defs).
|
|
13
13
|
* [createColumnHelper](https://tanstack.com/table/v8/docs/guide/column-defs#column-helpers) is also exposed to make it more convenient
|
|
14
14
|
* to create columns.
|
|
15
15
|
*/
|
|
16
|
-
columns: ColumnDef<T>[];
|
|
16
|
+
readonly columns: ColumnDef<T>[];
|
|
17
17
|
/**
|
|
18
18
|
* Enables pagination, mostly follows:
|
|
19
19
|
* https://tanstack.com/table/v8/docs/api/features/pagination
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
pagination?: PaginationType;
|
|
22
|
+
readonly pagination?: PaginationType;
|
|
23
23
|
/**
|
|
24
24
|
* Enables sorting, mostly follows:
|
|
25
25
|
* https://tanstack.com/table/v8/docs/api/features/sorting#table-options
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
sorting?: SortingType;
|
|
28
|
+
readonly sorting?: SortingType;
|
|
29
29
|
/**
|
|
30
30
|
* This will force the table to have the specified hight
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
height?: number;
|
|
33
|
+
readonly height?: number;
|
|
34
34
|
/**
|
|
35
35
|
* When set to true makes the header sticky while scrolling vertically
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
|
-
stickyHeader?: boolean;
|
|
38
|
+
readonly stickyHeader?: boolean;
|
|
39
39
|
/**
|
|
40
40
|
* Pins the firstColumn when scrolling horizontally
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
|
-
pinFirstColumn?: boolean;
|
|
43
|
+
readonly pinFirstColumn?: boolean;
|
|
44
44
|
/**
|
|
45
45
|
* Enables row click action. The provided callback will be executed when the row is clicked.
|
|
46
46
|
*/
|
|
47
|
-
onRowClick?: (row: Row<T>) => void;
|
|
47
|
+
readonly onRowClick?: (row: Row<T>) => void;
|
|
48
48
|
/**
|
|
49
49
|
* The elements to display when the data table is empty
|
|
50
50
|
*/
|
|
51
|
-
emptyState?: ReactNode | ReactNode[];
|
|
51
|
+
readonly emptyState?: ReactNode | ReactNode[];
|
|
52
52
|
/**
|
|
53
53
|
* When true, shows the loading state of the DataTable
|
|
54
54
|
*/
|
|
55
|
-
loading?: boolean;
|
|
55
|
+
readonly loading?: boolean;
|
|
56
56
|
}
|
|
57
57
|
export declare function DataTable<T extends object>({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, loading, }: DataTableProps<T>): JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Table } from "@tanstack/react-table";
|
|
3
3
|
interface PaginationProps<T> {
|
|
4
|
-
table: Table<T>;
|
|
5
|
-
itemsPerPage?: number[];
|
|
6
|
-
totalItems: number;
|
|
7
|
-
loading: boolean;
|
|
4
|
+
readonly table: Table<T>;
|
|
5
|
+
readonly itemsPerPage?: number[];
|
|
6
|
+
readonly totalItems: number;
|
|
7
|
+
readonly loading: boolean;
|
|
8
|
+
readonly onPageChange: () => void;
|
|
8
9
|
}
|
|
9
|
-
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, loading, }: PaginationProps<T>): JSX.Element;
|
|
10
|
+
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, loading, onPageChange, }: PaginationProps<T>): JSX.Element;
|
|
10
11
|
export {};
|
package/dist/DataTable/index.js
CHANGED
|
@@ -138,7 +138,7 @@ var styles$2 = {"pagination":"zn0VRVhObt0-","paginationInfo":"_1d4uh90gfSI-","pa
|
|
|
138
138
|
styleInject_es.styleInject(css_248z$2);
|
|
139
139
|
|
|
140
140
|
const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
|
|
141
|
-
function Pagination({ table, itemsPerPage, totalItems, loading, }) {
|
|
141
|
+
function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, }) {
|
|
142
142
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
143
143
|
const totalRows = totalItems;
|
|
144
144
|
const firstPosition = pageIndex * pageSize + 1;
|
|
@@ -154,8 +154,14 @@ function Pagination({ table, itemsPerPage, totalItems, loading, }) {
|
|
|
154
154
|
}, size: "small" }, itemsPerPageOptions.map(numOfPages => (React__default["default"].createElement(Option.SelectOption, { key: numOfPages, value: numOfPages }, numOfPages)))),
|
|
155
155
|
React__default["default"].createElement("span", { className: styles$2.paginationSelectLabel }, "per page")),
|
|
156
156
|
React__default["default"].createElement("div", { className: styles$2.paginationButtons },
|
|
157
|
-
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () =>
|
|
158
|
-
|
|
157
|
+
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () => {
|
|
158
|
+
table.previousPage();
|
|
159
|
+
onPageChange();
|
|
160
|
+
}, disabled: !table.getCanPreviousPage() }),
|
|
161
|
+
React__default["default"].createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowRight", ariaLabel: "arrowRight", onClick: () => {
|
|
162
|
+
table.nextPage();
|
|
163
|
+
onPageChange();
|
|
164
|
+
}, disabled: !table.getCanNextPage() })))));
|
|
159
165
|
}
|
|
160
166
|
|
|
161
167
|
var css_248z$1 = "._0FexNr-lIgA- {\n padding: calc(16px * 1);\n padding: var(--space-base);\n border-top: calc(16px / 8) solid rgb(225, 225, 225);\n border-top: var(--border-thick) solid var(--color-border);\n}\n\n.PKlqQjoQ6DY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-pack: justify;\n justify-content: space-between;\n font-weight: bold;\n}\n\n.PKlqQjoQ6DY- * {\n text-align: left;\n}\n\n.ItTcVYUbVNM-,\n.ItTcVYUbVNM- * {\n font-weight: normal;\n text-align: right;\n}\n\n.PKlqQjoQ6DY-:not(:last-child) {\n padding-bottom: calc(16px / 2);\n padding-bottom: var(--space-small);\n}\n";
|
|
@@ -255,7 +261,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
255
261
|
});
|
|
256
262
|
const table = reactTable.useReactTable(tableSettings);
|
|
257
263
|
return (React__default["default"].createElement("div", { className: styles$3.dataTableContainer },
|
|
258
|
-
React__default["default"].createElement("div", { className: styles$3.tableContainer, style: { height }, ref: ref },
|
|
264
|
+
React__default["default"].createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$3.tableContainer, style: { height }, ref: ref },
|
|
259
265
|
React__default["default"].createElement("table", { className: tableClasses },
|
|
260
266
|
React__default["default"].createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
|
|
261
267
|
React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, emptyState: emptyState, loading: loading }),
|
|
@@ -267,7 +273,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
267
273
|
exactWidth <= jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
|
|
268
274
|
pagination && (React__default["default"].createElement(Pagination, { table: table, itemsPerPage: pagination.itemsPerPage, totalItems: pagination.manualPagination
|
|
269
275
|
? pagination.totalItems
|
|
270
|
-
: table.getCoreRowModel().rows.length, loading: loading }))));
|
|
276
|
+
: table.getCoreRowModel().rows.length, loading: loading, onPageChange: () => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0); } }))));
|
|
271
277
|
}
|
|
272
278
|
|
|
273
279
|
const mockContainerWidth = (exactWidth) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.53.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"> 1%",
|
|
85
85
|
"IE 10"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "403bda7e9da3cdfa667b6b22af56137e18ad914c"
|
|
88
88
|
}
|