fuse-importer 0.25.9 → 0.26.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/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +11 -1
- package/lib/esm/Importer/Review/ReviewWithContext.js +4 -8
- package/lib/esm/Importer/Uploader/HeadersPreview.js +5 -9
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +3 -3
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +35 -12
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +28 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +21 -10
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +4 -2
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +5 -68
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/index.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/styles.js +2 -2
- package/lib/esm/Importer/common/index.js +1 -1
- package/lib/esm/Importer/common/utils.d.ts +4 -1
- package/lib/esm/Importer/common/utils.js +15 -4
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +2 -1
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +27 -7
- package/lib/esm/Importer/data/index.d.ts +7 -2
- package/lib/esm/Importer/data/index.js +18 -10
- package/lib/esm/Importer/index.d.ts +3 -2
- package/lib/esm/Importer/index.js +2 -4
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +10 -25
- package/lib/esm/common/Table/TableActions/ExportData.js +3 -1
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +37 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.d.ts +11 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +3 -1
- package/lib/esm/common/Table/TableActions/TableActions.js +2 -1
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +1 -1
- package/lib/esm/common/Table/TableActions/hooks.d.ts +20 -0
- package/lib/esm/common/Table/TableActions/hooks.js +96 -0
- package/lib/esm/common/Table/TableView/TableHeaders.d.ts +6 -8
- package/lib/esm/common/Table/TableView/TableHeaders.js +15 -14
- package/lib/esm/common/Table/TableView/{TableRow.d.ts → TableRows/TableRow.d.ts} +5 -5
- package/lib/esm/common/Table/TableView/{TableRow.js → TableRows/TableRow.js} +9 -6
- package/lib/esm/common/Table/TableView/TableRows/index.d.ts +4 -0
- package/lib/esm/common/Table/TableView/{TableCells.js → TableRows/index.js} +13 -11
- package/lib/esm/common/Table/TableView/common/index.d.ts +5 -0
- package/lib/esm/common/Table/TableView/{common.js → common/index.js} +18 -5
- package/lib/esm/common/Table/TableView/index.d.ts +4 -39
- package/lib/esm/common/Table/TableView/index.js +48 -65
- package/lib/esm/common/Table/TableView/types.d.ts +37 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/index.d.ts +2 -2
- package/lib/esm/common/Table/index.js +20 -16
- package/lib/esm/common/columnsValidations.d.ts +45 -0
- package/lib/esm/common/columnsValidations.js +351 -0
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/inputs/Autocomplete.d.ts +2 -1
- package/lib/esm/common/inputs/Autocomplete.js +2 -2
- package/lib/esm/common/inputs/SelectMenu.d.ts +1 -1
- package/lib/esm/common/inputs/SelectMenu.js +17 -9
- package/lib/esm/index.d.ts +4 -1
- package/lib/esm/index.js +56 -10
- package/lib/esm/locales/de.d.ts +20 -0
- package/lib/esm/locales/de.js +20 -0
- package/lib/esm/locales/en.d.ts +20 -0
- package/lib/esm/locales/en.js +20 -0
- package/lib/esm/locales/es.d.ts +20 -0
- package/lib/esm/locales/es.js +20 -0
- package/lib/esm/locales/fr.d.ts +20 -0
- package/lib/esm/locales/fr.js +20 -0
- package/lib/esm/types.d.ts +53 -1
- package/lib/esm/types.js +31 -0
- package/lib/esm/utils/index.d.ts +10 -0
- package/lib/esm/utils/index.js +31 -0
- package/lib/main.js +23 -23
- package/package.json +3 -2
- package/lib/esm/Importer/useFullscreenOverlay.d.ts +0 -1
- package/lib/esm/Importer/useFullscreenOverlay.js +0 -14
- package/lib/esm/common/Table/TableView/TableCells.d.ts +0 -4
- package/lib/esm/common/Table/TableView/common.d.ts +0 -9
|
@@ -25,24 +25,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import { useTranslation } from "react-i18next";
|
|
28
29
|
import styled, { css } from "styled-components";
|
|
29
30
|
import { Div } from "../../../styled/utils";
|
|
30
|
-
import { chevronDown as chevronDownIcon } from "../icons";
|
|
31
31
|
import { SortDirection } from "../TableDataProvider";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
export var TableViewHeader = styled(TableViewCellContainer)(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export var SortIndicator = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"], ["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"])), function (p) {
|
|
38
|
-
return p.direction === SortDirection.asc && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-top: 3px;\n transform: rotate(180deg);\n "], ["\n margin-top: 3px;\n transform: rotate(180deg);\n "])));
|
|
32
|
+
import { chevronDown as chevronDownIcon } from "../icons";
|
|
33
|
+
import { TableViewCellContainer, defaultTableHeaderHeightPx, getColumnWidthsPx, } from "./common";
|
|
34
|
+
export var TableViewHeader = styled(TableViewCellContainer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom: none;\n box-shadow: inset 0 -1px 0 ", ";\n background-color: ", ";\n ", ";\n color: ", ";\n"], ["\n border-bottom: none;\n box-shadow: inset 0 -1px 0 ", ";\n background-color: ", ";\n ", ";\n color: ", ";\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.css.body2; }, function (p) { return p.theme.colors.text; });
|
|
35
|
+
export var SortIndicator = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"], ["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"])), function (p) {
|
|
36
|
+
return p.direction === SortDirection.asc && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-top: 3px;\n transform: rotate(180deg);\n "], ["\n margin-top: 3px;\n transform: rotate(180deg);\n "])));
|
|
39
37
|
}, function (p) { return p.theme.colors.gray300; });
|
|
40
|
-
export var TableHeadersContainer = styled(Div)(
|
|
41
|
-
export var TableHeadersContent = styled(Div)(
|
|
38
|
+
export var TableHeadersContainer = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n overflow-x: hidden;\n background-color: ", ";\n"], ["\n overflow-x: hidden;\n background-color: ", ";\n"])), function (p) { return p.theme.colors.tableHeader; });
|
|
39
|
+
export var TableHeadersContent = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n /* We may add some padding-right here \n since TableHeadersContainer has overflow-x: hidden */\n /* Table header scrolling is controlled by the table content,\n we need to add some padding to cover the width of the vertical scrollbars that may \n be present in the table content. Scrollbars can vary between browsers and OSes,\n Assuming scrollbars won't be wider than 100px: */\n box-shadow: inset 0 -1px 0 ", ";\n padding-right: 100px;\n"], ["\n /* We may add some padding-right here \n since TableHeadersContainer has overflow-x: hidden */\n /* Table header scrolling is controlled by the table content,\n we need to add some padding to cover the width of the vertical scrollbars that may \n be present in the table content. Scrollbars can vary between browsers and OSes,\n Assuming scrollbars won't be wider than 100px: */\n box-shadow: inset 0 -1px 0 ", ";\n padding-right: 100px;\n"])), function (p) { return p.theme.colors.gray300; });
|
|
42
40
|
export var TableHeaders = function (_a) {
|
|
43
|
-
var _b = _a.scrollLeft, scrollLeft = _b === void 0 ? 0 : _b, columns = _a.columns, sortBy = _a.sortBy, rowHeight = _a.rowHeight, containerRef = _a.containerRef, setSortBy = _a.setSortBy, _c = _a.
|
|
41
|
+
var _b = _a.scrollLeft, scrollLeft = _b === void 0 ? 0 : _b, columns = _a.columns, sortBy = _a.sortBy, rowHeight = _a.rowHeight, containerRef = _a.containerRef, setSortBy = _a.setSortBy, _c = _a.height, height = _c === void 0 ? defaultTableHeaderHeightPx : _c, containerWidth = _a.containerWidth, rowWidth = _a.rowWidth, props = __rest(_a, ["scrollLeft", "columns", "sortBy", "rowHeight", "containerRef", "setSortBy", "height", "containerWidth", "rowWidth"]);
|
|
44
42
|
var t = useTranslation().t;
|
|
45
|
-
return (_jsx(TableHeadersContainer, __assign({ ref: containerRef }, { children: _jsx(TableHeadersContent, __assign({ dflex: true, w:
|
|
43
|
+
return (_jsx(TableHeadersContainer, __assign({ ref: containerRef, w: containerWidth }, { children: _jsx(TableHeadersContent, __assign({ dflex: true, w: rowWidth }, { children: columns.map(function (column, index) {
|
|
46
44
|
var header = column.header, Header = column.Header;
|
|
47
45
|
var onHeaderClick = function () {
|
|
48
46
|
if (!setSortBy || column.disableSort)
|
|
@@ -62,7 +60,10 @@ export var TableHeaders = function (_a) {
|
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
};
|
|
65
|
-
|
|
63
|
+
var columnWidthPercentages = getColumnWidthsPx(columns, rowWidth);
|
|
64
|
+
var columnWidthPercentage = columnWidthPercentages[index];
|
|
65
|
+
var isLast = index === columns.length - 1;
|
|
66
|
+
return (_jsxs(TableViewHeader, __assign({ isLast: isLast, className: isLast ? "last-column" : "", w: columnWidthPercentage, onClick: onHeaderClick, h: height }, props, { children: [_jsx(_Fragment, { children: Header ? _jsx(Header, {}) : _jsx(Div, __assign({ truncateText: true }, { children: t(header) })) }), (sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === column.dataAccessor && (_jsx(SortIndicator, __assign({ direction: sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction }, { children: chevronDownIcon })))] }), index));
|
|
66
67
|
}) })) })));
|
|
67
68
|
};
|
|
68
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5
|
|
69
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TableViewProps } from "
|
|
3
|
-
import { DivCSSProps } from "
|
|
2
|
+
import { TableViewProps } from "../types";
|
|
3
|
+
import { DivCSSProps } from "../../../../styled/utils";
|
|
4
4
|
export declare const Cell: React.MemoExoticComponent<(props: any) => JSX.Element>;
|
|
5
5
|
type TableViewRowProps = {
|
|
6
6
|
isHighlighted: boolean;
|
|
7
7
|
isLast: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare const TableViewRow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("
|
|
9
|
+
export declare const TableViewRow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps & TableViewRowProps, never>;
|
|
10
10
|
type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"> & {
|
|
11
11
|
row: any;
|
|
12
|
+
rowWidth: number;
|
|
12
13
|
indexI: number;
|
|
13
14
|
isLast?: boolean;
|
|
14
15
|
getItemKey?: (row: any) => string;
|
|
15
16
|
isRowSelected?: boolean;
|
|
16
|
-
shouldHaveCustomScrollbar?: boolean;
|
|
17
17
|
} & DivCSSProps;
|
|
18
|
-
export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey,
|
|
18
|
+
export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey, rowWidth, isRowSelected, ...props }: Props) => JSX.Element;
|
|
19
19
|
export {};
|
|
@@ -28,11 +28,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
28
28
|
import React from "react";
|
|
29
29
|
import { areEqual } from "react-window";
|
|
30
30
|
import styled, { css } from "styled-components";
|
|
31
|
-
import { Div } from "
|
|
32
|
-
import {
|
|
31
|
+
import { Div } from "../../../../styled/utils";
|
|
32
|
+
import { getColumnWidthsPx, TableViewCellContainer } from "../common";
|
|
33
33
|
export var Cell = React.memo(function (props) {
|
|
34
|
-
var children = props.children,
|
|
35
|
-
return (_jsx(TableViewCellContainer, __assign({
|
|
34
|
+
var children = props.children, cellProps = __rest(props, ["children"]);
|
|
35
|
+
return (_jsx(TableViewCellContainer, __assign({}, cellProps, { children: children })));
|
|
36
36
|
}, areEqual);
|
|
37
37
|
export var TableViewRow = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: white;\n ", "\n ", "\n"], ["\n background-color: white;\n ", "\n ", "\n"])), function (p) {
|
|
38
38
|
return !p.isLast && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: inset 0 -1px 0 ", ";\n "], ["\n box-shadow: inset 0 -1px 0 ", ";\n "])), function (p) { return p.theme.colors.gray300; });
|
|
@@ -40,15 +40,18 @@ export var TableViewRow = styled(Div)(templateObject_3 || (templateObject_3 = __
|
|
|
40
40
|
return p.isHighlighted && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "], ["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "])), p.theme.colors.blue100, p.theme.colors.blue500, p.theme.colors.gray1000);
|
|
41
41
|
});
|
|
42
42
|
export var TableRow = function (_a) {
|
|
43
|
-
var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, highlightFirstRow = _a.highlightFirstRow, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b,
|
|
43
|
+
var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, highlightFirstRow = _a.highlightFirstRow, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, rowWidth = _a.rowWidth, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "highlightFirstRow", "onRowClick", "getItemKey", "rowWidth", "isRowSelected"]);
|
|
44
44
|
var isHighlighted = (indexI === 0 && highlightFirstRow) || isRowSelected;
|
|
45
45
|
return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
|
|
46
46
|
var Content = column.Content;
|
|
47
47
|
var key = getItemKey ? getItemKey(row) : "".concat(indexI);
|
|
48
48
|
var resolvedKey = "column-".concat(indexJ, "-row-").concat(key);
|
|
49
|
+
var columnWidthPercentages = getColumnWidthsPx(columns, rowWidth);
|
|
50
|
+
var columnWidthPercentage = columnWidthPercentages[indexJ];
|
|
51
|
+
var isLastColumn = indexJ === columns.length - 1;
|
|
49
52
|
return (_jsx(Cell, __assign({ row: row, onClick: onRowClick && !column.preventRowClick
|
|
50
53
|
? function () { return onRowClick(row); }
|
|
51
|
-
: null,
|
|
54
|
+
: null, isLast: isLastColumn, className: isLastColumn ? "last-column" : "", w: columnWidthPercentage }, { children: Content ? (_jsx(Content, __assign({}, row, { rowIndex: indexI }))) : (_jsx(Div, __assign({ truncateText: true }, { children: row[column.dataAccessor] || "-" }))) }), resolvedKey));
|
|
52
55
|
}) })));
|
|
53
56
|
};
|
|
54
57
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -12,24 +12,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { CSS } from "@dnd-kit/utilities";
|
|
14
14
|
import { useSortable } from "@dnd-kit/sortable";
|
|
15
|
-
import { Div } from "
|
|
15
|
+
import { Div } from "../../../../styled/utils";
|
|
16
16
|
import { TableRow } from "./TableRow";
|
|
17
17
|
import React from "react";
|
|
18
18
|
import { areEqual } from "react-window";
|
|
19
|
-
import { useSpreadsheetContext } from "
|
|
20
|
-
var
|
|
19
|
+
import { useSpreadsheetContext } from "../../../../Importer";
|
|
20
|
+
var Row = React.memo(function (_a) {
|
|
21
21
|
var _b;
|
|
22
22
|
var data = _a.data, rowIndex = _a.rowIndex, style = _a.style;
|
|
23
|
-
var items = data.items, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey
|
|
23
|
+
var items = data.items, rowWidth = data.rowWidth, isDraggable = data.isDraggable, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey;
|
|
24
24
|
var item = items[rowIndex];
|
|
25
25
|
var selectedRows = useSpreadsheetContext().selectedRows;
|
|
26
26
|
var isRowSelected = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.includes((_b = item === null || item === void 0 ? void 0 : item._meta) === null || _b === void 0 ? void 0 : _b.id);
|
|
27
|
-
|
|
27
|
+
var Container = isDraggable ? DraggableRow : Div;
|
|
28
|
+
var containerProps = { style: style };
|
|
29
|
+
if (isDraggable)
|
|
30
|
+
containerProps = __assign(__assign({}, containerProps), { item: item });
|
|
31
|
+
return (_jsx(Container, __assign({}, containerProps, { children: _jsx(TableRow, { rowWidth: rowWidth, columns: columns, onRowClick: onRowClick, highlightFirstRow: highlightFirstRow, h: rowHeight, row: item, indexI: rowIndex, isLast: rowIndex === items.length - 1, pRelative: true, getItemKey: getItemKey, isRowSelected: isRowSelected || false }) })));
|
|
28
32
|
}, areEqual);
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var items = data.items, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey;
|
|
32
|
-
var item = items[rowIndex];
|
|
33
|
+
var DraggableRow = React.memo(function (_a) {
|
|
34
|
+
var item = _a.item, baseStyle = _a.style, children = _a.children;
|
|
33
35
|
var _b = useSortable({
|
|
34
36
|
id: item.id,
|
|
35
37
|
}), listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform;
|
|
@@ -38,6 +40,6 @@ var DraggableCell = React.memo(function (_a) {
|
|
|
38
40
|
};
|
|
39
41
|
var dragAndDropHandler = __assign({}, listeners);
|
|
40
42
|
item.dragAndDropHandler = dragAndDropHandler;
|
|
41
|
-
return (_jsx(Div, __assign({ style: __assign(__assign({}, baseStyle), dragAndDropStyles), ref: setNodeRef }, { children:
|
|
43
|
+
return (_jsx(Div, __assign({ style: __assign(__assign({}, baseStyle), dragAndDropStyles), ref: setNodeRef }, { children: children })));
|
|
42
44
|
}, areEqual);
|
|
43
|
-
export {
|
|
45
|
+
export { Row, DraggableRow };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TableViewColumn } from "../types";
|
|
2
|
+
export declare const defaultTableRowHeightPx = 60;
|
|
3
|
+
export declare const defaultTableHeaderHeightPx = 60;
|
|
4
|
+
export declare const getColumnWidthsPx: (columns: TableViewColumn[], rowWidth: number) => string[];
|
|
5
|
+
export declare const TableViewCellContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps, never>;
|
|
@@ -3,16 +3,29 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import styled, { css } from "styled-components";
|
|
6
|
-
import { Div } from "
|
|
6
|
+
import { Div } from "../../../../styled/utils";
|
|
7
7
|
export var defaultTableRowHeightPx = 60;
|
|
8
8
|
export var defaultTableHeaderHeightPx = 60;
|
|
9
|
-
export var
|
|
9
|
+
export var getColumnWidthsPx = function (columns, rowWidth) {
|
|
10
|
+
var round4 = function (n) { return Number((Math.floor(n * 10000) / 10000).toFixed(4)); };
|
|
10
11
|
var totalColumnWidthCount = columns.reduce(function (sum, c) {
|
|
11
12
|
return sum + (c.width ? c.width : 1);
|
|
12
13
|
}, 0);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
var remainingPercentage = 1;
|
|
15
|
+
var percentages = columns.map(function (column, index) {
|
|
16
|
+
if (index === columns.length - 1) {
|
|
17
|
+
// for the last column, just use the remaining percentage
|
|
18
|
+
// to avoid floating point errors
|
|
19
|
+
return round4(remainingPercentage);
|
|
20
|
+
}
|
|
21
|
+
var percentage = (column.width || 1) / totalColumnWidthCount;
|
|
22
|
+
percentage = round4(percentage);
|
|
23
|
+
remainingPercentage -= percentage;
|
|
24
|
+
remainingPercentage = round4(remainingPercentage);
|
|
25
|
+
return percentage;
|
|
26
|
+
});
|
|
27
|
+
var res = percentages.map(function (p) { return Math.floor(p * rowWidth); });
|
|
28
|
+
return res.map(function (r) { return r + "px"; });
|
|
16
29
|
};
|
|
17
30
|
export var TableViewCellContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n padding-left: 16px;\n align-items: center;\n color: ", ";\n\n ", "\n ", ";\n"], ["\n display: flex;\n padding-left: 16px;\n align-items: center;\n color: ", ";\n\n ", "\n ", ";\n"])), function (p) { return p.theme.colors.textPrim; }, function (_a) {
|
|
18
31
|
var onClick = _a.onClick;
|
|
@@ -1,46 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { SortBy } from "../TableDataProvider";
|
|
4
|
-
export * from "./common";
|
|
2
|
+
import { TableViewProps } from "./types";
|
|
5
3
|
export * from "./TableHeaders";
|
|
6
|
-
export * from "./TableRow";
|
|
4
|
+
export * from "./TableRows/TableRow";
|
|
5
|
+
export * from "./common";
|
|
7
6
|
type TableViewWrapperProps = {
|
|
8
7
|
isLoading: boolean;
|
|
9
8
|
checkboxColumnWidth?: number;
|
|
10
9
|
};
|
|
11
10
|
export declare const TableViewWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableViewWrapperProps, never>;
|
|
12
|
-
export
|
|
13
|
-
header?: string;
|
|
14
|
-
Header?: (p: any) => JSX.Element;
|
|
15
|
-
Content?: (p: any) => JSX.Element;
|
|
16
|
-
dataAccessor?: string;
|
|
17
|
-
preventRowClick?: boolean;
|
|
18
|
-
disableSort?: boolean;
|
|
19
|
-
width?: number;
|
|
20
|
-
};
|
|
21
|
-
type TableSection = {
|
|
22
|
-
rowStartIndex?: number;
|
|
23
|
-
rowStopIndex?: number;
|
|
24
|
-
data?: any[];
|
|
25
|
-
};
|
|
26
|
-
export type TableViewProps = {
|
|
27
|
-
data: any[];
|
|
28
|
-
columns: TableViewColumn[];
|
|
29
|
-
sortBy?: SortBy;
|
|
30
|
-
setSortBy?: React.Dispatch<React.SetStateAction<SortBy>>;
|
|
31
|
-
isLoading?: boolean;
|
|
32
|
-
pageSize?: number;
|
|
33
|
-
highlightFirstRow?: boolean;
|
|
34
|
-
rowWidth?: number;
|
|
35
|
-
rowHeight?: number;
|
|
36
|
-
tableHeadersHeight?: number;
|
|
37
|
-
onSectionRendered?: (section: TableSection) => void;
|
|
38
|
-
onTableScroll?: (scrollTop: number) => void;
|
|
39
|
-
onRowClick?: (row: any) => void;
|
|
40
|
-
getItemKey?: (row: any) => string;
|
|
41
|
-
shouldBeDraggable?: boolean;
|
|
42
|
-
checkboxColumnWidth?: number;
|
|
43
|
-
shouldHaveCustomScrollbar?: boolean;
|
|
44
|
-
isFiltering?: boolean;
|
|
45
|
-
} & DivCSSProps;
|
|
46
|
-
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, shouldHaveCustomScrollbar, checkboxColumnWidth, isFiltering, ...props }: TableViewProps) => JSX.Element>;
|
|
11
|
+
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: TableViewProps) => JSX.Element>;
|
|
@@ -25,58 +25,55 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
28
|
+
import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
29
|
+
import React, { Fragment, useCallback, useRef } from "react";
|
|
30
30
|
import AutoSizer from "react-virtualized-auto-sizer";
|
|
31
|
+
import { FixedSizeGrid as Grid, areEqual } from "react-window";
|
|
31
32
|
import styled, { css } from "styled-components";
|
|
32
|
-
import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
33
33
|
import { Div } from "../../../styled/utils";
|
|
34
34
|
import { Spinner } from "../../Spinner";
|
|
35
|
-
import { defaultTableRowHeightPx, defaultTableHeaderHeightPx } from "./common";
|
|
36
35
|
import { TableHeaders } from "./TableHeaders";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
export * from "./common";
|
|
36
|
+
import { Row } from "./TableRows";
|
|
37
|
+
import { defaultTableHeaderHeightPx, defaultTableRowHeightPx } from "./common";
|
|
40
38
|
export * from "./TableHeaders";
|
|
41
|
-
export * from "./TableRow";
|
|
42
|
-
export
|
|
39
|
+
export * from "./TableRows/TableRow";
|
|
40
|
+
export * from "./common";
|
|
41
|
+
export var TableViewWrapper = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n box-shadow: 0 0 0 1px ", ";\n overflow: hidden;\n\n ", "\n\n // prevents clipped dropdowns\n .ReactVirtualized__Grid__innerScrollContainer {\n overflow: visible !important;\n }\n .ReactVirtualized__Table__row {\n overflow: visible !important;\n }\n\n"], ["\n ", "\n box-shadow: 0 0 0 1px ", ";\n overflow: hidden;\n\n ", "\n\n // prevents clipped dropdowns\n .ReactVirtualized__Grid__innerScrollContainer {\n overflow: visible !important;\n }\n .ReactVirtualized__Table__row {\n overflow: visible !important;\n }\n\n"])), function (p) {
|
|
43
42
|
return p.isLoading && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0.5;\n "], ["\n opacity: 0.5;\n "])));
|
|
44
43
|
}, function (p) { return p.theme.colors.gray300; }, function (_a) {
|
|
45
44
|
var checkboxColumnWidth = _a.checkboxColumnWidth;
|
|
46
45
|
return checkboxColumnWidth && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n max-width: calc(100vw - ", "px);\n "], ["\n max-width: calc(100vw - ", "px);\n "])), checkboxColumnWidth);
|
|
47
|
-
}
|
|
46
|
+
});
|
|
48
47
|
var SpinnerWrapper = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n pointer-events: none;\n z-index: 100;\n"], ["\n pointer-events: none;\n z-index: 100;\n"])));
|
|
49
48
|
var tableHeaderId = "tableHeaderId";
|
|
50
|
-
var
|
|
51
|
-
var
|
|
49
|
+
var VirtualizedGrid = styled(Grid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), function (p) { return p.theme.css.scrollbarDark; });
|
|
50
|
+
var loadingUI = (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}) })) })));
|
|
51
|
+
var buildGridStyles = function (rowWidthScalingFactor) {
|
|
52
52
|
/* using style={{ willChange: "unset" }} is important for having items
|
|
53
53
|
like backdrops with position fixed inside of the table working as
|
|
54
54
|
expected. Required for dropdowns in cells */
|
|
55
55
|
var gridStyles = {
|
|
56
56
|
outline: "none",
|
|
57
57
|
willChange: "unset",
|
|
58
|
+
boxSizing: "border-box",
|
|
58
59
|
};
|
|
59
|
-
if (
|
|
60
|
+
if (rowWidthScalingFactor === 1)
|
|
60
61
|
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "hidden", overflowY: "auto" });
|
|
61
|
-
else if (
|
|
62
|
-
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "
|
|
62
|
+
else if (rowWidthScalingFactor > 1)
|
|
63
|
+
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "auto" });
|
|
63
64
|
return gridStyles;
|
|
64
65
|
};
|
|
65
66
|
export var TableView = React.memo(function (_a) {
|
|
66
|
-
var data = _a.data, columns = _a.columns, pageSize = _a.pageSize, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.sortBy, sortBy = _c === void 0 ? { field: null, direction: null } : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.highlightFirstRow, highlightFirstRow = _e === void 0 ? false : _e, _f = _a.setSortBy, setSortBy = _f === void 0 ? null : _f, _g = _a.
|
|
67
|
-
/*
|
|
68
|
-
multiply the rowWidth by 0.95 to let the user know they can scroll
|
|
69
|
-
horizontally (will display partial column on the right)
|
|
70
|
-
*/
|
|
71
|
-
var _rowWidth = rowWidth > 1 ? rowWidth * 0.95 : rowWidth;
|
|
67
|
+
var data = _a.data, columns = _a.columns, pageSize = _a.pageSize, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.sortBy, sortBy = _c === void 0 ? { field: null, direction: null } : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.highlightFirstRow, highlightFirstRow = _e === void 0 ? false : _e, _f = _a.setSortBy, setSortBy = _f === void 0 ? null : _f, _g = _a.rowWidthScalingFactor, rowWidthScalingFactor = _g === void 0 ? 1 : _g, onSectionRendered = _a.onSectionRendered, _h = _a.tableHeadersHeight, tableHeadersHeight = _h === void 0 ? defaultTableHeaderHeightPx : _h, _j = _a.rowHeight, rowHeight = _j === void 0 ? defaultTableRowHeightPx : _j, _k = _a.h, h = _k === void 0 ? 500 : _k, _l = _a.onTableScroll, onTableScroll = _l === void 0 ? null : _l, _m = _a.getItemKey, getItemKey = _m === void 0 ? null : _m, _o = _a.isDraggable, isDraggable = _o === void 0 ? false : _o, checkboxColumnWidth = _a.checkboxColumnWidth, _p = _a.isFiltering, isFiltering = _p === void 0 ? false : _p, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidthScalingFactor", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering"]);
|
|
72
68
|
var headerContainerRef = useRef();
|
|
73
|
-
var listRef = useRef();
|
|
74
|
-
var canRenderTableHeaders = isFiltering ? true : data.length > 0;
|
|
75
|
-
var tableHeadersUI = canRenderTableHeaders && (_jsx(TableHeaders, { id: tableHeaderId, containerRef: headerContainerRef, height: tableHeadersHeight, rowHeight: rowHeight, rowWidth: _rowWidth, scrollLeft: 0, columns: columns, sortBy: sortBy, setSortBy: setSortBy, shouldHaveCustomScrollbar: shouldHaveCustomScrollbar }));
|
|
76
69
|
var onScroll = function (_a) {
|
|
77
70
|
var scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
|
|
78
71
|
if (headerContainerRef.current && headerContainerRef.current.scrollTo) {
|
|
79
|
-
|
|
72
|
+
requestAnimationFrame(function () {
|
|
73
|
+
headerContainerRef.current.scrollTo({
|
|
74
|
+
left: scrollLeft,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
80
77
|
}
|
|
81
78
|
if (onTableScroll) {
|
|
82
79
|
onTableScroll(scrollTop);
|
|
@@ -92,56 +89,42 @@ export var TableView = React.memo(function (_a) {
|
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
91
|
}, [data, onSectionRendered]);
|
|
95
|
-
var loadingUI = isLoading && (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}) })) })));
|
|
96
92
|
var tableHeight = pageSize
|
|
97
93
|
? pageSize * rowHeight + tableHeadersHeight
|
|
98
94
|
: h;
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
rowHeight: rowHeight,
|
|
105
|
-
getItemKey: getItemKey,
|
|
106
|
-
shouldHaveCustomScrollbar: shouldHaveCustomScrollbar,
|
|
107
|
-
}); }, [
|
|
108
|
-
data,
|
|
109
|
-
onRowClick,
|
|
110
|
-
columns,
|
|
111
|
-
highlightFirstRow,
|
|
112
|
-
rowHeight,
|
|
113
|
-
shouldHaveCustomScrollbar,
|
|
114
|
-
]);
|
|
115
|
-
var buildGridProps = function (width, isDraggable, columnWidth, height) { return ({
|
|
116
|
-
style: buildGridStyles(_rowWidth),
|
|
117
|
-
width: width,
|
|
118
|
-
columnCount: 1,
|
|
119
|
-
itemData: itemData,
|
|
120
|
-
onItemsRendered: onItemsRendered,
|
|
121
|
-
onScroll: onScroll,
|
|
122
|
-
columnWidth: isDraggable ? Math.floor(width * _rowWidth) : columnWidth,
|
|
123
|
-
height: height - tableHeadersHeight,
|
|
124
|
-
rowHeight: rowHeight,
|
|
125
|
-
rowCount: data.length,
|
|
126
|
-
}); };
|
|
127
|
-
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading, checkboxColumnWidth: checkboxColumnWidth }, (!shouldHaveCustomScrollbar ? { h: tableHeight } : {}), props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
128
|
-
var width = _a.width, height = _a.height;
|
|
129
|
-
var canUseCustomScrollbar = shouldHaveCustomScrollbar && !shouldBeDraggable;
|
|
95
|
+
var canRenderTableHeaders = isFiltering ? true : data.length > 0;
|
|
96
|
+
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading, checkboxColumnWidth: checkboxColumnWidth, h: tableHeight }, props, { children: [isLoading && loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
97
|
+
var autosizerWidth = _a.width, autosizerHeight = _a.height;
|
|
98
|
+
// using Math.floor to avoid floating point errors with the grid and table cell widths
|
|
99
|
+
var rowWidth = Math.floor(autosizerWidth * rowWidthScalingFactor);
|
|
130
100
|
var gridProps = {
|
|
131
|
-
|
|
132
|
-
|
|
101
|
+
itemData: {
|
|
102
|
+
items: data,
|
|
103
|
+
isDraggable: isDraggable,
|
|
104
|
+
rowWidth: rowWidth,
|
|
105
|
+
onRowClick: onRowClick,
|
|
106
|
+
columns: columns,
|
|
107
|
+
highlightFirstRow: highlightFirstRow,
|
|
108
|
+
rowHeight: rowHeight,
|
|
109
|
+
getItemKey: getItemKey,
|
|
110
|
+
},
|
|
111
|
+
style: buildGridStyles(rowWidthScalingFactor),
|
|
112
|
+
width: autosizerWidth,
|
|
133
113
|
columnCount: 1,
|
|
134
|
-
itemData: itemData,
|
|
135
114
|
onItemsRendered: onItemsRendered,
|
|
136
115
|
onScroll: onScroll,
|
|
137
|
-
columnWidth:
|
|
138
|
-
height:
|
|
116
|
+
columnWidth: rowWidth,
|
|
117
|
+
height: autosizerHeight - tableHeadersHeight,
|
|
139
118
|
rowHeight: rowHeight,
|
|
140
119
|
rowCount: data.length,
|
|
141
120
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
var GridContainer = isDraggable
|
|
122
|
+
? SortableContext
|
|
123
|
+
: Fragment;
|
|
124
|
+
var gridContainerProps = isDraggable
|
|
125
|
+
? { items: data, strategy: verticalListSortingStrategy }
|
|
126
|
+
: {};
|
|
127
|
+
return (_jsxs(_Fragment, { children: [canRenderTableHeaders && (_jsx(TableHeaders, { rowWidth: rowWidth, containerWidth: autosizerWidth, id: tableHeaderId, containerRef: headerContainerRef, height: tableHeadersHeight, rowHeight: rowHeight, scrollLeft: 0, columns: columns, sortBy: sortBy, setSortBy: setSortBy })), _jsx(GridContainer, __assign({}, gridContainerProps, { children: _jsx(VirtualizedGrid, __assign({}, gridProps, { children: Row })) }))] }));
|
|
145
128
|
} })] })));
|
|
146
129
|
}, areEqual);
|
|
147
130
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DivCSSProps } from "../../../styled/utils";
|
|
3
|
+
import { SortBy } from "../TableDataProvider";
|
|
4
|
+
export type TableViewColumn = {
|
|
5
|
+
header?: string;
|
|
6
|
+
Header?: (p: any) => JSX.Element;
|
|
7
|
+
Content?: (p: any) => JSX.Element;
|
|
8
|
+
dataAccessor?: string;
|
|
9
|
+
preventRowClick?: boolean;
|
|
10
|
+
disableSort?: boolean;
|
|
11
|
+
width?: number;
|
|
12
|
+
};
|
|
13
|
+
type TableSection = {
|
|
14
|
+
rowStartIndex?: number;
|
|
15
|
+
rowStopIndex?: number;
|
|
16
|
+
data?: any[];
|
|
17
|
+
};
|
|
18
|
+
export type TableViewProps = {
|
|
19
|
+
data: any[];
|
|
20
|
+
columns: TableViewColumn[];
|
|
21
|
+
sortBy?: SortBy;
|
|
22
|
+
setSortBy?: React.Dispatch<React.SetStateAction<SortBy>>;
|
|
23
|
+
isLoading?: boolean;
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
highlightFirstRow?: boolean;
|
|
26
|
+
rowWidthScalingFactor?: number;
|
|
27
|
+
rowHeight?: number;
|
|
28
|
+
tableHeadersHeight?: number;
|
|
29
|
+
onSectionRendered?: (section: TableSection) => void;
|
|
30
|
+
onTableScroll?: (scrollTop: number) => void;
|
|
31
|
+
onRowClick?: (row: any) => void;
|
|
32
|
+
getItemKey?: (row: any) => string;
|
|
33
|
+
isDraggable?: boolean;
|
|
34
|
+
checkboxColumnWidth?: number;
|
|
35
|
+
isFiltering?: boolean;
|
|
36
|
+
} & DivCSSProps;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,8 @@ type Props = {
|
|
|
4
4
|
columns: any[];
|
|
5
5
|
onRowClick?: (row: any) => void;
|
|
6
6
|
templateSlug?: string;
|
|
7
|
-
|
|
7
|
+
isDraggable?: boolean;
|
|
8
8
|
} & DivCSSProps;
|
|
9
|
-
declare const Table: ({ columns, onRowClick, blankState, templateSlug,
|
|
9
|
+
declare const Table: ({ columns, onRowClick, blankState, templateSlug, isDraggable, ...props }: Props) => JSX.Element;
|
|
10
10
|
export { Table };
|
|
11
11
|
export * from "./TableDataProvider";
|
|
@@ -71,11 +71,13 @@ import { useTableContext } from "./TableDataProvider";
|
|
|
71
71
|
import { TableView as TableViewBase } from "./TableView";
|
|
72
72
|
import { useReorderRows } from "./useReorderRows";
|
|
73
73
|
import { addToast } from "../../common/Toast";
|
|
74
|
-
var
|
|
75
|
-
|
|
74
|
+
var TableContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow-x: auto;\n width: calc(100% + 2px);\n ", ";\n"], ["\n overflow-x: auto;\n width: calc(100% + 2px);\n ", ";\n"])), function (p) { return p.theme.css.scrollbarDark; });
|
|
75
|
+
var TableWrapper = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n min-width: 1000px;\n border: solid 1px ", ";\n"], ["\n min-width: 1000px;\n border: solid 1px ", ";\n"])), function (p) { return p.theme.colors.gray300; });
|
|
76
|
+
var TableView = styled(TableViewBase)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (p) {
|
|
77
|
+
return p.withPagination && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n border-radius: 0px;\n "], ["\n border-radius: 0px;\n "])));
|
|
76
78
|
});
|
|
77
79
|
var Table = function (_a) {
|
|
78
|
-
var columns = _a.columns, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.blankState, blankState = _c === void 0 ? null : _c, templateSlug = _a.templateSlug, _d = _a.
|
|
80
|
+
var columns = _a.columns, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.blankState, blankState = _c === void 0 ? null : _c, templateSlug = _a.templateSlug, _d = _a.isDraggable, isDraggable = _d === void 0 ? false : _d, props = __rest(_a, ["columns", "onRowClick", "blankState", "templateSlug", "isDraggable"]);
|
|
79
81
|
var _e = useTableContext(), data = _e.data, isLoading = _e.isLoading, sortBy = _e.sortBy, setSortBy = _e.setSortBy, totalPages = _e.totalPages;
|
|
80
82
|
var reorderRows = useReorderRows(templateSlug).reorderRows;
|
|
81
83
|
var withPagination = data.length > 0 && totalPages > 1;
|
|
@@ -115,22 +117,24 @@ var Table = function (_a) {
|
|
|
115
117
|
});
|
|
116
118
|
}); };
|
|
117
119
|
var dndContextValues = {
|
|
118
|
-
sensors:
|
|
119
|
-
collisionDetection:
|
|
120
|
-
onDragEnd:
|
|
121
|
-
modifiers:
|
|
120
|
+
sensors: isDraggable ? sensors : undefined,
|
|
121
|
+
collisionDetection: isDraggable ? closestCenter : undefined,
|
|
122
|
+
onDragEnd: isDraggable ? handleDragEnd : undefined,
|
|
123
|
+
modifiers: isDraggable
|
|
122
124
|
? [restrictToVerticalAxis, restrictToWindowEdges]
|
|
123
125
|
: undefined,
|
|
124
126
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
var Container = data.length > 0 ? TableContainer : Div;
|
|
128
|
+
var Wrapper = data.length > 0 ? TableWrapper : Div;
|
|
129
|
+
return (_jsx(Container, { children: _jsx(Wrapper, { children: _jsxs(Div, __assign({}, props, { children: [data.length ? (_jsx(DndContext, __assign({ sensors: dndContextValues.sensors, collisionDetection: dndContextValues.collisionDetection, onDragEnd: dndContextValues.onDragEnd, modifiers: dndContextValues.modifiers }, { children: _jsx(TableView, __assign({ pageSize: data.length, withPagination: withPagination, isDraggable: isDraggable }, {
|
|
130
|
+
isLoading: isLoading,
|
|
131
|
+
data: data,
|
|
132
|
+
columns: columns,
|
|
133
|
+
sortBy: sortBy,
|
|
134
|
+
setSortBy: setSortBy,
|
|
135
|
+
onRowClick: onRowClick,
|
|
136
|
+
})) }))) : (blankState), paginationUI] })) }) }));
|
|
133
137
|
};
|
|
134
138
|
export { Table };
|
|
135
139
|
export * from "./TableDataProvider";
|
|
136
|
-
var templateObject_1, templateObject_2;
|
|
140
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ColumnRequiredProps, ValidationOptionKeys, ValidationTypes } from "../types";
|
|
2
|
+
export type ValidationOption = {
|
|
3
|
+
type: "text" | "number" | "date";
|
|
4
|
+
key: ValidationOptionKeys;
|
|
5
|
+
tooltip: string;
|
|
6
|
+
};
|
|
7
|
+
export type Validation = {
|
|
8
|
+
value: ValidationTypes;
|
|
9
|
+
label: string;
|
|
10
|
+
isDefaultValidation?: boolean;
|
|
11
|
+
options?: ValidationOption[];
|
|
12
|
+
};
|
|
13
|
+
export declare const validationsByColumnType: {
|
|
14
|
+
[key: string]: Validation[];
|
|
15
|
+
};
|
|
16
|
+
export declare const validationsByType: {};
|
|
17
|
+
export declare const availableColumnTypes: string[];
|
|
18
|
+
export declare const datePatterns: {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
export declare const dateTimePatterns: {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
export declare const timePatterns: {
|
|
27
|
+
value: string;
|
|
28
|
+
label: string;
|
|
29
|
+
}[];
|
|
30
|
+
export declare const allowedPatterns: {
|
|
31
|
+
date: {
|
|
32
|
+
value: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}[];
|
|
35
|
+
datetime: {
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
}[];
|
|
39
|
+
time: {
|
|
40
|
+
value: string;
|
|
41
|
+
label: string;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
export declare const patternsColumnTypes: string[];
|
|
45
|
+
export declare const validateColumn: <T extends "string" | "boolean" | "time" | "integer" | "float" | "email" | "url" | "enum" | "date" | "datetime">(columnData: ColumnRequiredProps<T>) => Promise<void>;
|