@jobber/components 6.81.0 → 6.82.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/DataTable/DataTable.d.ts +16 -0
- package/dist/DataTable/components/DataTableActions.d.ts +2 -0
- package/dist/DataTable/components/DataTableBody.d.ts +2 -0
- package/dist/DataTable/components/DataTableCell.d.ts +2 -0
- package/dist/DataTable/components/DataTableContainer.d.ts +2 -0
- package/dist/DataTable/components/DataTableFooter.d.ts +9 -0
- package/dist/DataTable/components/DataTableHeader.d.ts +2 -0
- package/dist/DataTable/components/DataTableHeaderCell.d.ts +5 -0
- package/dist/DataTable/components/DataTablePagination.d.ts +5 -0
- package/dist/DataTable/components/DataTablePaginationButton.d.ts +21 -0
- package/dist/DataTable/components/DataTableRow.d.ts +2 -0
- package/dist/DataTable/components/DataTableRowActions.d.ts +4 -0
- package/dist/DataTable/components/DataTableSortableHeader.d.ts +18 -0
- package/dist/DataTable/components/DataTableTable.d.ts +2 -0
- package/dist/DataTable/components/index.cjs +27 -0
- package/dist/DataTable/components/index.d.ts +13 -0
- package/dist/DataTable/components/index.mjs +9 -0
- package/dist/DataTable/index.cjs +6 -0
- package/dist/DataTable/index.d.ts +1 -0
- package/dist/DataTable/index.mjs +1 -0
- package/dist/DataTable-cjs.js +40 -60
- package/dist/DataTable-es.js +37 -57
- package/dist/DataTableTable-cjs.js +127 -0
- package/dist/DataTableTable-es.js +112 -0
- package/dist/DatePicker/index.cjs +0 -1
- package/dist/DatePicker/index.mjs +0 -1
- package/dist/DatePicker-cjs.js +2472 -6
- package/dist/DatePicker-es.js +2454 -6
- package/dist/InputDate/index.cjs +0 -1
- package/dist/InputDate/index.mjs +0 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/styles.css +134 -0
- package/dist/utils/meta/meta.json +13 -0
- package/package.json +2 -5
- package/rollup.config.mjs +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ColumnDef, Row } from "@tanstack/react-table";
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
3
|
import { PaginationType, SortingType } from "./types";
|
|
4
|
+
import { DataTableActions, DataTableBody, DataTableContainer, DataTableFooter, DataTableHeader, DataTableHeaderCell, DataTablePagination, DataTablePaginationButton, DataTableRowActions, DataTableSortableHeader, DataTableTable } from "./components";
|
|
4
5
|
export interface DataTableProps<T> {
|
|
5
6
|
/**
|
|
6
7
|
* The actual data that will be used for the table.
|
|
@@ -55,3 +56,18 @@ export interface DataTableProps<T> {
|
|
|
55
56
|
readonly loading?: boolean;
|
|
56
57
|
}
|
|
57
58
|
export declare function DataTable<T extends object>({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, loading, }: DataTableProps<T>): React.JSX.Element;
|
|
59
|
+
export declare namespace DataTable {
|
|
60
|
+
var Table: typeof DataTableTable;
|
|
61
|
+
var Header: typeof DataTableHeader;
|
|
62
|
+
var HeaderCell: typeof DataTableHeaderCell;
|
|
63
|
+
var Row: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableRowElement> & React.RefAttributes<HTMLTableRowElement>>;
|
|
64
|
+
var Cell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>>;
|
|
65
|
+
var RowActions: typeof DataTableRowActions;
|
|
66
|
+
var Actions: typeof DataTableActions;
|
|
67
|
+
var Body: typeof DataTableBody;
|
|
68
|
+
var Container: typeof DataTableContainer;
|
|
69
|
+
var SortableHeader: typeof DataTableSortableHeader;
|
|
70
|
+
var Footer: typeof DataTableFooter;
|
|
71
|
+
var Pagination: typeof DataTablePagination;
|
|
72
|
+
var PaginationButton: typeof DataTablePaginationButton;
|
|
73
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DataTableFooterProps extends React.HTMLAttributes<HTMLTableSectionElement> {
|
|
3
|
+
readonly children: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Number of columns to span across. This should match the number of columns in your table.
|
|
6
|
+
*/
|
|
7
|
+
readonly colSpan: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function DataTableFooter({ children, className, colSpan, ...props }: DataTableFooterProps): React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DataTablePaginationProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
readonly children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function DataTablePagination({ children, className, ...props }: DataTablePaginationProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DataTablePaginationButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* The direction of the pagination button
|
|
5
|
+
*/
|
|
6
|
+
readonly direction: "previous" | "next";
|
|
7
|
+
/**
|
|
8
|
+
* Callback function when the pagination button is clicked
|
|
9
|
+
*/
|
|
10
|
+
readonly onClick?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the pagination button is disabled
|
|
13
|
+
*/
|
|
14
|
+
readonly disabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Function that returns the aria-label for the button. Required for accessibility.
|
|
17
|
+
* Should return translated strings based on the direction parameter.
|
|
18
|
+
*/
|
|
19
|
+
readonly ariaLabel: (direction: "previous" | "next") => string;
|
|
20
|
+
}
|
|
21
|
+
export declare function DataTablePaginationButton({ direction, onClick, disabled, ariaLabel, }: DataTablePaginationButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SortDirection } from "../SortIcon";
|
|
3
|
+
export interface DataTableSortableHeaderProps {
|
|
4
|
+
/**
|
|
5
|
+
* The header content to display (text, icons, etc.)
|
|
6
|
+
*/
|
|
7
|
+
readonly children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* The current sort direction for this column. When undefined, the header renders as non-interactive.
|
|
10
|
+
*/
|
|
11
|
+
readonly direction?: SortDirection;
|
|
12
|
+
/**
|
|
13
|
+
* Callback function triggered when the sortable header is clicked.
|
|
14
|
+
* When undefined, the header renders as non-interactive.
|
|
15
|
+
*/
|
|
16
|
+
readonly onSort?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function DataTableSortableHeader(props: DataTableSortableHeaderProps & React.HTMLAttributes<HTMLTableCellElement>): JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var DataTableTable = require('../../DataTableTable-cjs.js');
|
|
4
|
+
require('react');
|
|
5
|
+
require('classnames');
|
|
6
|
+
require('../../tslib.es6-cjs.js');
|
|
7
|
+
require('../../Button-cjs.js');
|
|
8
|
+
require('react-router-dom');
|
|
9
|
+
require('../../Icon-cjs.js');
|
|
10
|
+
require('@jobber/design');
|
|
11
|
+
require('../../Typography-cjs.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.DataTableActions = DataTableTable.DataTableActions;
|
|
16
|
+
exports.DataTableBody = DataTableTable.DataTableBody;
|
|
17
|
+
exports.DataTableCell = DataTableTable.DataTableCell;
|
|
18
|
+
exports.DataTableContainer = DataTableTable.DataTableContainer;
|
|
19
|
+
exports.DataTableFooter = DataTableTable.DataTableFooter;
|
|
20
|
+
exports.DataTableHeader = DataTableTable.DataTableHeader;
|
|
21
|
+
exports.DataTableHeaderCell = DataTableTable.DataTableHeaderCell;
|
|
22
|
+
exports.DataTablePagination = DataTableTable.DataTablePagination;
|
|
23
|
+
exports.DataTablePaginationButton = DataTableTable.DataTablePaginationButton;
|
|
24
|
+
exports.DataTableRow = DataTableTable.DataTableRow;
|
|
25
|
+
exports.DataTableRowActions = DataTableTable.DataTableRowActions;
|
|
26
|
+
exports.DataTableSortableHeader = DataTableTable.DataTableSortableHeader;
|
|
27
|
+
exports.DataTableTable = DataTableTable.DataTableTable;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { DataTableActions } from "./DataTableActions";
|
|
2
|
+
export { DataTableBody } from "./DataTableBody";
|
|
3
|
+
export { DataTableCell } from "./DataTableCell";
|
|
4
|
+
export { DataTableContainer } from "./DataTableContainer";
|
|
5
|
+
export { DataTableFooter } from "./DataTableFooter";
|
|
6
|
+
export { DataTableHeader } from "./DataTableHeader";
|
|
7
|
+
export { DataTableHeaderCell } from "./DataTableHeaderCell";
|
|
8
|
+
export { DataTablePagination } from "./DataTablePagination";
|
|
9
|
+
export { DataTablePaginationButton } from "./DataTablePaginationButton";
|
|
10
|
+
export { DataTableRow } from "./DataTableRow";
|
|
11
|
+
export { DataTableRowActions } from "./DataTableRowActions";
|
|
12
|
+
export { DataTableSortableHeader } from "./DataTableSortableHeader";
|
|
13
|
+
export { DataTableTable } from "./DataTableTable";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { D as DataTableActions, b as DataTableBody, c as DataTableCell, d as DataTableContainer, e as DataTableFooter, f as DataTableHeader, g as DataTableHeaderCell, h as DataTablePagination, i as DataTablePaginationButton, j as DataTableRow, k as DataTableRowActions, l as DataTableSortableHeader, m as DataTableTable } from '../../DataTableTable-es.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '../../tslib.es6-es.js';
|
|
5
|
+
import '../../Button-es.js';
|
|
6
|
+
import 'react-router-dom';
|
|
7
|
+
import '../../Icon-es.js';
|
|
8
|
+
import '@jobber/design';
|
|
9
|
+
import '../../Typography-es.js';
|
package/dist/DataTable/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var DataTable = require('../DataTable-cjs.js');
|
|
4
4
|
var helpers = require('../helpers-cjs.js');
|
|
5
|
+
var DataTableTable = require('../DataTableTable-cjs.js');
|
|
5
6
|
var reactTable = require('@tanstack/react-table');
|
|
6
7
|
require('classnames');
|
|
7
8
|
require('react');
|
|
@@ -41,6 +42,11 @@ require('react-hook-form');
|
|
|
41
42
|
|
|
42
43
|
exports.DataTable = DataTable.DataTable;
|
|
43
44
|
exports.mockContainerWidth = helpers.mockContainerWidth;
|
|
45
|
+
Object.defineProperty(exports, "SortDirection", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return DataTableTable.SortDirection; }
|
|
48
|
+
});
|
|
49
|
+
exports.SortIcon = DataTableTable.SortIcon;
|
|
44
50
|
Object.defineProperty(exports, "createColumnHelper", {
|
|
45
51
|
enumerable: true,
|
|
46
52
|
get: function () { return reactTable.createColumnHelper; }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { DataTable } from "./DataTable";
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export * from "./test-utilities/helpers";
|
|
4
|
+
export { SortIcon, SortDirection } from "./SortIcon";
|
|
4
5
|
export { Row, ColumnDef, createColumnHelper, PaginationState, SortingState, } from "@tanstack/react-table";
|
package/dist/DataTable/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { D as DataTable } from '../DataTable-es.js';
|
|
2
2
|
export { m as mockContainerWidth } from '../helpers-es.js';
|
|
3
|
+
export { a as SortDirection, S as SortIcon } from '../DataTableTable-es.js';
|
|
3
4
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
4
5
|
import 'classnames';
|
|
5
6
|
import 'react';
|
package/dist/DataTable-cjs.js
CHANGED
|
@@ -9,8 +9,9 @@ var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
|
9
9
|
var Select_index = require('./Select/index.cjs');
|
|
10
10
|
var Button = require('./Button-cjs.js');
|
|
11
11
|
var Text = require('./Text-cjs.js');
|
|
12
|
+
var DataTableTable = require('./DataTableTable-cjs.js');
|
|
12
13
|
|
|
13
|
-
var styles$
|
|
14
|
+
var styles$2 = {"dataTableContainer":"_3IHK46TSBOI-","tableContainer":"_8CMtSx4qamA-","table":"bNYpzdn5rPc-","pinFirstColumn":"lKXqbcsnCFs-","emptyStateCell":"i-x8vss2hcI-","stickyHeader":"eWffzdKfJH0-","pinFirstHeaderSortable":"aGF6t8l8iUk-","sortableColumn":"W0kYDUxPkqI-","clickableRow":"vWFyXrAaFtQ-","emptyState":"_8L7icG7E530-","spinning":"O1cxELzWgmM-"};
|
|
14
15
|
|
|
15
16
|
function BodyLoading({ table }) {
|
|
16
17
|
const loaderRows = table.getState().pagination.pageSize;
|
|
@@ -20,7 +21,7 @@ function BodyLoading({ table }) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function Body({ table, onRowClick, emptyState, loading, }) {
|
|
23
|
-
const bodyRowClasses = classnames({ [styles$
|
|
24
|
+
const bodyRowClasses = classnames({ [styles$2.clickableRow]: !!onRowClick });
|
|
24
25
|
const handleRowClick = React.useCallback((row) => () => {
|
|
25
26
|
if (onRowClick == undefined)
|
|
26
27
|
return;
|
|
@@ -39,8 +40,8 @@ function Body({ table, onRowClick, emptyState, loading, }) {
|
|
|
39
40
|
})));
|
|
40
41
|
}))) : (React.createElement("tbody", null,
|
|
41
42
|
React.createElement("tr", { className: bodyRowClasses },
|
|
42
|
-
React.createElement("td", { colSpan: table.getAllColumns().length, className: styles$
|
|
43
|
-
React.createElement("div", { className: styles$
|
|
43
|
+
React.createElement("td", { colSpan: table.getAllColumns().length, className: styles$2.emptyStateCell },
|
|
44
|
+
React.createElement("div", { className: styles$2.emptyState }, emptyState)))))));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function createTableSettings(data, columns, options) {
|
|
@@ -96,7 +97,7 @@ function getSortingSettings(sorting) {
|
|
|
96
97
|
return sortingSettings;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
var styles$
|
|
100
|
+
var styles$1 = {"pagination":"_5TLZRabskzI-","paginationInfo":"k8VFFgHUPZ4-","paginationNav":"SfaHBP7KC3Y-","paginationSelect":"E4zFf5oEm-Y-","paginationSelectLabel":"N4LhT5occ94-","paginationButtons":"HQPsyRjssL0-","spinning":"YHT2Mg0618I-"};
|
|
100
101
|
|
|
101
102
|
const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
|
|
102
103
|
function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, }) {
|
|
@@ -105,16 +106,16 @@ function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, })
|
|
|
105
106
|
const firstPosition = pageIndex * pageSize + 1;
|
|
106
107
|
const secondPosition = Math.min(totalRows, pageSize * (pageIndex + 1));
|
|
107
108
|
const itemsPerPageOptions = React.useMemo(() => { var _a; return (_a = itemsPerPage === null || itemsPerPage === void 0 ? void 0 : itemsPerPage.map(item => String(item))) !== null && _a !== void 0 ? _a : defaultItemsPerPageOptions; }, [itemsPerPage]);
|
|
108
|
-
return secondPosition <= 0 ? (React.createElement("div", { className: styles$
|
|
109
|
-
React.createElement("div", { className: styles$
|
|
110
|
-
React.createElement("div", { className: styles$
|
|
111
|
-
React.createElement("div", { className: styles$
|
|
112
|
-
React.createElement("div", { className: styles$
|
|
109
|
+
return secondPosition <= 0 ? (React.createElement("div", { className: styles$1.pagination },
|
|
110
|
+
React.createElement("div", { className: styles$1.paginationInfo }, !loading ? React.createElement(Text.Text, null, "No items") : React.createElement(Glimmer.Glimmer, { width: 200 })))) : (React.createElement("div", { className: styles$1.pagination },
|
|
111
|
+
React.createElement("div", { className: styles$1.paginationInfo }, `Showing ${firstPosition}-${secondPosition} of ${totalRows} items`),
|
|
112
|
+
React.createElement("div", { className: styles$1.paginationNav },
|
|
113
|
+
React.createElement("div", { className: styles$1.paginationSelect },
|
|
113
114
|
React.createElement(Select_index.Select, { value: table.getState().pagination.pageSize, onChange: value => {
|
|
114
115
|
table.setPageSize(Number(value));
|
|
115
116
|
}, size: "small" }, itemsPerPageOptions.map(numOfPages => (React.createElement(Select_index.Option, { key: numOfPages, value: numOfPages }, numOfPages)))),
|
|
116
|
-
React.createElement("span", { className: styles$
|
|
117
|
-
React.createElement("div", { className: styles$
|
|
117
|
+
React.createElement("span", { className: styles$1.paginationSelectLabel }, "per page")),
|
|
118
|
+
React.createElement("div", { className: styles$1.paginationButtons },
|
|
118
119
|
React.createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () => {
|
|
119
120
|
table.previousPage();
|
|
120
121
|
onPageChange();
|
|
@@ -125,18 +126,18 @@ function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, })
|
|
|
125
126
|
}, disabled: !table.getCanNextPage() })))));
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
var styles
|
|
129
|
+
var styles = {"mobileFooterContainer":"wMM6V80Rt-w-","mobileFooterRow":"HAoSIniVNvI-","mobileFooterRowData":"mNGvTIKaQIA-","spinning":"u7HdA4nq7qM-"};
|
|
129
130
|
|
|
130
131
|
const DesktopView = ({ table }) => (React.createElement("tfoot", { "data-testid": "data-table-desktop-footer" }, table.getFooterGroups().map(footerGroup => (React.createElement("tr", { key: footerGroup.id }, footerGroup.headers.map(header => (React.createElement("th", { key: header.id, style: {
|
|
131
132
|
width: header.getSize(),
|
|
132
133
|
minWidth: header.column.columnDef.minSize,
|
|
133
134
|
maxWidth: header.column.columnDef.maxSize,
|
|
134
135
|
} }, reactTable.flexRender(header.column.columnDef.footer, header.getContext())))))))));
|
|
135
|
-
const HandheldView = ({ table }) => (React.createElement("div", { className: styles
|
|
136
|
+
const HandheldView = ({ table }) => (React.createElement("div", { className: styles.mobileFooterContainer, "data-testid": "data-table-handheld-footer" }, table.getFooterGroups().map(footerGroup => (React.createElement("div", { key: footerGroup.id }, footerGroup.headers
|
|
136
137
|
.filter(header => header.column.columnDef.footer)
|
|
137
|
-
.map((header, index) => (React.createElement(React.Fragment, null, index === 0 ? (React.createElement("div", { className: styles
|
|
138
|
+
.map((header, index) => (React.createElement(React.Fragment, null, index === 0 ? (React.createElement("div", { className: styles.mobileFooterRow }, reactTable.flexRender(header.column.columnDef.footer, header.getContext()))) : (React.createElement("div", { className: styles.mobileFooterRow, key: footerGroup.id },
|
|
138
139
|
reactTable.flexRender(header.column.columnDef.header, header.getContext()),
|
|
139
|
-
React.createElement("div", { className: styles
|
|
140
|
+
React.createElement("div", { className: styles.mobileFooterRowData }, reactTable.flexRender(header.column.columnDef.footer, header.getContext()))))))))))));
|
|
140
141
|
const Footer = ({ table, viewType = "handheld", }) => {
|
|
141
142
|
const hasFooter = table
|
|
142
143
|
.getAllColumns()
|
|
@@ -147,42 +148,8 @@ const Footer = ({ table, viewType = "handheld", }) => {
|
|
|
147
148
|
return null;
|
|
148
149
|
};
|
|
149
150
|
|
|
150
|
-
var styles = {"sortIcon":"NrRExUGE6GY-","inactive":"e3aVa36Y7W8-","active":"lDKd982Sr-w-","spinning":"D9cW6RdlpZ0-"};
|
|
151
|
-
|
|
152
|
-
var SortDirection;
|
|
153
|
-
(function (SortDirection) {
|
|
154
|
-
SortDirection[SortDirection["ascending"] = 0] = "ascending";
|
|
155
|
-
SortDirection[SortDirection["descending"] = 1] = "descending";
|
|
156
|
-
SortDirection[SortDirection["equilibrium"] = 2] = "equilibrium";
|
|
157
|
-
})(SortDirection || (SortDirection = {}));
|
|
158
|
-
const sortStyleIndex = [
|
|
159
|
-
{
|
|
160
|
-
option: SortDirection.equilibrium,
|
|
161
|
-
upArrowStyle: undefined,
|
|
162
|
-
downArrowStyle: undefined,
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
option: SortDirection.ascending,
|
|
166
|
-
upArrowStyle: classnames(styles.active),
|
|
167
|
-
downArrowStyle: classnames(styles.inactive),
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
option: SortDirection.descending,
|
|
171
|
-
upArrowStyle: classnames(styles.inactive),
|
|
172
|
-
downArrowStyle: classnames(styles.active),
|
|
173
|
-
},
|
|
174
|
-
];
|
|
175
|
-
function SortIcon({ direction }) {
|
|
176
|
-
const foundStyle = sortStyleIndex.find(style => style.option === direction);
|
|
177
|
-
const finalStyle = foundStyle === undefined ? sortStyleIndex[0] : foundStyle;
|
|
178
|
-
return (React.createElement("div", { className: classnames(styles.sortIcon) },
|
|
179
|
-
React.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
180
|
-
React.createElement("path", { className: finalStyle.upArrowStyle, d: "M16.2929 10.6661C15.9024 11.0566 15.2692 11.0566 14.8787 10.6661L12.2891 8.14263L9.70711 10.6661C9.31658 11.0566 8.68342 11.0566 8.29289 10.6661C7.90237 10.2756 7.90237 9.64239 8.29289 9.25186L11.5858 5.95897C11.9763 5.56845 12.6095 5.56845 13 5.95897L16.2929 9.25186C16.6834 9.64239 16.6834 10.2756 16.2929 10.6661Z" }),
|
|
181
|
-
React.createElement("path", { className: finalStyle.downArrowStyle, d: "M8.29292 13.3339C8.68345 12.9434 9.31661 12.9434 9.70714 13.3339L12.2968 15.8573L14.8787 13.3339C15.2692 12.9434 15.9024 12.9434 16.2929 13.3339C16.6834 13.7244 16.6834 14.3576 16.2929 14.7481L13 18.041C12.6095 18.4315 11.9763 18.4315 11.5858 18.041L8.29292 14.7481C7.9024 14.3576 7.9024 13.7244 8.29292 13.3339Z" }))));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
151
|
function Header({ table, stickyHeader, sorting, onRowClick, }) {
|
|
185
|
-
const stickyClass = classnames({ [styles$
|
|
152
|
+
const stickyClass = classnames({ [styles$2.stickyHeader]: stickyHeader });
|
|
186
153
|
return (React.createElement("thead", { className: stickyClass }, table.getHeaderGroups().map(headerGroup => (React.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map(header => {
|
|
187
154
|
const isSorting = sorting && header.column.getCanSort();
|
|
188
155
|
const headingCellInlineStyle = {
|
|
@@ -194,17 +161,17 @@ function Header({ table, stickyHeader, sorting, onRowClick, }) {
|
|
|
194
161
|
headingCellInlineStyle.paddingRight = 0;
|
|
195
162
|
}
|
|
196
163
|
return (React.createElement("th", { key: header.id, colSpan: header.colSpan, className: isSorting
|
|
197
|
-
? classnames(styles$
|
|
198
|
-
[styles$
|
|
164
|
+
? classnames(styles$2.sortableColumn, {
|
|
165
|
+
[styles$2.pinFirstHeaderSortable]: !!onRowClick,
|
|
199
166
|
})
|
|
200
167
|
: "", onClick: sorting ? header.column.getToggleSortingHandler() : undefined, style: headingCellInlineStyle }, header.isPlaceholder ? null : (React.createElement("div", null,
|
|
201
168
|
reactTable.flexRender(header.column.columnDef.header, header.getContext()),
|
|
202
169
|
header.column.getCanSort() &&
|
|
203
170
|
sorting &&
|
|
204
|
-
!header.column.getIsSorted() && (React.createElement(SortIcon, { direction: SortDirection.equilibrium })),
|
|
171
|
+
!header.column.getIsSorted() && (React.createElement(DataTableTable.SortIcon, { direction: DataTableTable.SortDirection.equilibrium })),
|
|
205
172
|
{
|
|
206
|
-
asc: React.createElement(SortIcon, { direction: SortDirection.ascending }),
|
|
207
|
-
desc: React.createElement(SortIcon, { direction: SortDirection.descending }),
|
|
173
|
+
asc: React.createElement(DataTableTable.SortIcon, { direction: DataTableTable.SortDirection.ascending }),
|
|
174
|
+
desc: React.createElement(DataTableTable.SortIcon, { direction: DataTableTable.SortDirection.descending }),
|
|
208
175
|
}[header.column.getIsSorted()]))));
|
|
209
176
|
}))))));
|
|
210
177
|
}
|
|
@@ -215,12 +182,12 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
215
182
|
pagination,
|
|
216
183
|
sorting,
|
|
217
184
|
});
|
|
218
|
-
const tableClasses = classnames(styles$
|
|
219
|
-
[styles$
|
|
185
|
+
const tableClasses = classnames(styles$2.table, {
|
|
186
|
+
[styles$2.pinFirstColumn]: pinFirstColumn,
|
|
220
187
|
});
|
|
221
188
|
const table = reactTable.useReactTable(tableSettings);
|
|
222
|
-
return (React.createElement("div", { className: styles$
|
|
223
|
-
React.createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$
|
|
189
|
+
return (React.createElement("div", { className: styles$2.dataTableContainer },
|
|
190
|
+
React.createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$2.tableContainer, style: { height }, ref: ref },
|
|
224
191
|
React.createElement("table", { className: tableClasses },
|
|
225
192
|
React.createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
|
|
226
193
|
React.createElement(Body, { table: table, onRowClick: onRowClick, emptyState: emptyState, loading: loading }),
|
|
@@ -234,5 +201,18 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
234
201
|
? pagination.totalItems
|
|
235
202
|
: table.getCoreRowModel().rows.length, loading: loading, onPageChange: () => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0); } }))));
|
|
236
203
|
}
|
|
204
|
+
DataTable.Table = DataTableTable.DataTableTable;
|
|
205
|
+
DataTable.Header = DataTableTable.DataTableHeader;
|
|
206
|
+
DataTable.HeaderCell = DataTableTable.DataTableHeaderCell;
|
|
207
|
+
DataTable.Row = DataTableTable.DataTableRow;
|
|
208
|
+
DataTable.Cell = DataTableTable.DataTableCell;
|
|
209
|
+
DataTable.RowActions = DataTableTable.DataTableRowActions;
|
|
210
|
+
DataTable.Actions = DataTableTable.DataTableActions;
|
|
211
|
+
DataTable.Body = DataTableTable.DataTableBody;
|
|
212
|
+
DataTable.Container = DataTableTable.DataTableContainer;
|
|
213
|
+
DataTable.SortableHeader = DataTableTable.DataTableSortableHeader;
|
|
214
|
+
DataTable.Footer = DataTableTable.DataTableFooter;
|
|
215
|
+
DataTable.Pagination = DataTableTable.DataTablePagination;
|
|
216
|
+
DataTable.PaginationButton = DataTableTable.DataTablePaginationButton;
|
|
237
217
|
|
|
238
218
|
exports.DataTable = DataTable;
|
package/dist/DataTable-es.js
CHANGED
|
@@ -7,8 +7,9 @@ import { _ as __rest } from './tslib.es6-es.js';
|
|
|
7
7
|
import { Select, Option as SelectOption } from './Select/index.mjs';
|
|
8
8
|
import { B as Button } from './Button-es.js';
|
|
9
9
|
import { T as Text } from './Text-es.js';
|
|
10
|
+
import { S as SortIcon, a as SortDirection, m as DataTableTable, f as DataTableHeader, g as DataTableHeaderCell, j as DataTableRow, c as DataTableCell, k as DataTableRowActions, D as DataTableActions, b as DataTableBody, d as DataTableContainer, l as DataTableSortableHeader, e as DataTableFooter, h as DataTablePagination, i as DataTablePaginationButton } from './DataTableTable-es.js';
|
|
10
11
|
|
|
11
|
-
var styles$
|
|
12
|
+
var styles$2 = {"dataTableContainer":"_3IHK46TSBOI-","tableContainer":"_8CMtSx4qamA-","table":"bNYpzdn5rPc-","pinFirstColumn":"lKXqbcsnCFs-","emptyStateCell":"i-x8vss2hcI-","stickyHeader":"eWffzdKfJH0-","pinFirstHeaderSortable":"aGF6t8l8iUk-","sortableColumn":"W0kYDUxPkqI-","clickableRow":"vWFyXrAaFtQ-","emptyState":"_8L7icG7E530-","spinning":"O1cxELzWgmM-"};
|
|
12
13
|
|
|
13
14
|
function BodyLoading({ table }) {
|
|
14
15
|
const loaderRows = table.getState().pagination.pageSize;
|
|
@@ -18,7 +19,7 @@ function BodyLoading({ table }) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function Body({ table, onRowClick, emptyState, loading, }) {
|
|
21
|
-
const bodyRowClasses = classnames({ [styles$
|
|
22
|
+
const bodyRowClasses = classnames({ [styles$2.clickableRow]: !!onRowClick });
|
|
22
23
|
const handleRowClick = useCallback((row) => () => {
|
|
23
24
|
if (onRowClick == undefined)
|
|
24
25
|
return;
|
|
@@ -37,8 +38,8 @@ function Body({ table, onRowClick, emptyState, loading, }) {
|
|
|
37
38
|
})));
|
|
38
39
|
}))) : (React__default.createElement("tbody", null,
|
|
39
40
|
React__default.createElement("tr", { className: bodyRowClasses },
|
|
40
|
-
React__default.createElement("td", { colSpan: table.getAllColumns().length, className: styles$
|
|
41
|
-
React__default.createElement("div", { className: styles$
|
|
41
|
+
React__default.createElement("td", { colSpan: table.getAllColumns().length, className: styles$2.emptyStateCell },
|
|
42
|
+
React__default.createElement("div", { className: styles$2.emptyState }, emptyState)))))));
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function createTableSettings(data, columns, options) {
|
|
@@ -94,7 +95,7 @@ function getSortingSettings(sorting) {
|
|
|
94
95
|
return sortingSettings;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
var styles$
|
|
98
|
+
var styles$1 = {"pagination":"_5TLZRabskzI-","paginationInfo":"k8VFFgHUPZ4-","paginationNav":"SfaHBP7KC3Y-","paginationSelect":"E4zFf5oEm-Y-","paginationSelectLabel":"N4LhT5occ94-","paginationButtons":"HQPsyRjssL0-","spinning":"YHT2Mg0618I-"};
|
|
98
99
|
|
|
99
100
|
const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
|
|
100
101
|
function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, }) {
|
|
@@ -103,16 +104,16 @@ function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, })
|
|
|
103
104
|
const firstPosition = pageIndex * pageSize + 1;
|
|
104
105
|
const secondPosition = Math.min(totalRows, pageSize * (pageIndex + 1));
|
|
105
106
|
const itemsPerPageOptions = useMemo(() => { var _a; return (_a = itemsPerPage === null || itemsPerPage === void 0 ? void 0 : itemsPerPage.map(item => String(item))) !== null && _a !== void 0 ? _a : defaultItemsPerPageOptions; }, [itemsPerPage]);
|
|
106
|
-
return secondPosition <= 0 ? (React__default.createElement("div", { className: styles$
|
|
107
|
-
React__default.createElement("div", { className: styles$
|
|
108
|
-
React__default.createElement("div", { className: styles$
|
|
109
|
-
React__default.createElement("div", { className: styles$
|
|
110
|
-
React__default.createElement("div", { className: styles$
|
|
107
|
+
return secondPosition <= 0 ? (React__default.createElement("div", { className: styles$1.pagination },
|
|
108
|
+
React__default.createElement("div", { className: styles$1.paginationInfo }, !loading ? React__default.createElement(Text, null, "No items") : React__default.createElement(Glimmer, { width: 200 })))) : (React__default.createElement("div", { className: styles$1.pagination },
|
|
109
|
+
React__default.createElement("div", { className: styles$1.paginationInfo }, `Showing ${firstPosition}-${secondPosition} of ${totalRows} items`),
|
|
110
|
+
React__default.createElement("div", { className: styles$1.paginationNav },
|
|
111
|
+
React__default.createElement("div", { className: styles$1.paginationSelect },
|
|
111
112
|
React__default.createElement(Select, { value: table.getState().pagination.pageSize, onChange: value => {
|
|
112
113
|
table.setPageSize(Number(value));
|
|
113
114
|
}, size: "small" }, itemsPerPageOptions.map(numOfPages => (React__default.createElement(SelectOption, { key: numOfPages, value: numOfPages }, numOfPages)))),
|
|
114
|
-
React__default.createElement("span", { className: styles$
|
|
115
|
-
React__default.createElement("div", { className: styles$
|
|
115
|
+
React__default.createElement("span", { className: styles$1.paginationSelectLabel }, "per page")),
|
|
116
|
+
React__default.createElement("div", { className: styles$1.paginationButtons },
|
|
116
117
|
React__default.createElement(Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () => {
|
|
117
118
|
table.previousPage();
|
|
118
119
|
onPageChange();
|
|
@@ -123,18 +124,18 @@ function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, })
|
|
|
123
124
|
}, disabled: !table.getCanNextPage() })))));
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
var styles
|
|
127
|
+
var styles = {"mobileFooterContainer":"wMM6V80Rt-w-","mobileFooterRow":"HAoSIniVNvI-","mobileFooterRowData":"mNGvTIKaQIA-","spinning":"u7HdA4nq7qM-"};
|
|
127
128
|
|
|
128
129
|
const DesktopView = ({ table }) => (React__default.createElement("tfoot", { "data-testid": "data-table-desktop-footer" }, table.getFooterGroups().map(footerGroup => (React__default.createElement("tr", { key: footerGroup.id }, footerGroup.headers.map(header => (React__default.createElement("th", { key: header.id, style: {
|
|
129
130
|
width: header.getSize(),
|
|
130
131
|
minWidth: header.column.columnDef.minSize,
|
|
131
132
|
maxWidth: header.column.columnDef.maxSize,
|
|
132
133
|
} }, flexRender(header.column.columnDef.footer, header.getContext())))))))));
|
|
133
|
-
const HandheldView = ({ table }) => (React__default.createElement("div", { className: styles
|
|
134
|
+
const HandheldView = ({ table }) => (React__default.createElement("div", { className: styles.mobileFooterContainer, "data-testid": "data-table-handheld-footer" }, table.getFooterGroups().map(footerGroup => (React__default.createElement("div", { key: footerGroup.id }, footerGroup.headers
|
|
134
135
|
.filter(header => header.column.columnDef.footer)
|
|
135
|
-
.map((header, index) => (React__default.createElement(React__default.Fragment, null, index === 0 ? (React__default.createElement("div", { className: styles
|
|
136
|
+
.map((header, index) => (React__default.createElement(React__default.Fragment, null, index === 0 ? (React__default.createElement("div", { className: styles.mobileFooterRow }, flexRender(header.column.columnDef.footer, header.getContext()))) : (React__default.createElement("div", { className: styles.mobileFooterRow, key: footerGroup.id },
|
|
136
137
|
flexRender(header.column.columnDef.header, header.getContext()),
|
|
137
|
-
React__default.createElement("div", { className: styles
|
|
138
|
+
React__default.createElement("div", { className: styles.mobileFooterRowData }, flexRender(header.column.columnDef.footer, header.getContext()))))))))))));
|
|
138
139
|
const Footer = ({ table, viewType = "handheld", }) => {
|
|
139
140
|
const hasFooter = table
|
|
140
141
|
.getAllColumns()
|
|
@@ -145,42 +146,8 @@ const Footer = ({ table, viewType = "handheld", }) => {
|
|
|
145
146
|
return null;
|
|
146
147
|
};
|
|
147
148
|
|
|
148
|
-
var styles = {"sortIcon":"NrRExUGE6GY-","inactive":"e3aVa36Y7W8-","active":"lDKd982Sr-w-","spinning":"D9cW6RdlpZ0-"};
|
|
149
|
-
|
|
150
|
-
var SortDirection;
|
|
151
|
-
(function (SortDirection) {
|
|
152
|
-
SortDirection[SortDirection["ascending"] = 0] = "ascending";
|
|
153
|
-
SortDirection[SortDirection["descending"] = 1] = "descending";
|
|
154
|
-
SortDirection[SortDirection["equilibrium"] = 2] = "equilibrium";
|
|
155
|
-
})(SortDirection || (SortDirection = {}));
|
|
156
|
-
const sortStyleIndex = [
|
|
157
|
-
{
|
|
158
|
-
option: SortDirection.equilibrium,
|
|
159
|
-
upArrowStyle: undefined,
|
|
160
|
-
downArrowStyle: undefined,
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
option: SortDirection.ascending,
|
|
164
|
-
upArrowStyle: classnames(styles.active),
|
|
165
|
-
downArrowStyle: classnames(styles.inactive),
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
option: SortDirection.descending,
|
|
169
|
-
upArrowStyle: classnames(styles.inactive),
|
|
170
|
-
downArrowStyle: classnames(styles.active),
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
function SortIcon({ direction }) {
|
|
174
|
-
const foundStyle = sortStyleIndex.find(style => style.option === direction);
|
|
175
|
-
const finalStyle = foundStyle === undefined ? sortStyleIndex[0] : foundStyle;
|
|
176
|
-
return (React__default.createElement("div", { className: classnames(styles.sortIcon) },
|
|
177
|
-
React__default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
178
|
-
React__default.createElement("path", { className: finalStyle.upArrowStyle, d: "M16.2929 10.6661C15.9024 11.0566 15.2692 11.0566 14.8787 10.6661L12.2891 8.14263L9.70711 10.6661C9.31658 11.0566 8.68342 11.0566 8.29289 10.6661C7.90237 10.2756 7.90237 9.64239 8.29289 9.25186L11.5858 5.95897C11.9763 5.56845 12.6095 5.56845 13 5.95897L16.2929 9.25186C16.6834 9.64239 16.6834 10.2756 16.2929 10.6661Z" }),
|
|
179
|
-
React__default.createElement("path", { className: finalStyle.downArrowStyle, d: "M8.29292 13.3339C8.68345 12.9434 9.31661 12.9434 9.70714 13.3339L12.2968 15.8573L14.8787 13.3339C15.2692 12.9434 15.9024 12.9434 16.2929 13.3339C16.6834 13.7244 16.6834 14.3576 16.2929 14.7481L13 18.041C12.6095 18.4315 11.9763 18.4315 11.5858 18.041L8.29292 14.7481C7.9024 14.3576 7.9024 13.7244 8.29292 13.3339Z" }))));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
149
|
function Header({ table, stickyHeader, sorting, onRowClick, }) {
|
|
183
|
-
const stickyClass = classnames({ [styles$
|
|
150
|
+
const stickyClass = classnames({ [styles$2.stickyHeader]: stickyHeader });
|
|
184
151
|
return (React__default.createElement("thead", { className: stickyClass }, table.getHeaderGroups().map(headerGroup => (React__default.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map(header => {
|
|
185
152
|
const isSorting = sorting && header.column.getCanSort();
|
|
186
153
|
const headingCellInlineStyle = {
|
|
@@ -192,8 +159,8 @@ function Header({ table, stickyHeader, sorting, onRowClick, }) {
|
|
|
192
159
|
headingCellInlineStyle.paddingRight = 0;
|
|
193
160
|
}
|
|
194
161
|
return (React__default.createElement("th", { key: header.id, colSpan: header.colSpan, className: isSorting
|
|
195
|
-
? classnames(styles$
|
|
196
|
-
[styles$
|
|
162
|
+
? classnames(styles$2.sortableColumn, {
|
|
163
|
+
[styles$2.pinFirstHeaderSortable]: !!onRowClick,
|
|
197
164
|
})
|
|
198
165
|
: "", onClick: sorting ? header.column.getToggleSortingHandler() : undefined, style: headingCellInlineStyle }, header.isPlaceholder ? null : (React__default.createElement("div", null,
|
|
199
166
|
flexRender(header.column.columnDef.header, header.getContext()),
|
|
@@ -213,12 +180,12 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
213
180
|
pagination,
|
|
214
181
|
sorting,
|
|
215
182
|
});
|
|
216
|
-
const tableClasses = classnames(styles$
|
|
217
|
-
[styles$
|
|
183
|
+
const tableClasses = classnames(styles$2.table, {
|
|
184
|
+
[styles$2.pinFirstColumn]: pinFirstColumn,
|
|
218
185
|
});
|
|
219
186
|
const table = useReactTable(tableSettings);
|
|
220
|
-
return (React__default.createElement("div", { className: styles$
|
|
221
|
-
React__default.createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$
|
|
187
|
+
return (React__default.createElement("div", { className: styles$2.dataTableContainer },
|
|
188
|
+
React__default.createElement("div", { "data-testid": "ATL-DataTable-Container", className: styles$2.tableContainer, style: { height }, ref: ref },
|
|
222
189
|
React__default.createElement("table", { className: tableClasses },
|
|
223
190
|
React__default.createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
|
|
224
191
|
React__default.createElement(Body, { table: table, onRowClick: onRowClick, emptyState: emptyState, loading: loading }),
|
|
@@ -232,5 +199,18 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
232
199
|
? pagination.totalItems
|
|
233
200
|
: table.getCoreRowModel().rows.length, loading: loading, onPageChange: () => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0); } }))));
|
|
234
201
|
}
|
|
202
|
+
DataTable.Table = DataTableTable;
|
|
203
|
+
DataTable.Header = DataTableHeader;
|
|
204
|
+
DataTable.HeaderCell = DataTableHeaderCell;
|
|
205
|
+
DataTable.Row = DataTableRow;
|
|
206
|
+
DataTable.Cell = DataTableCell;
|
|
207
|
+
DataTable.RowActions = DataTableRowActions;
|
|
208
|
+
DataTable.Actions = DataTableActions;
|
|
209
|
+
DataTable.Body = DataTableBody;
|
|
210
|
+
DataTable.Container = DataTableContainer;
|
|
211
|
+
DataTable.SortableHeader = DataTableSortableHeader;
|
|
212
|
+
DataTable.Footer = DataTableFooter;
|
|
213
|
+
DataTable.Pagination = DataTablePagination;
|
|
214
|
+
DataTable.PaginationButton = DataTablePaginationButton;
|
|
235
215
|
|
|
236
216
|
export { DataTable as D };
|