@vendorflow/components 2.0.79 → 2.0.82
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/lib/components/material-ui/DataTable/Data.js +1 -0
- package/lib/components/material-ui/DataTable/DataTable.d.ts +3 -0
- package/lib/components/material-ui/DataTable/DataTable.js +19 -12
- package/lib/components/material-ui/DataTable/DataTable.story.js +2 -2
- package/lib/components/material-ui/DataTable/TablePieces/BodyCell.js +2 -1
- package/lib/components/material-ui/DataTable/TablePieces/BodyRow.d.ts +5 -2
- package/lib/components/material-ui/DataTable/TablePieces/BodyRow.js +6 -7
- package/lib/components/material-ui/DataTable/TablePieces/HeaderCell.d.ts +2 -1
- package/lib/components/material-ui/DataTable/TablePieces/HeaderCell.js +5 -3
- package/lib/components/material-ui/DataTable/TablePieces/TableBodyContent.d.ts +5 -1
- package/lib/components/material-ui/DataTable/TablePieces/TableBodyContent.js +19 -9
- package/lib/components/material-ui/DataTable/TablePieces/ViewColumnTool.js +2 -1
- package/package.json +2 -2
|
@@ -19,6 +19,7 @@ var faker_1 = __importDefault(require("faker"));
|
|
|
19
19
|
var DataTable_1 = require("./DataTable");
|
|
20
20
|
exports.Columns = [
|
|
21
21
|
{
|
|
22
|
+
id: 'fullName',
|
|
22
23
|
Header: 'Full Name',
|
|
23
24
|
columns: [
|
|
24
25
|
__assign({ Header: 'First Name', accessor: 'firstName' }, (0, DataTable_1.getColumnFilterConfig)('text')),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { Column, UseSortByColumnProps, HeaderGroup, UseSortByOptions, TableOptions, UseSortByColumnOptions, PluginHook, UsePaginationOptions, UseSortByInstanceProps, UsePaginationInstanceProps, TableInstance, TableState, UseSortByState, UsePaginationState, UseRowSelectOptions, UseRowSelectInstanceProps, UseRowSelectState, ColumnInstance, Row, UseRowSelectRowProps, UseExpandedOptions, UseExpandedInstanceProps, UseExpandedState, UseExpandedRowProps, ActionType, UseGlobalFiltersInstanceProps, UseGlobalFiltersState, UseFiltersOptions, UseFiltersInstanceProps, UseFiltersState, UseFiltersColumnOptions, UseFiltersColumnProps, Renderer, FilterProps, UseTableOptions, UseGlobalFiltersOptions, UseResizeColumnsColumnOptions, UseResizeColumnsColumnProps, UseResizeColumnsState } from 'react-table';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
+
export declare const ACTION_COLUMN_ID = "action-column";
|
|
6
7
|
export declare type Mode = 'single' | 'multi';
|
|
7
8
|
export declare type CustomColumnConfigProps<D extends object> = {
|
|
8
9
|
name?: string;
|
|
@@ -52,6 +53,8 @@ export interface TableFeatureOptions<D extends object> {
|
|
|
52
53
|
enabled: boolean;
|
|
53
54
|
};
|
|
54
55
|
table?: {
|
|
56
|
+
flexLayoutEnabled?: boolean;
|
|
57
|
+
hideToolbar?: boolean;
|
|
55
58
|
getRowId?: UseTableOptions<D>['getRowId'];
|
|
56
59
|
};
|
|
57
60
|
virtualize?: {
|
|
@@ -73,7 +73,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
73
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
74
|
};
|
|
75
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
exports.getColumnFilterConfig = exports.renderSingleLineCell = exports.useDefaultTableInstance = exports.usePluginConfig = exports.CELL_PADDING = void 0;
|
|
76
|
+
exports.getColumnFilterConfig = exports.renderSingleLineCell = exports.useDefaultTableInstance = exports.usePluginConfig = exports.CELL_PADDING = exports.ACTION_COLUMN_ID = void 0;
|
|
77
77
|
/** @jsxRuntime classic */
|
|
78
78
|
/** @jsx jsx */
|
|
79
79
|
var react_1 = require("@emotion/react");
|
|
@@ -95,6 +95,7 @@ var react_scrollbar_size_1 = __importDefault(require("react-scrollbar-size"));
|
|
|
95
95
|
var Table_1 = __importDefault(require("./TablePieces/Table"));
|
|
96
96
|
var HeaderCell_1 = __importDefault(require("./TablePieces/HeaderCell"));
|
|
97
97
|
var TableBodyContent_1 = __importDefault(require("./TablePieces/TableBodyContent"));
|
|
98
|
+
exports.ACTION_COLUMN_ID = 'action-column';
|
|
98
99
|
exports.CELL_PADDING = 4;
|
|
99
100
|
var EXPAND_BTN_WIDTH = 24;
|
|
100
101
|
var NO_MATCH_TEXT = 'Sorry, no matching records found';
|
|
@@ -112,7 +113,7 @@ function DataTable(_a) {
|
|
|
112
113
|
var scrollbarWidth = (0, react_scrollbar_size_1.default)().width;
|
|
113
114
|
var _h = __read((0, react_2.useState)(0), 2), scrollLeft = _h[0], setScrollLeft = _h[1];
|
|
114
115
|
var _j = (labels || { noMatchLabel: NO_MATCH_TEXT }).noMatchLabel, noMatchLabel = _j === void 0 ? NO_MATCH_TEXT : _j;
|
|
115
|
-
var _k = options || {}, rowExpandingConfig = _k.rowExpanding, filtersConfig = _k.filters, globalSearchConfig = _k.globalSearch, columnHidingConfig = _k.columnHiding, paginationConfig = _k.pagination, sortingConfig = _k.sorting, virtualizeConfig = _k.virtualize;
|
|
116
|
+
var _k = options || {}, rowExpandingConfig = _k.rowExpanding, filtersConfig = _k.filters, globalSearchConfig = _k.globalSearch, columnHidingConfig = _k.columnHiding, paginationConfig = _k.pagination, sortingConfig = _k.sorting, tableConfig = _k.table, virtualizeConfig = _k.virtualize;
|
|
116
117
|
var ExpandedComponent = (rowExpandingConfig || {}).Component;
|
|
117
118
|
var allColumns = instance.allColumns, getTableProps = instance.getTableProps, gotoPage = instance.gotoPage, headerGroups = instance.headerGroups, page = instance.page, prepareRow = instance.prepareRow, rows = instance.rows, setAllFilters = instance.setAllFilters, setPageSize = instance.setPageSize, setFilter = instance.setFilter, setGlobalFilter = instance.setGlobalFilter, state = instance.state, totalColumnsWidth = instance.totalColumnsWidth;
|
|
118
119
|
var pageOptions = ((_b = options === null || options === void 0 ? void 0 : options.pagination) === null || _b === void 0 ? void 0 : _b.rowsPerPageOptions) || instance.pageOptions;
|
|
@@ -162,9 +163,9 @@ function DataTable(_a) {
|
|
|
162
163
|
}
|
|
163
164
|
}, [scrollLeft]);
|
|
164
165
|
return ((0, react_1.jsx)(material_1.Paper, __assign({ ref: rootRef, css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: calc(100% - ", "px);\n height: 100%;\n position: relative;\n "], ["\n width: calc(100% - ", "px);\n height: 100%;\n position: relative;\n "])), hasScrollbar.vertical ? scrollbarWidth : 0), className: "DataTable" }, restOfProps),
|
|
165
|
-
(0, react_1.jsx)("div", { ref: toolbarRef, className: "DataTable__Toolbar" },
|
|
166
|
+
!(tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.hideToolbar) && ((0, react_1.jsx)("div", { ref: toolbarRef, className: "DataTable__Toolbar" },
|
|
166
167
|
(0, react_1.jsx)(Toolbar_1.default, { title: title, allColumns: allColumns, columnNameById: columnNameById, globalFilter: globalFilter, enableFilters: filtersConfig === null || filtersConfig === void 0 ? void 0 : filtersConfig.enabled, enableGlobalSearch: globalSearchConfig === null || globalSearchConfig === void 0 ? void 0 : globalSearchConfig.enabled, enableHideColumns: columnHidingConfig === null || columnHidingConfig === void 0 ? void 0 : columnHidingConfig.enabled, hasRowsSelected: hasRowsSelected, numRowsSelected: numRowsSelected, setAllFilters: setAllFilters, setGlobalFilter: (globalSearchConfig === null || globalSearchConfig === void 0 ? void 0 : globalSearchConfig.setGlobalFilter) ? globalSearchConfig === null || globalSearchConfig === void 0 ? void 0 : globalSearchConfig.setGlobalFilter : setGlobalFilter, renderActions: renderActions, renderRowSelectActions: renderRowSelectActions }),
|
|
167
|
-
(filtersConfig === null || filtersConfig === void 0 ? void 0 : filtersConfig.enabled) && ((0, react_1.jsx)(AppliedFilters_1.default, { columnNameById: columnNameById, filters: filters, setFilter: setFilter }))),
|
|
168
|
+
(filtersConfig === null || filtersConfig === void 0 ? void 0 : filtersConfig.enabled) && ((0, react_1.jsx)(AppliedFilters_1.default, { columnNameById: columnNameById, filters: filters, setFilter: setFilter })))),
|
|
168
169
|
(0, react_1.jsx)("div", { className: "DataTable__TableContainer", css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: ", "px;\n "], ["\n height: ", "px;\n "])), containerHeight) },
|
|
169
170
|
(0, react_1.jsx)(Table_1.default, { getTableProps: getTableProps, css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n display: grid;\n grid-template-rows: auto 1fr;\n "], ["\n width: 100%;\n display: grid;\n grid-template-rows: auto 1fr;\n "]))) },
|
|
170
171
|
(0, react_1.jsx)(material_1.TableHead, { ref: tableHeadRef, className: "DataTable__TableHead", component: "div", css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n && {\n display: block;\n height: auto;\n width: calc(100% - ", "px);\n overflow-x: auto;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n\n &::-webkit-scrollbar {\n /* Hide scrollbar for Chrome, Safari and Opera */\n display: none;\n }\n }\n "], ["\n && {\n display: block;\n height: auto;\n width: calc(100% - ", "px);\n overflow-x: auto;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n\n &::-webkit-scrollbar {\n /* Hide scrollbar for Chrome, Safari and Opera */\n display: none;\n }\n }\n "])), hasScrollbar.vertical ? scrollbarWidth : 0), onScroll: function (evt) {
|
|
@@ -176,21 +177,27 @@ function DataTable(_a) {
|
|
|
176
177
|
// eslint-disable-next-line react/jsx-key
|
|
177
178
|
(0, react_1.jsx)(material_1.TableRow, __assign({}, headerGroup.getHeaderGroupProps(), { component: "div" }), headerGroup.headers.map(function (header) {
|
|
178
179
|
var _a = header.getHeaderProps((sortingConfig === null || sortingConfig === void 0 ? void 0 : sortingConfig.enabled) ? header.getSortByToggleProps() : undefined), key = _a.key, restOfHeaderProps = __rest(_a, ["key"]);
|
|
179
|
-
return (0, react_1.jsx)(HeaderCell_1.default, { key: key, header: header, headerProps: restOfHeaderProps });
|
|
180
|
+
return ((0, react_1.jsx)(HeaderCell_1.default, { key: key, header: header, headerProps: restOfHeaderProps, flexLayoutEnabled: (tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.flexLayoutEnabled) || false }));
|
|
180
181
|
})));
|
|
181
182
|
})),
|
|
182
|
-
(0, react_1.jsx)(TableBodyContent_1.default, { defaultRowHeight: defaultRowHeight, ExpandedComponent: ExpandedComponent, hasScrollbarRefCallback: hasScrollbarRefCallback, height: tableBodyContentRect.height, isVirtualizeEnabled: !!(virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.enabled), noMatchLabel: noMatchLabel, prepareRow: prepareRow, scrollContainerRef: scrollContainerRef, setScrollLeft: setScrollLeft, tableBodyRef: tableBodyRef, tableBodyMeasureRefCallback: tableBodyMeasureRefCallback, tableRows: tableRows, totalColumnsWidth: totalColumnsWidth, width: tableBodyContentRect.width }))),
|
|
183
|
+
(0, react_1.jsx)(TableBodyContent_1.default, { defaultRowHeight: defaultRowHeight, ExpandedComponent: ExpandedComponent, flexLayoutEnabled: (tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.flexLayoutEnabled) || false, hasScrollbar: hasScrollbar, hasScrollbarRefCallback: hasScrollbarRefCallback, height: tableBodyContentRect.height, isVirtualizeEnabled: !!(virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.enabled), noMatchLabel: noMatchLabel, prepareRow: prepareRow, scrollContainerRef: scrollContainerRef, scrollbarWidth: scrollbarWidth, setScrollLeft: setScrollLeft, tableBodyRef: tableBodyRef, tableBodyMeasureRefCallback: tableBodyMeasureRefCallback, tableRows: tableRows, totalColumnsWidth: totalColumnsWidth, width: tableBodyContentRect.width }))),
|
|
183
184
|
(paginationConfig === null || paginationConfig === void 0 ? void 0 : paginationConfig.enabled) && ((0, react_1.jsx)(material_1.TablePagination, { ref: paginationRef, className: "DataTable__Pagination", component: "div", count: rows.length, page: pageIndex, onPageChange: function (evt, newPage) { return gotoPage(newPage); }, onRowsPerPageChange: function (evt) { return setPageSize(Number(evt.target.value)); }, rowsPerPage: pageSize, rowsPerPageOptions: pageOptions }))));
|
|
184
185
|
}
|
|
185
186
|
exports.default = DataTable;
|
|
186
187
|
function usePluginConfig(options) {
|
|
187
188
|
var filters = options.filters, globalSearch = options.globalSearch, pagination = options.pagination, rowExpanding = options.rowExpanding, sorting = options.sorting, rowSelect = options.rowSelect, columnHiding = options.columnHiding, columnResizing = options.columnResizing, virtualize = options.virtualize;
|
|
188
|
-
var
|
|
189
|
+
var actionColumnCellWidth = (rowExpanding === null || rowExpanding === void 0 ? void 0 : rowExpanding.enabled) && (rowSelect === null || rowSelect === void 0 ? void 0 : rowSelect.enabled)
|
|
189
190
|
? exports.CELL_PADDING * 2 + EXPAND_BTN_WIDTH + IndeterminateCheckbox_1.CHECKBOX_WIDTH
|
|
190
191
|
: Math.max(EXPAND_BTN_WIDTH, IndeterminateCheckbox_1.CHECKBOX_WIDTH) + exports.CELL_PADDING * 2;
|
|
191
192
|
return (0, react_2.useMemo)(function () {
|
|
193
|
+
var _a;
|
|
192
194
|
var result = [];
|
|
193
|
-
|
|
195
|
+
if ((_a = options.table) === null || _a === void 0 ? void 0 : _a.flexLayoutEnabled) {
|
|
196
|
+
result.push(react_table_1.useFlexLayout);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
result.push(react_table_1.useBlockLayout);
|
|
200
|
+
}
|
|
194
201
|
if (filters === null || filters === void 0 ? void 0 : filters.enabled) {
|
|
195
202
|
result.push(react_table_1.useFilters);
|
|
196
203
|
}
|
|
@@ -217,10 +224,10 @@ function usePluginConfig(options) {
|
|
|
217
224
|
result.push(function (hooks) {
|
|
218
225
|
hooks.visibleColumns.push(function (columns) { return __spreadArray([
|
|
219
226
|
{
|
|
220
|
-
id:
|
|
221
|
-
width:
|
|
222
|
-
minWidth:
|
|
223
|
-
maxWidth:
|
|
227
|
+
id: exports.ACTION_COLUMN_ID,
|
|
228
|
+
width: actionColumnCellWidth,
|
|
229
|
+
minWidth: actionColumnCellWidth,
|
|
230
|
+
maxWidth: actionColumnCellWidth,
|
|
224
231
|
Header: function (props) {
|
|
225
232
|
var _a = props, getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, getToggleAllPageRowsSelectedProps = _a.getToggleAllPageRowsSelectedProps;
|
|
226
233
|
return ((0, react_1.jsx)(react_2.Fragment, null,
|
|
@@ -51,7 +51,7 @@ function DataTable() {
|
|
|
51
51
|
pageSize: 10,
|
|
52
52
|
},
|
|
53
53
|
virtualize: {
|
|
54
|
-
enabled:
|
|
54
|
+
enabled: false,
|
|
55
55
|
},
|
|
56
56
|
rowSelect: {
|
|
57
57
|
enabled: true,
|
|
@@ -61,6 +61,7 @@ function DataTable() {
|
|
|
61
61
|
enabled: true,
|
|
62
62
|
},
|
|
63
63
|
table: {
|
|
64
|
+
flexLayoutEnabled: true,
|
|
64
65
|
getRowId: function (person) { return person.id; },
|
|
65
66
|
},
|
|
66
67
|
};
|
|
@@ -69,7 +70,6 @@ function DataTable() {
|
|
|
69
70
|
data: data,
|
|
70
71
|
options: options,
|
|
71
72
|
defaultColumn: { minWidth: 50, width: 150 },
|
|
72
|
-
initialState: { hiddenColumns: ['firstName'] },
|
|
73
73
|
});
|
|
74
74
|
return (react_1.default.createElement(material_1.ThemeProvider, { theme: (0, material_1.createTheme)() },
|
|
75
75
|
react_1.default.createElement("div", { style: { height: '700px', width: '640px' } },
|
|
@@ -38,11 +38,12 @@ var DataTable_1 = require("../DataTable");
|
|
|
38
38
|
function BodyCell(_a) {
|
|
39
39
|
var cell = _a.cell, cellProps = _a.cellProps;
|
|
40
40
|
var style = cellProps.style, className = cellProps.className, restOfCellProps = __rest(cellProps, ["style", "className"]);
|
|
41
|
+
var isActionColumn = cell.column.id === DataTable_1.ACTION_COLUMN_ID;
|
|
41
42
|
return ((0, react_1.jsx)(react_1.ClassNames, null, function (_a) {
|
|
42
43
|
var css = _a.css, cx = _a.cx;
|
|
43
44
|
return ((0, react_1.jsx)(material_1.TableCell, __assign({ css: cx(
|
|
44
45
|
// @ts-ignore
|
|
45
|
-
css(style), css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n padding: ", "px;\n display: block;\n border-bottom: none;\n }\n "], ["\n && {\n padding: ", "px;\n display: block;\n border-bottom: none;\n }\n "])), DataTable_1.CELL_PADDING)), className: (0, classnames_1.default)(className,
|
|
46
|
+
css(style), css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n padding: ", "px;\n display: block;\n border-bottom: none;\n ", "\n }\n "], ["\n && {\n padding: ", "px;\n display: block;\n border-bottom: none;\n ", "\n }\n "])), DataTable_1.CELL_PADDING, isActionColumn ? 'flex: none;' : '')), className: (0, classnames_1.default)(className, isActionColumn ? 'cell-ActionColumn' : undefined) }, restOfCellProps, { component: "div", variant: "body" }), cell.render('Cell')));
|
|
46
47
|
}));
|
|
47
48
|
}
|
|
48
49
|
exports.default = BodyCell;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
1
4
|
import { CSSProperties } from 'react';
|
|
2
5
|
import { EnhancedRow } from '../DataTable';
|
|
3
6
|
import { TableRowProps } from 'react-table';
|
|
@@ -11,5 +14,5 @@ interface Props<D extends object> {
|
|
|
11
14
|
style?: CSSProperties;
|
|
12
15
|
measure?: () => void;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
export
|
|
17
|
+
export default function BodyRow<D extends object>({ ExpandedComponent, row, rowProps, innerRef, style, measure, }: Props<D>): jsx.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -52,7 +52,7 @@ var react_2 = require("react");
|
|
|
52
52
|
var material_1 = require("@mui/material");
|
|
53
53
|
var BodyCell_1 = __importDefault(require("./BodyCell"));
|
|
54
54
|
var lodash_1 = require("lodash");
|
|
55
|
-
function
|
|
55
|
+
function BodyRow(_a) {
|
|
56
56
|
var ExpandedComponent = _a.ExpandedComponent, row = _a.row, rowProps = _a.rowProps, innerRef = _a.innerRef, style = _a.style, measure = _a.measure;
|
|
57
57
|
var _b = __read((0, react_2.useState)(null), 2), element = _b[0], setElement = _b[1];
|
|
58
58
|
var className = rowProps.className, rowPropsStyle = rowProps.style, restOfRowProps = __rest(rowProps, ["className", "style"]);
|
|
@@ -71,18 +71,17 @@ function Row(_a) {
|
|
|
71
71
|
if (innerRef) {
|
|
72
72
|
innerRef(node);
|
|
73
73
|
}
|
|
74
|
-
}, css: cx(style && css(style)
|
|
74
|
+
}, css: cx(style && css(style)) },
|
|
75
75
|
(0, react_1.jsx)(material_1.TableRow, __assign({}, restOfRowProps, { component: "div", css: cx(
|
|
76
76
|
// @ts-ignore
|
|
77
|
-
css(rowPropsStyle), css(
|
|
77
|
+
css(rowPropsStyle), css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n "], ["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n "])))), className: className }), row.cells.map(function (cell) {
|
|
78
78
|
var _a = cell.getCellProps(), key = _a.key, restOfCellProps = __rest(_a, ["key"]);
|
|
79
79
|
return (0, react_1.jsx)(BodyCell_1.default, { key: key, cell: cell, cellProps: restOfCellProps });
|
|
80
80
|
})),
|
|
81
|
-
isExpanded && !!ExpandedComponent && ((0, react_1.jsx)(material_1.TableRow, { component: "div", css: css(
|
|
82
|
-
(0, react_1.jsx)(material_1.TableCell, { component: "div", variant: "body", css: css(
|
|
81
|
+
isExpanded && !!ExpandedComponent && ((0, react_1.jsx)(material_1.TableRow, { component: "div", css: css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n min-width: 100%;\n width: 100%;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n "], ["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n min-width: 100%;\n width: 100%;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n "]))) },
|
|
82
|
+
(0, react_1.jsx)(material_1.TableCell, { component: "div", variant: "body", css: css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n && {\n display: block;\n border-bottom: none;\n }\n "], ["\n && {\n display: block;\n border-bottom: none;\n }\n "]))) },
|
|
83
83
|
(0, react_1.jsx)(ExpandedComponent, { data: row.original }))))));
|
|
84
84
|
}));
|
|
85
85
|
}
|
|
86
|
-
var BodyRow = (0, react_2.memo)(Row);
|
|
87
86
|
exports.default = BodyRow;
|
|
88
|
-
var templateObject_1, templateObject_2, templateObject_3
|
|
87
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -5,8 +5,9 @@ import { EnhancedHeader } from '../DataTable';
|
|
|
5
5
|
import { TableHeaderProps } from 'react-table';
|
|
6
6
|
interface Props<D extends object> {
|
|
7
7
|
className?: string;
|
|
8
|
+
flexLayoutEnabled: boolean;
|
|
8
9
|
header: EnhancedHeader<D>;
|
|
9
10
|
headerProps: Omit<TableHeaderProps, 'key'>;
|
|
10
11
|
}
|
|
11
|
-
export default function HeaderCell<D extends object>({ className, header, headerProps }: Props<D>): jsx.JSX.Element;
|
|
12
|
+
export default function HeaderCell<D extends object>({ className, flexLayoutEnabled, header, headerProps }: Props<D>): jsx.JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -38,17 +38,19 @@ var material_1 = require("@mui/material");
|
|
|
38
38
|
var icons_material_1 = require("@mui/icons-material");
|
|
39
39
|
var DataTable_1 = require("../DataTable");
|
|
40
40
|
function HeaderCell(_a) {
|
|
41
|
-
var className = _a.className, header = _a.header, headerProps = _a.headerProps;
|
|
41
|
+
var className = _a.className, flexLayoutEnabled = _a.flexLayoutEnabled, header = _a.header, headerProps = _a.headerProps;
|
|
42
42
|
var headerPropsClassName = headerProps.className, style = headerProps.style, restOfProps = __rest(headerProps, ["className", "style"]);
|
|
43
43
|
return ((0, react_1.jsx)(react_1.ClassNames, null, function (_a) {
|
|
44
44
|
var css = _a.css, cx = _a.cx;
|
|
45
45
|
return ((0, react_1.jsx)(material_1.TableCell, __assign({}, restOfProps, { component: "div", variant: "head", css: cx(
|
|
46
46
|
// @ts-ignore
|
|
47
|
-
css(style), css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n display: flex;\n box-sizing: border-box;\n padding: ", "px;\n }\n "], ["\n && {\n display: flex;\n box-sizing: border-box;\n padding: ", "px;\n }\n "])), DataTable_1.CELL_PADDING),
|
|
47
|
+
css(style), css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n display: flex;\n box-sizing: border-box;\n padding: ", "px;\n }\n "], ["\n && {\n display: flex;\n box-sizing: border-box;\n padding: ", "px;\n }\n "])), DataTable_1.CELL_PADDING), !flexLayoutEnabled &&
|
|
48
|
+
header.minWidth !== undefined && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n min-width: ", "px;\n "], ["\n min-width: ", "px;\n "])), header.minWidth), !flexLayoutEnabled &&
|
|
49
|
+
header.maxWidth !== undefined && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n max-width: ", "px;\n "], ["\n max-width: ", "px;\n "])), header.maxWidth)), className: (0, classnames_1.default)(headerPropsClassName, className, "col-" + header.id) }),
|
|
48
50
|
(0, react_1.jsx)("div", { css: cx(css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: ", ";\n align-items: center;\n width: 100%;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n "], ["\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: ", ";\n align-items: center;\n width: 100%;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n "])), header.columns != null ? 'center' : 'flex-start')) },
|
|
49
51
|
(0, react_1.jsx)("span", { css: cx(css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-weight: 600;\n flex: none;\n "], ["\n font-weight: 600;\n flex: none;\n "])))) }, header.render('Header')),
|
|
50
52
|
(0, react_1.jsx)(SortIndicator_1.default, { canSort: header.canSort, isSorted: header.isSorted, isSortedDesc: header.isSortedDesc }),
|
|
51
|
-
header.id !==
|
|
53
|
+
header.id !== DataTable_1.ACTION_COLUMN_ID && !header.id.includes('_placeholder') && !!header.getResizerProps && ((0, react_1.jsx)(icons_material_1.DragIndicator, __assign({ css: css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n right: 0;\n top: 50%;\n transform: translate(-50%, -50%);\n color: #b2b2b2;\n background-color: white;\n "], ["\n position: absolute;\n right: 0;\n top: 50%;\n transform: translate(-50%, -50%);\n color: #b2b2b2;\n background-color: white;\n "]))) }, header.getResizerProps()))))));
|
|
52
54
|
}));
|
|
53
55
|
}
|
|
54
56
|
exports.default = HeaderCell;
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
5
5
|
import { Row } from 'react-table';
|
|
6
|
+
import { HasScrollbar } from '@vendorflow/common/lib/hooks';
|
|
6
7
|
interface Props<D extends object> {
|
|
7
8
|
defaultRowHeight: number;
|
|
8
9
|
ExpandedComponent: ((props: {
|
|
9
10
|
data: D;
|
|
10
11
|
}) => JSX.Element) | undefined;
|
|
12
|
+
flexLayoutEnabled: boolean;
|
|
13
|
+
hasScrollbar: HasScrollbar;
|
|
11
14
|
hasScrollbarRefCallback: (node: HTMLDivElement | null) => void;
|
|
12
15
|
height: number | undefined;
|
|
13
16
|
isVirtualizeEnabled: boolean;
|
|
14
17
|
noMatchLabel?: string;
|
|
15
18
|
prepareRow: (row: Row<D>) => void;
|
|
19
|
+
scrollbarWidth: number;
|
|
16
20
|
scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
|
|
17
21
|
setScrollLeft: Dispatch<SetStateAction<number>>;
|
|
18
22
|
tableBodyRef: MutableRefObject<HTMLDivElement | null>;
|
|
@@ -21,5 +25,5 @@ interface Props<D extends object> {
|
|
|
21
25
|
totalColumnsWidth: number;
|
|
22
26
|
width: number | undefined;
|
|
23
27
|
}
|
|
24
|
-
export default function TableBodyContent<D extends object>({ defaultRowHeight, ExpandedComponent, hasScrollbarRefCallback, height, isVirtualizeEnabled, noMatchLabel, prepareRow, scrollContainerRef, setScrollLeft, tableBodyRef, tableBodyMeasureRefCallback, tableRows, totalColumnsWidth, width, }: Props<D>): jsx.JSX.Element;
|
|
28
|
+
export default function TableBodyContent<D extends object>({ defaultRowHeight, ExpandedComponent, flexLayoutEnabled, hasScrollbar, hasScrollbarRefCallback, height, isVirtualizeEnabled, noMatchLabel, prepareRow, scrollbarWidth, scrollContainerRef, setScrollLeft, tableBodyRef, tableBodyMeasureRefCallback, tableRows, totalColumnsWidth, width, }: Props<D>): jsx.JSX.Element;
|
|
25
29
|
export {};
|
|
@@ -25,23 +25,33 @@ var react_virtualized_1 = require("react-virtualized");
|
|
|
25
25
|
var BodyRow_1 = __importDefault(require("./BodyRow"));
|
|
26
26
|
var material_1 = require("@mui/material");
|
|
27
27
|
var react_2 = require("react");
|
|
28
|
+
var hooks_1 = require("@vendorflow/common/lib/hooks");
|
|
28
29
|
function TableBodyContent(_a) {
|
|
29
|
-
var defaultRowHeight = _a.defaultRowHeight, ExpandedComponent = _a.ExpandedComponent, hasScrollbarRefCallback = _a.hasScrollbarRefCallback, height = _a.height, isVirtualizeEnabled = _a.isVirtualizeEnabled, noMatchLabel = _a.noMatchLabel, prepareRow = _a.prepareRow, scrollContainerRef = _a.scrollContainerRef, setScrollLeft = _a.setScrollLeft, tableBodyRef = _a.tableBodyRef, tableBodyMeasureRefCallback = _a.tableBodyMeasureRefCallback, tableRows = _a.tableRows, totalColumnsWidth = _a.totalColumnsWidth, width = _a.width;
|
|
30
|
-
var
|
|
30
|
+
var defaultRowHeight = _a.defaultRowHeight, ExpandedComponent = _a.ExpandedComponent, flexLayoutEnabled = _a.flexLayoutEnabled, hasScrollbar = _a.hasScrollbar, hasScrollbarRefCallback = _a.hasScrollbarRefCallback, height = _a.height, isVirtualizeEnabled = _a.isVirtualizeEnabled, noMatchLabel = _a.noMatchLabel, prepareRow = _a.prepareRow, scrollbarWidth = _a.scrollbarWidth, scrollContainerRef = _a.scrollContainerRef, setScrollLeft = _a.setScrollLeft, tableBodyRef = _a.tableBodyRef, tableBodyMeasureRefCallback = _a.tableBodyMeasureRefCallback, tableRows = _a.tableRows, totalColumnsWidth = _a.totalColumnsWidth, width = _a.width;
|
|
31
|
+
var scrollContentWidth = (0, react_2.useMemo)(function () {
|
|
32
|
+
if (!flexLayoutEnabled || !width) {
|
|
33
|
+
return totalColumnsWidth;
|
|
34
|
+
}
|
|
35
|
+
return width - (hasScrollbar.vertical ? scrollbarWidth : 0);
|
|
36
|
+
}, [flexLayoutEnabled, totalColumnsWidth, width, hasScrollbar, scrollbarWidth]);
|
|
37
|
+
var forceUpdate = (0, hooks_1.useForceUpdate)();
|
|
38
|
+
var cache = (0, react_2.useRef)(new react_virtualized_1.CellMeasurerCache({ fixedWidth: true, defaultHeight: defaultRowHeight, defaultWidth: scrollContentWidth }));
|
|
31
39
|
(0, react_2.useEffect)(function () {
|
|
32
40
|
if (isVirtualizeEnabled) {
|
|
33
41
|
cache.current = new react_virtualized_1.CellMeasurerCache({
|
|
34
42
|
fixedWidth: true,
|
|
35
43
|
defaultHeight: defaultRowHeight,
|
|
36
|
-
defaultWidth:
|
|
44
|
+
defaultWidth: scrollContentWidth,
|
|
37
45
|
});
|
|
38
46
|
cache.current.clearAll();
|
|
47
|
+
forceUpdate();
|
|
39
48
|
}
|
|
40
|
-
}, [
|
|
49
|
+
}, [scrollContentWidth]);
|
|
41
50
|
function renderRow(_a) {
|
|
42
51
|
var columnIndex = _a.columnIndex, rowIndex = _a.rowIndex, key = _a.key, parent = _a.parent, style = _a.style;
|
|
43
52
|
var row = tableRows[rowIndex];
|
|
44
53
|
prepareRow(row);
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
55
|
var _b = row.getRowProps(), _ = _b.key, restOfRowProps = __rest(_b, ["key"]);
|
|
46
56
|
return ((0, react_1.jsx)(react_virtualized_1.CellMeasurer, { cache: cache.current, columnIndex: columnIndex, key: key, rowIndex: rowIndex, parent: parent }, function (_a) {
|
|
47
57
|
var measure = _a.measure, registerChild = _a.registerChild;
|
|
@@ -68,14 +78,14 @@ function TableBodyContent(_a) {
|
|
|
68
78
|
var scrollLeft = evt.target.scrollLeft;
|
|
69
79
|
setScrollLeft(scrollLeft);
|
|
70
80
|
} },
|
|
71
|
-
(0, react_1.jsx)("div",
|
|
81
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: ", "px;\n "], ["\n width: ", "px;\n "])), scrollContentWidth) }, tableRows.length > 0 ? (tableRows.map(function (row) {
|
|
72
82
|
prepareRow(row);
|
|
73
83
|
var _a = row.getRowProps(), key = _a.key, restOfRowProps = __rest(_a, ["key"]);
|
|
74
84
|
return ((0, react_1.jsx)(BodyRow_1.default, { key: key, ExpandedComponent: ExpandedComponent, row: row, rowProps: restOfRowProps }));
|
|
75
|
-
})) : ((0, react_1.jsx)(material_1.TableRow, { component: "div", css: (0, react_1.css)(
|
|
76
|
-
(0, react_1.jsx)(material_1.TableCell, { component: "div", variant: "body", css: (0, react_1.css)(
|
|
77
|
-
(0, react_1.jsx)("div", { css: (0, react_1.css)(
|
|
85
|
+
})) : ((0, react_1.jsx)(material_1.TableRow, { component: "div", css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n min-width: 100%;\n width: 100%;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n\n &&:last-child {\n border-bottom: none;\n }\n "], ["\n && {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n box-sizing: border-box;\n min-width: 100%;\n width: 100%;\n border-bottom: 1px solid rgba(224, 224, 224, 1);\n }\n\n &&:last-child {\n border-bottom: none;\n }\n "]))) },
|
|
86
|
+
(0, react_1.jsx)(material_1.TableCell, { component: "div", variant: "body", css: (0, react_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n && {\n display: block;\n border-bottom: none;\n width: 100%;\n }\n "], ["\n && {\n display: block;\n border-bottom: none;\n width: 100%;\n }\n "]))) },
|
|
87
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n text-align: center;\n "], ["\n text-align: center;\n "]))) },
|
|
78
88
|
(0, react_1.jsx)("span", null, noMatchLabel))))))))));
|
|
79
89
|
}
|
|
80
90
|
exports.default = TableBodyContent;
|
|
81
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
91
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -42,6 +42,7 @@ var material_1 = require("@mui/material");
|
|
|
42
42
|
var icons_material_1 = require("@mui/icons-material");
|
|
43
43
|
var nanoid_1 = require("nanoid");
|
|
44
44
|
var IndeterminateCheckbox_1 = __importDefault(require("./IndeterminateCheckbox"));
|
|
45
|
+
var DataTable_1 = require("../DataTable");
|
|
45
46
|
function ViewColumnTool(_a) {
|
|
46
47
|
var allColumns = _a.allColumns, columnNameById = _a.columnNameById;
|
|
47
48
|
var id = (0, react_2.useMemo)(function () { return (0, nanoid_1.nanoid)(); }, []);
|
|
@@ -65,7 +66,7 @@ function ViewColumnTool(_a) {
|
|
|
65
66
|
(0, react_1.jsx)(material_1.IconButton, { onClick: handleClose },
|
|
66
67
|
(0, react_1.jsx)(icons_material_1.Close, null)))),
|
|
67
68
|
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n "]))) }, allColumns
|
|
68
|
-
.filter(function (column) { return column.id !==
|
|
69
|
+
.filter(function (column) { return column.id !== DataTable_1.ACTION_COLUMN_ID; })
|
|
69
70
|
.map(function (column) {
|
|
70
71
|
return ((0, react_1.jsx)(material_1.FormControlLabel, { key: column.id, label: columnNameById[column.id],
|
|
71
72
|
// @ts-ignore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendorflow/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.82",
|
|
4
4
|
"description": "React components for vendorflow",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/react-table": "^7.7.6",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
64
64
|
"@typescript-eslint/parser": "^4.32.0",
|
|
65
|
-
"@vendorflow/common": "^1.0.
|
|
65
|
+
"@vendorflow/common": "^1.0.50",
|
|
66
66
|
"babel-eslint": "10.1.0",
|
|
67
67
|
"babel-jest": "^24.9.0",
|
|
68
68
|
"babel-loader": "^8.2.2",
|