fuse-importer 0.0.8-testing → 0.1.1-testing
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/ImporterWithContext.js +63 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +68 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +58 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.js +21 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +23 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +61 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +55 -0
- package/lib/esm/Importer/Matcher/common/icons/index.js +14 -0
- package/lib/esm/Importer/Matcher/common/index.js +39 -0
- package/lib/esm/Importer/Matcher/common/types.js +9 -0
- package/lib/esm/Importer/Matcher/index.js +22 -0
- package/lib/esm/Importer/PreviewFirstTime.js +81 -0
- package/lib/esm/Importer/PreviewModeBanner.js +19 -0
- package/lib/esm/Importer/Review/AppResponseModal.js +35 -0
- package/lib/esm/Importer/Review/ReviewContextProvider.js +318 -0
- package/lib/esm/Importer/Review/ReviewWithContext.js +33 -0
- package/lib/esm/Importer/Review/index.js +4 -0
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +24 -0
- package/lib/esm/Importer/Stepper/Step.js +19 -0
- package/lib/esm/Importer/Stepper/StepIndex.js +27 -0
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +24 -0
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +31 -0
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +33 -0
- package/lib/esm/Importer/Stepper/common/icons.js +18 -0
- package/lib/esm/Importer/Stepper/index.js +118 -0
- package/lib/esm/Importer/TrialModeBanner.js +22 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/DragAndDropImporter.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +123 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/ImporterSectionHeader.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +44 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.js +14 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +45 -0
- package/lib/esm/Importer/Uploader/HeaderButtons.js +28 -0
- package/lib/esm/Importer/Uploader/HeadersPreview.js +44 -0
- package/lib/esm/Importer/Uploader/UploaderContextProvider.js +27 -0
- package/lib/esm/Importer/Uploader/index.js +13 -0
- package/lib/esm/Importer/common/AppLoading.js +24 -0
- package/lib/esm/Importer/common/Footer.js +17 -0
- package/lib/esm/Importer/common/FuseApi.js +48 -0
- package/lib/esm/Importer/common/GlobalStyle.js +7 -0
- package/lib/esm/Importer/common/ImporterFonts.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +56 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +176 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +66 -0
- package/lib/esm/Importer/common/Spreadsheet/components/GlobalStyle.js +9 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +110 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +186 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +55 -0
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +19 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +43 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +74 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +114 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.d.ts +11 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.js +29 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/Boolean.js +18 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.js +30 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/FloatInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/IntegerInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/StringInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +20 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +245 -0
- package/lib/esm/Importer/common/Spreadsheet/index.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/styles.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +47 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +236 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +202 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +181 -0
- package/lib/esm/Importer/common/icons/index.js +18 -0
- package/lib/esm/Importer/common/index.js +13 -0
- package/lib/esm/Importer/common/theme.js +19 -0
- package/lib/esm/Importer/common/utils.js +100 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +247 -0
- package/lib/esm/Importer/data/index.js +172 -0
- package/lib/esm/Importer/index.js +28 -0
- package/lib/esm/api/index.js +93 -0
- package/lib/esm/api/responseHandlers.js +49 -0
- package/lib/esm/common/AppLoadingContextProvider/AppLoadingUI.js +26 -0
- package/lib/esm/common/AppLoadingContextProvider/index.js +25 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Modal.js +31 -0
- package/lib/esm/common/Spinner.js +41 -0
- package/lib/esm/common/Table/Pagination/icons.js +42 -0
- package/lib/esm/common/Table/Pagination/index.js +32 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +50 -0
- package/lib/esm/common/Table/TableActions/ExportData.js +23 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +47 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +72 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +35 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +18 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +83 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/hooks.js +41 -0
- package/lib/esm/common/Table/TableActions/icons.js +17 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableDataProvider.js +127 -0
- package/lib/esm/common/Table/TableView/TableHeaders.js +69 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +57 -0
- package/lib/esm/common/Table/TableView/TableRows/index.js +48 -0
- package/lib/esm/common/Table/TableView/common/index.js +37 -0
- package/lib/esm/common/Table/TableView/index.js +132 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/icons.js +15 -0
- package/lib/esm/common/Table/index.js +140 -0
- package/lib/esm/common/Table/useReorderRows.js +83 -0
- package/lib/esm/common/Toast.js +69 -0
- package/lib/esm/common/TooltipProvider.js +57 -0
- package/lib/esm/common/buttons.js +97 -0
- package/lib/esm/common/columnsTransformations.js +94 -0
- package/lib/esm/common/columnsValidations.d.ts +1 -27
- package/lib/esm/common/columnsValidations.js +401 -0
- package/lib/esm/common/datePatterns.d.ts +26 -0
- package/lib/esm/common/datePatterns.js +327 -0
- package/lib/esm/common/icons/index.js +30 -0
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +46 -0
- package/lib/esm/common/inputs/Autocomplete.js +110 -0
- package/lib/esm/common/inputs/Checkbox.js +53 -0
- package/lib/esm/common/inputs/SelectMenu.js +74 -0
- package/lib/esm/common/inputs/TextInput.js +89 -0
- package/lib/esm/common/inputs/index.js +5 -0
- package/lib/esm/common/inputs/tooltip.js +38 -0
- package/lib/esm/common/logo.js +13 -0
- package/lib/esm/hooks/index.d.ts +1 -0
- package/lib/esm/hooks/index.js +16 -0
- package/lib/esm/index.js +218 -0
- package/lib/esm/locales/de.js +126 -0
- package/lib/esm/locales/en.js +126 -0
- package/lib/esm/locales/es.js +126 -0
- package/lib/esm/locales/fr.js +126 -0
- package/lib/esm/locales/index.js +4 -0
- package/lib/esm/styled/fontsURL.js +27 -0
- package/lib/esm/styled/index.js +3 -0
- package/lib/esm/styled/theme/animations.js +9 -0
- package/lib/esm/styled/theme/colorPalette.js +109 -0
- package/lib/esm/styled/theme/debugCss.js +16 -0
- package/lib/esm/styled/theme/dimensionsCss.js +20 -0
- package/lib/esm/styled/theme/fontCss.js +17 -0
- package/lib/esm/styled/theme/globalCss.js +26 -0
- package/lib/esm/styled/theme/index.js +33 -0
- package/lib/esm/styled/theme/layoutCss.js +26 -0
- package/lib/esm/styled/theme/mediaQueries.js +4 -0
- package/lib/esm/styled/theme/positionCss.js +27 -0
- package/lib/esm/styled/theme/textCss.js +18 -0
- package/lib/esm/styled/theme/textStyles.js +27 -0
- package/lib/esm/styled/themeType.js +6 -0
- package/lib/esm/styled/utils.js +17 -0
- package/lib/esm/types.d.ts +7 -6
- package/lib/esm/types.js +65 -0
- package/lib/esm/utils/hooks/useWindowSize.js +23 -0
- package/lib/esm/utils/hooks.js +1 -0
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +41 -0
- package/lib/main.js +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled, { css } from "styled-components";
|
|
6
|
+
import { Div } from "../../../../styled/utils";
|
|
7
|
+
export var defaultTableRowHeightPx = 60;
|
|
8
|
+
export var defaultTableHeaderHeightPx = 60;
|
|
9
|
+
export var getColumnWidthsPx = function (columns, rowWidth) {
|
|
10
|
+
var round4 = function (n) { return Number((Math.floor(n * 10000) / 10000).toFixed(4)); };
|
|
11
|
+
var totalColumnWidthCount = columns.reduce(function (sum, c) {
|
|
12
|
+
return sum + (c.width ? c.width : 1);
|
|
13
|
+
}, 0);
|
|
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"; });
|
|
29
|
+
};
|
|
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) {
|
|
31
|
+
var onClick = _a.onClick;
|
|
32
|
+
return onClick && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n :hover {\n cursor: pointer;\n }\n "], ["\n :hover {\n cursor: pointer;\n }\n "])));
|
|
33
|
+
}, function (_a) {
|
|
34
|
+
var theme = _a.theme;
|
|
35
|
+
return theme.css.body3;
|
|
36
|
+
});
|
|
37
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
29
|
+
import React, { Fragment, useCallback, useRef } from "react";
|
|
30
|
+
import AutoSizer from "react-virtualized-auto-sizer";
|
|
31
|
+
import { FixedSizeGrid as Grid, areEqual } from "react-window";
|
|
32
|
+
import styled, { css } from "styled-components";
|
|
33
|
+
import { Div } from "../../../styled/utils";
|
|
34
|
+
import { Spinner } from "../../Spinner";
|
|
35
|
+
import { TableHeaders } from "./TableHeaders";
|
|
36
|
+
import { Row } from "./TableRows";
|
|
37
|
+
import { defaultTableHeaderHeightPx, defaultTableRowHeightPx } from "./common";
|
|
38
|
+
export * from "./TableHeaders";
|
|
39
|
+
export * from "./TableRows/TableRow";
|
|
40
|
+
export * from "./common";
|
|
41
|
+
export var TableViewWrapper = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n ", "\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 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"])), function (p) {
|
|
42
|
+
return p.isLoading && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0.5;\n "], ["\n opacity: 0.5;\n "])));
|
|
43
|
+
}, function (p) {
|
|
44
|
+
return !p.isLoading && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 0 0 0 1px ", ";\n "], ["\n box-shadow: 0 0 0 1px ", ";\n "])), function (p) { return p.theme.colors.gray300; });
|
|
45
|
+
}, function (_a) {
|
|
46
|
+
var checkboxColumnWidth = _a.checkboxColumnWidth;
|
|
47
|
+
return checkboxColumnWidth && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n max-width: calc(100vw - ", "px);\n "], ["\n max-width: calc(100vw - ", "px);\n "])), checkboxColumnWidth);
|
|
48
|
+
});
|
|
49
|
+
var SpinnerWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n pointer-events: none;\n z-index: 100;\n"], ["\n pointer-events: none;\n z-index: 100;\n"])));
|
|
50
|
+
var tableHeaderId = "tableHeaderId";
|
|
51
|
+
var VirtualizedGrid = styled(Grid)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), function (p) { return p.theme.css.scrollbarDark; });
|
|
52
|
+
var loadingUI = (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}) })) })));
|
|
53
|
+
var buildGridStyles = function (rowWidthScalingFactor) {
|
|
54
|
+
/* using style={{ willChange: "unset" }} is important for having items
|
|
55
|
+
like backdrops with position fixed inside of the table working as
|
|
56
|
+
expected. Required for dropdowns in cells */
|
|
57
|
+
var gridStyles = {
|
|
58
|
+
outline: "none",
|
|
59
|
+
willChange: "unset",
|
|
60
|
+
boxSizing: "border-box",
|
|
61
|
+
};
|
|
62
|
+
if (rowWidthScalingFactor === 1)
|
|
63
|
+
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "hidden", overflowY: "auto" });
|
|
64
|
+
else if (rowWidthScalingFactor > 1)
|
|
65
|
+
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "auto" });
|
|
66
|
+
return gridStyles;
|
|
67
|
+
};
|
|
68
|
+
export var TableView = React.memo(function (_a) {
|
|
69
|
+
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.setSortBy, setSortBy = _e === void 0 ? null : _e, _f = _a.rowWidthScalingFactor, rowWidthScalingFactor = _f === void 0 ? 1 : _f, onSectionRendered = _a.onSectionRendered, _g = _a.tableHeadersHeight, tableHeadersHeight = _g === void 0 ? defaultTableHeaderHeightPx : _g, _h = _a.rowHeight, rowHeight = _h === void 0 ? defaultTableRowHeightPx : _h, _j = _a.h, h = _j === void 0 ? 500 : _j, _k = _a.onTableScroll, onTableScroll = _k === void 0 ? null : _k, _l = _a.getItemKey, getItemKey = _l === void 0 ? null : _l, _m = _a.isDraggable, isDraggable = _m === void 0 ? false : _m, checkboxColumnWidth = _a.checkboxColumnWidth, _o = _a.isFiltering, isFiltering = _o === void 0 ? false : _o, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "setSortBy", "rowWidthScalingFactor", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering"]);
|
|
70
|
+
var headerContainerRef = useRef();
|
|
71
|
+
var onScroll = function (_a) {
|
|
72
|
+
var scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
|
|
73
|
+
if (headerContainerRef.current && headerContainerRef.current.scrollTo) {
|
|
74
|
+
requestAnimationFrame(function () {
|
|
75
|
+
var _a;
|
|
76
|
+
(_a = headerContainerRef === null || headerContainerRef === void 0 ? void 0 : headerContainerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
77
|
+
left: scrollLeft,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (onTableScroll) {
|
|
82
|
+
onTableScroll(scrollTop);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var onItemsRendered = useCallback(function (_a) {
|
|
86
|
+
var rowStartIndex = _a.overscanRowStartIndex, rowStopIndex = _a.overscanRowStopIndex;
|
|
87
|
+
if (onSectionRendered) {
|
|
88
|
+
onSectionRendered({
|
|
89
|
+
rowStartIndex: rowStartIndex,
|
|
90
|
+
rowStopIndex: rowStopIndex,
|
|
91
|
+
data: data.slice(rowStartIndex, rowStopIndex + 1),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, [data, onSectionRendered]);
|
|
95
|
+
var tableHeight = pageSize
|
|
96
|
+
? pageSize * rowHeight + tableHeadersHeight
|
|
97
|
+
: h;
|
|
98
|
+
var canRenderTableHeaders = isFiltering ? true : data.length > 0;
|
|
99
|
+
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) {
|
|
100
|
+
var autosizerWidth = _a.width, autosizerHeight = _a.height;
|
|
101
|
+
// using Math.floor to avoid floating point errors with the grid and table cell widths
|
|
102
|
+
var rowWidth = Math.floor(autosizerWidth * rowWidthScalingFactor);
|
|
103
|
+
var gridProps = {
|
|
104
|
+
itemData: {
|
|
105
|
+
items: data,
|
|
106
|
+
isDraggable: isDraggable,
|
|
107
|
+
rowWidth: rowWidth,
|
|
108
|
+
onRowClick: onRowClick,
|
|
109
|
+
columns: columns,
|
|
110
|
+
rowHeight: rowHeight,
|
|
111
|
+
getItemKey: getItemKey,
|
|
112
|
+
},
|
|
113
|
+
style: buildGridStyles(rowWidthScalingFactor),
|
|
114
|
+
width: autosizerWidth,
|
|
115
|
+
columnCount: 1,
|
|
116
|
+
onItemsRendered: onItemsRendered,
|
|
117
|
+
onScroll: onScroll,
|
|
118
|
+
columnWidth: rowWidth,
|
|
119
|
+
height: autosizerHeight - tableHeadersHeight,
|
|
120
|
+
rowHeight: rowHeight,
|
|
121
|
+
rowCount: data.length,
|
|
122
|
+
};
|
|
123
|
+
var GridContainer = isDraggable
|
|
124
|
+
? SortableContext
|
|
125
|
+
: Fragment;
|
|
126
|
+
var gridContainerProps = isDraggable
|
|
127
|
+
? { items: data, strategy: verticalListSortingStrategy }
|
|
128
|
+
: {};
|
|
129
|
+
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 })) }))] }));
|
|
130
|
+
} })] })));
|
|
131
|
+
}, areEqual);
|
|
132
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export var chevronDown = (_jsx("svg", __assign({ width: "9", height: "5", viewBox: "0 0 9 5", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M4.31848 4.93945L0.421366 0.439453L8.2156 0.439454L4.31848 4.93945Z", fill: "#102622" }) })));
|
|
14
|
+
export var chevronRight = (_jsx("svg", __assign({ width: "6", height: "8", viewBox: "0 0 6 8", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M5.31848 4.06738L0.818482 7.9645L0.818482 0.170269L5.31848 4.06738Z", fill: "#102622" }) })));
|
|
15
|
+
export var spreedSheetIcon = (_jsxs("svg", __assign({ width: "376", height: "256", viewBox: "0 0 376 256", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsxs("g", __assign({ filter: "url(#filter0_d_4260_84132)" }, { children: [_jsx("rect", { x: "12", y: "8", width: "352", height: "231.997", rx: "4", fill: "white" }), _jsxs("g", __assign({ clipPath: "url(#clip0_4260_84132)" }, { children: [_jsx("path", { d: "M364 40.2222H12V236C12 238.209 13.7909 240 16 240H360C362.209 240 364 238.209 364 236V40.2222Z", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 224.239H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 208.937H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 193.655H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 178.355H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 163.052H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 147.752H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 132.47H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 117.169H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 101.867H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 86.5674H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 71.2844H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M12.1463 55.9827H364.146", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M305.004 40.6831V239.54", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M246.511 40.6831V239.54", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M188 40.6831V239.54", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M129.489 40.6831V239.54", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("path", { d: "M70.9966 40.6831V239.54", stroke: "#E6DBDB", strokeWidth: "0.5", strokeMiterlimit: "10" }), _jsx("rect", { x: "17.2543", y: "61.252", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "61.252", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "92.7949", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "105.938", width: "49.9105", height: "5.2573", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "137.482", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "153.254", width: "49.9105", height: "5.25734", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "137.482", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "153.254", width: "49.9104", height: "5.25734", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "169.026", width: "49.9104", height: "5.25732", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "184.798", width: "49.9104", height: "5.25732", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "197.942", width: "49.9104", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "213.713", width: "49.9104", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "229.485", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "121.71", width: "49.9104", height: "5.25733", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "182.169", width: "49.9104", height: "5.25733", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "182.169", width: "49.9105", height: "5.25733", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "121.71", width: "49.9105", height: "5.25733", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "58.623", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "137.482", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "197.942", width: "49.9104", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "197.942", width: "49.9105", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "137.482", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "74.3953", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "153.254", width: "49.9104", height: "5.25734", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "213.713", width: "49.9104", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "213.713", width: "49.9105", height: "5.25729", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "153.254", width: "49.9105", height: "5.25734", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "90.1672", width: "49.9105", height: "5.2573", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "169.026", width: "49.9104", height: "5.25732", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "193.253", y: "229.485", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "229.485", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "169.026", width: "49.9105", height: "5.25732", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "251.044", y: "105.938", width: "49.9105", height: "5.2573", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "45.48", width: "49.9104", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "45.48", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "75.045", y: "77.0229", width: "49.9105", height: "5.25731", rx: "1", fill: "#E6DBDB" }), _jsx("rect", { x: "17.2543", y: "121.71", width: "49.9104", height: "5.25733", rx: "1", fill: "#E6DBDB" })] }))] })), _jsx("path", { d: "M12 12.0015C12 9.79233 13.7909 8.00146 16 8.00146H360C362.209 8.00146 364 9.79233 364 12.0015V40.2237H12V12.0015Z", fill: "#00D085" }), _jsx("circle", { cx: "306.77", cy: "24.0002", r: "6", fill: "#025F40" }), _jsx("circle", { cx: "324.77", cy: "24.0002", r: "6", fill: "#025F40" }), _jsx("circle", { cx: "342.77", cy: "24.0002", r: "6", fill: "#025F40" }), _jsxs("defs", { children: [_jsxs("filter", __assign({ id: "filter0_d_4260_84132", x: "0", y: "0", width: "376", height: "256", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB" }, { children: [_jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), _jsx("feColorMatrix", { in: "SourceAlpha", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0", result: "hardAlpha" }), _jsx("feOffset", { dy: "4" }), _jsx("feGaussianBlur", { stdDeviation: "6" }), _jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" }), _jsx("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_4260_84132" }), _jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect1_dropShadow_4260_84132", result: "shape" })] })), _jsx("clipPath", __assign({ id: "clip0_4260_84132" }, { children: _jsx("path", { d: "M12 40.2222H364V236C364 238.209 362.209 240 360 240H16C13.7909 240 12 238.209 12 236V40.2222Z", fill: "white" }) }))] })] })));
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
53
|
+
var t = {};
|
|
54
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
55
|
+
t[p] = s[p];
|
|
56
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
57
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
58
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
59
|
+
t[p[i]] = s[p[i]];
|
|
60
|
+
}
|
|
61
|
+
return t;
|
|
62
|
+
};
|
|
63
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
64
|
+
import styled, { css } from "styled-components";
|
|
65
|
+
import { DndContext, useSensors, useSensor, PointerSensor, KeyboardSensor, closestCenter, } from "@dnd-kit/core";
|
|
66
|
+
import { restrictToVerticalAxis, restrictToWindowEdges, } from "@dnd-kit/modifiers";
|
|
67
|
+
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
|
68
|
+
import { Div } from "../../styled/utils";
|
|
69
|
+
import { Pagination } from "./Pagination";
|
|
70
|
+
import { useTableContext } from "./TableDataProvider";
|
|
71
|
+
import { TableView as TableViewBase } from "./TableView";
|
|
72
|
+
import { useReorderRows } from "./useReorderRows";
|
|
73
|
+
import { addToast } from "../../common/Toast";
|
|
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 "])));
|
|
78
|
+
});
|
|
79
|
+
var Table = function (_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"]);
|
|
81
|
+
var _e = useTableContext(), data = _e.data, isLoading = _e.isLoading, sortBy = _e.sortBy, setSortBy = _e.setSortBy, totalPages = _e.totalPages;
|
|
82
|
+
var reorderRows = useReorderRows(templateSlug).reorderRows;
|
|
83
|
+
var withPagination = data.length > 0 && totalPages > 1;
|
|
84
|
+
var sensors = useSensors(useSensor(PointerSensor, {
|
|
85
|
+
activationConstraint: {
|
|
86
|
+
distance: 8,
|
|
87
|
+
},
|
|
88
|
+
}), useSensor(KeyboardSensor, {
|
|
89
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
90
|
+
}));
|
|
91
|
+
var paginationUI = (_jsx(_Fragment, { children: withPagination && (_jsx(Div, __assign({ dflex: true, justifyCenter: true, pb: 50 }, { children: _jsx(Pagination, {}) }))) }));
|
|
92
|
+
var handleDragEnd = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var active, over, overIndex, overIndexIsFalsyButNotZero, error_1;
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
return __generator(this, function (_d) {
|
|
96
|
+
switch (_d.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
active = event.active, over = event.over;
|
|
99
|
+
overIndex = (_c = (_b = (_a = over === null || over === void 0 ? void 0 : over.data) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.sortable) === null || _c === void 0 ? void 0 : _c.index;
|
|
100
|
+
overIndexIsFalsyButNotZero = !overIndex && overIndex !== 0;
|
|
101
|
+
if (!(active === null || active === void 0 ? void 0 : active.id) || overIndexIsFalsyButNotZero || active.id === over.id) {
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
_d.label = 1;
|
|
105
|
+
case 1:
|
|
106
|
+
_d.trys.push([1, 3, , 4]);
|
|
107
|
+
return [4 /*yield*/, reorderRows(active.id, overIndex + 1)];
|
|
108
|
+
case 2:
|
|
109
|
+
_d.sent();
|
|
110
|
+
return [3 /*break*/, 4];
|
|
111
|
+
case 3:
|
|
112
|
+
error_1 = _d.sent();
|
|
113
|
+
addToast("Failed to reorder rows", "error");
|
|
114
|
+
return [3 /*break*/, 4];
|
|
115
|
+
case 4: return [2 /*return*/];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); };
|
|
119
|
+
var dndContextValues = {
|
|
120
|
+
sensors: isDraggable ? sensors : undefined,
|
|
121
|
+
collisionDetection: isDraggable ? closestCenter : undefined,
|
|
122
|
+
onDragEnd: isDraggable ? handleDragEnd : undefined,
|
|
123
|
+
modifiers: isDraggable
|
|
124
|
+
? [restrictToVerticalAxis, restrictToWindowEdges]
|
|
125
|
+
: undefined,
|
|
126
|
+
};
|
|
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 || isLoading ? (_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] })) }) }));
|
|
137
|
+
};
|
|
138
|
+
export { Table };
|
|
139
|
+
export * from "./TableDataProvider";
|
|
140
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import { addToast } from "..";
|
|
50
|
+
import { api } from "../../api";
|
|
51
|
+
import { Div } from "../../styled/utils";
|
|
52
|
+
import { useTableContext } from "./TableDataProvider";
|
|
53
|
+
export var useReorderRows = function (templateSlug, customMessage) {
|
|
54
|
+
var getData = useTableContext().getData;
|
|
55
|
+
var reorderRows = function (columnId, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var apiUrl, defaultMessage, confirmationMessage, error_1;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
apiUrl = "/api/v1/templates/".concat(templateSlug, "/columns/").concat(columnId);
|
|
61
|
+
defaultMessage = (_jsx(Div, __assign({ alignCenter: true }, { children: _jsx(Div, { children: "Columns reordered successfully" }) })));
|
|
62
|
+
confirmationMessage = (_jsx(Div, __assign({ spaceBetween: true, alignCenter: true }, { children: customMessage || defaultMessage })));
|
|
63
|
+
_a.label = 1;
|
|
64
|
+
case 1:
|
|
65
|
+
_a.trys.push([1, 3, , 4]);
|
|
66
|
+
return [4 /*yield*/, api.patch(apiUrl, {
|
|
67
|
+
position: position,
|
|
68
|
+
})];
|
|
69
|
+
case 2:
|
|
70
|
+
_a.sent();
|
|
71
|
+
addToast(confirmationMessage, "success");
|
|
72
|
+
getData();
|
|
73
|
+
return [3 /*break*/, 4];
|
|
74
|
+
case 3:
|
|
75
|
+
error_1 = _a.sent();
|
|
76
|
+
addToast("Failed to reorder rows", "error");
|
|
77
|
+
return [3 /*break*/, 4];
|
|
78
|
+
case 4: return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}); };
|
|
82
|
+
return { reorderRows: reorderRows };
|
|
83
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import toast, { ToastBar, Toaster, } from "react-hot-toast";
|
|
18
|
+
import styled from "styled-components";
|
|
19
|
+
import { defaultCheckIcon, greenCheckIcon, redXIcon } from "./icons";
|
|
20
|
+
import { colors } from "../styled/theme/colorPalette";
|
|
21
|
+
import { Div } from "../styled/utils";
|
|
22
|
+
var defaultDuration = 5000;
|
|
23
|
+
var defaultPosition = "bottom-right";
|
|
24
|
+
var toastBorderRadius = 4;
|
|
25
|
+
var toastMaxWidth = "85%";
|
|
26
|
+
export var addToast = function (msg, type, toastOptions) {
|
|
27
|
+
if (type === void 0) { type = "blank"; }
|
|
28
|
+
if (toastOptions === void 0) { toastOptions = {}; }
|
|
29
|
+
var _toastOptions = __assign({ duration: defaultDuration, position: defaultPosition }, toastOptions);
|
|
30
|
+
var toastFn = type === "blank" ? toast : toast[type];
|
|
31
|
+
toastFn(msg, _toastOptions);
|
|
32
|
+
};
|
|
33
|
+
var toastContainerCss = {
|
|
34
|
+
padding: 0,
|
|
35
|
+
marginRight: 72,
|
|
36
|
+
borderRadius: toastBorderRadius,
|
|
37
|
+
boxShadow: "none",
|
|
38
|
+
maxWidth: toastMaxWidth,
|
|
39
|
+
};
|
|
40
|
+
var toastTypeStyles = {
|
|
41
|
+
success: {
|
|
42
|
+
backgroundColor: colors.blue50,
|
|
43
|
+
color: colors.text,
|
|
44
|
+
icon: greenCheckIcon,
|
|
45
|
+
},
|
|
46
|
+
error: {
|
|
47
|
+
color: colors.red800,
|
|
48
|
+
backgroundColor: colors.red100,
|
|
49
|
+
icon: redXIcon,
|
|
50
|
+
},
|
|
51
|
+
blank: {
|
|
52
|
+
backgroundColor: colors.white,
|
|
53
|
+
color: colors.text,
|
|
54
|
+
icon: defaultCheckIcon,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
var ToastWrapper = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 10px;\n box-shadow: 0px 2px 8px 1px rgba(0, 0, 0, 0.1);\n border-radius: ", "px;\n ", ";\n"], ["\n padding: 10px;\n box-shadow: 0px 2px 8px 1px rgba(0, 0, 0, 0.1);\n border-radius: ", "px;\n ", ";\n"])), toastBorderRadius, function (p) { return p.theme.css.alignCenter; });
|
|
58
|
+
var Toast = function () {
|
|
59
|
+
return (_jsx(Toaster, __assign({ toastOptions: {
|
|
60
|
+
style: toastContainerCss,
|
|
61
|
+
} }, { children: function (t) { return (_jsx(ToastBar, __assign({ toast: t }, { children: function (_a) {
|
|
62
|
+
var message = _a.message, hotToastIcon = _a.icon;
|
|
63
|
+
var _b = toastTypeStyles[t.type] || {}, icon = _b.icon, color = _b.color, backgroundColor = _b.backgroundColor;
|
|
64
|
+
return (_jsxs(ToastWrapper, __assign({ c: color, bg: backgroundColor }, { children: [_jsx(Div, __assign({ alignCenter: true }, { children: icon || hotToastIcon })), _jsx(Div, __assign({ alignCenter: true }, { children: message })), _jsx(Div, __assign({ p: 5, clickable: true, onClick: function () { return toast.dismiss(t.id); } }, { children: closeIcon }))] })));
|
|
65
|
+
} }))); } })));
|
|
66
|
+
};
|
|
67
|
+
export { Toast };
|
|
68
|
+
var closeIcon = (_jsxs("svg", __assign({ width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M2.5 2.5L7.82258 7.82258", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M2.5 7.82251L7.82258 2.49993", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
69
|
+
var templateObject_1;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import { useMemo, useState } from "react";
|
|
29
|
+
import { usePopper } from "react-popper";
|
|
30
|
+
import styled from "styled-components";
|
|
31
|
+
import { Div } from "../styled/utils";
|
|
32
|
+
export var TooltipContent = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n color: ", ";\n background: ", ";\n border-radius: 4px;\n padding: 10px;\n pointer-events: none;\n z-index: 1000;\n"], ["\n ", ";\n color: ", ";\n background: ", ";\n border-radius: 4px;\n padding: 10px;\n pointer-events: none;\n z-index: 1000;\n"])), function (p) { return p.theme.css.body4; }, function (p) { return p.theme.colors.white; }, function (p) { return p.theme.colors.black; });
|
|
33
|
+
export var TooltipProvider = function (_a) {
|
|
34
|
+
var tooltip = _a.tooltip, children = _a.children, tooltipMaxWidth = _a.tooltipMaxWidth, tooltipMinWidth = _a.tooltipMinWidth, _b = _a.placement, placement = _b === void 0 ? "top-start" : _b, _c = _a.flip, flip = _c === void 0 ? true : _c, _d = _a.isDisabled, isDisabled = _d === void 0 ? false : _d, _e = _a.isOpen, isOpen = _e === void 0 ? false : _e, _f = _a.offset, offset = _f === void 0 ? [0, 4] : _f, props = __rest(_a, ["tooltip", "children", "tooltipMaxWidth", "tooltipMinWidth", "placement", "flip", "isDisabled", "isOpen", "offset"]);
|
|
35
|
+
var _g = useState(false), isDisplayingTooltip = _g[0], setIsDisplayingTooltip = _g[1];
|
|
36
|
+
var _h = useState(null), referenceElement = _h[0], setReferenceElement = _h[1];
|
|
37
|
+
var _j = useState(null), popperElement = _j[0], setPopperElement = _j[1];
|
|
38
|
+
var options = useMemo(function () { return ({
|
|
39
|
+
placement: placement,
|
|
40
|
+
modifiers: [
|
|
41
|
+
{
|
|
42
|
+
name: "offset",
|
|
43
|
+
options: {
|
|
44
|
+
offset: offset,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "flip",
|
|
49
|
+
enabled: flip,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
}); }, [placement, offset]);
|
|
53
|
+
var _k = usePopper(referenceElement, popperElement, options), styles = _k.styles, attributes = _k.attributes;
|
|
54
|
+
var showTooltip = isOpen || (isDisplayingTooltip && !!tooltip);
|
|
55
|
+
return (_jsxs(Div, __assign({ dim: "100%", ref: setReferenceElement, onMouseOver: function () { return isDisabled || setIsDisplayingTooltip(true); }, onMouseOut: function () { return isDisabled || setIsDisplayingTooltip(false); } }, props, { children: [children, showTooltip && (_jsx(TooltipContent, __assign({ ref: setPopperElement, style: styles.popper, maxw: tooltipMaxWidth, minw: tooltipMinWidth }, attributes.popper, { children: tooltip })))] })));
|
|
56
|
+
};
|
|
57
|
+
var templateObject_1;
|