fuse-importer 0.1.8-testing → 0.2.0-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 +11 -9
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +3 -3
- package/lib/esm/Importer/PreviewFirstTime.js +1 -1
- package/lib/esm/Importer/PreviewModeBanner.js +2 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +2 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.js +6 -6
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +21 -4
- package/lib/esm/Importer/Stepper/index.js +19 -17
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +1 -1
- package/lib/esm/Importer/WarningsBanner.d.ts +3 -0
- package/lib/esm/Importer/WarningsBanner.js +42 -0
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.d.ts +5 -4
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.js +104 -50
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.js +6 -1
- package/lib/esm/Importer/common/Spreadsheet/KeyboardEventContextProvider/index.d.ts +7 -0
- package/lib/esm/Importer/common/Spreadsheet/KeyboardEventContextProvider/index.js +73 -0
- package/lib/esm/Importer/common/Spreadsheet/SearchContextProvider/index.d.ts +15 -0
- package/lib/esm/Importer/common/Spreadsheet/SearchContextProvider/index.js +43 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.d.ts +3 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.js +40 -26
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +2 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.js +13 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useCellSelection.d.ts +24 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useCellSelection.js +207 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.d.ts +4 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.js +101 -24
- package/lib/esm/Importer/common/Spreadsheet/UndoRedoContextProvider/index.d.ts +16 -0
- package/lib/esm/Importer/common/Spreadsheet/UndoRedoContextProvider/index.js +104 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.js +28 -12
- package/lib/esm/Importer/common/Spreadsheet/common/index.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +13 -5
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.js +65 -15
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData/CellContextProvider.d.ts +23 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData/CellContextProvider.js +128 -0
- package/lib/esm/Importer/common/Spreadsheet/components/{SpreadsheetData.d.ts → SpreadsheetData/index.d.ts} +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/{SpreadsheetData.js → SpreadsheetData/index.js} +19 -18
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +8 -8
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +3 -4
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +8 -8
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +11 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +26 -18
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +2 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +8 -1
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +18 -5
- package/lib/esm/Importer/hooks/useSubmitToServer.d.ts +1 -1
- package/lib/esm/Importer/hooks/useSubmitToServer.js +55 -9
- package/lib/esm/common/CircleSpinner.d.ts +1 -0
- package/lib/esm/common/CircleSpinner.js +13 -0
- package/lib/esm/common/FileUploadDropzone/ImporterDropzone.js +56 -21
- package/lib/esm/common/Table/TableActions/CustomActions/CustomActions.js +28 -23
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +3 -3
- package/lib/esm/common/Table/TableActions/RowFilters.js +2 -2
- package/lib/esm/common/Table/TableActions/SearchRows.js +18 -26
- package/lib/esm/common/Table/TableActions/TableActions.js +7 -4
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +1 -1
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +3 -3
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +1 -1
- package/lib/esm/common/Table/TableView/index.d.ts +1 -1
- package/lib/esm/common/Table/TableView/index.js +2 -2
- package/lib/esm/common/Table/TableView/types.d.ts +1 -0
- package/lib/esm/common/Toast.d.ts +9 -1
- package/lib/esm/common/Toast.js +29 -8
- package/lib/esm/common/icons/index.js +3 -3
- package/lib/esm/common/inputs/Autocomplete.js +2 -2
- package/lib/esm/common/inputs/TextInput.d.ts +1 -0
- package/lib/esm/common/inputs/TextInput.js +10 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/locales/de.d.ts +10 -0
- package/lib/esm/locales/de.js +10 -0
- package/lib/esm/locales/en.d.ts +10 -0
- package/lib/esm/locales/en.js +10 -0
- package/lib/esm/locales/es.d.ts +10 -0
- package/lib/esm/locales/es.js +10 -0
- package/lib/esm/locales/fr.d.ts +10 -0
- package/lib/esm/locales/fr.js +10 -0
- package/lib/esm/types.d.ts +1 -0
- package/lib/main.js +8 -8
- package/package.json +1 -1
- package/lib/esm/Importer/TrialModeBanner.d.ts +0 -1
- package/lib/esm/Importer/TrialModeBanner.js +0 -22
|
@@ -55,10 +55,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
57
|
import { useState } from "react";
|
|
58
|
-
import { useImporterContext, } from "../contexts/ImporterContextProvider";
|
|
59
58
|
import { isRecordEmpty } from "../../Importer/common/Spreadsheet/common";
|
|
60
59
|
import { sendRecordsToIntegrations } from "../../Importer/common/utils";
|
|
61
60
|
import { getTemplateFields, recordListToDataSet } from "../../Importer/data";
|
|
61
|
+
import { addToast } from "../../common";
|
|
62
|
+
import { useImporterContext, } from "../contexts/ImporterContextProvider";
|
|
62
63
|
var trackImportedRowsCount = function (fuseApi, templateSlug, rowCount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
64
|
var error_1, errorMessage;
|
|
64
65
|
var _a, _b;
|
|
@@ -82,21 +83,41 @@ var trackImportedRowsCount = function (fuseApi, templateSlug, rowCount) { return
|
|
|
82
83
|
});
|
|
83
84
|
}); };
|
|
84
85
|
var buildColumnMappingsFromHeaderMatchings = function (templateHeaders, templateHeaderMatchings) {
|
|
85
|
-
return templateHeaders
|
|
86
|
+
return templateHeaders
|
|
87
|
+
.filter(function (column) { return column.label && templateHeaderMatchings[column.label]; })
|
|
88
|
+
.map(function (column) {
|
|
86
89
|
return {
|
|
87
90
|
matched_column_name: templateHeaderMatchings[column.label],
|
|
88
91
|
template_column_name: column.label,
|
|
89
92
|
};
|
|
90
93
|
});
|
|
91
94
|
};
|
|
92
|
-
var
|
|
95
|
+
var buildValueMappingsFromHeaderValueMatchings = function (enumFieldValueMatchings) {
|
|
96
|
+
var mappings = Object.values(enumFieldValueMatchings).map(function (column) {
|
|
97
|
+
var valuesMappings = [];
|
|
98
|
+
for (var _i = 0, _a = Object.entries(column); _i < _a.length; _i++) {
|
|
99
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
100
|
+
if (!value) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
valuesMappings.push({
|
|
104
|
+
matched_value: key,
|
|
105
|
+
template_value: value,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return valuesMappings;
|
|
109
|
+
});
|
|
110
|
+
return mappings.flat();
|
|
111
|
+
};
|
|
112
|
+
var saveMappedColumns = function (columnMappings, valueMappings, fuseApi, templateSlug) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
113
|
var error_2;
|
|
94
114
|
return __generator(this, function (_a) {
|
|
95
115
|
switch (_a.label) {
|
|
96
116
|
case 0:
|
|
97
117
|
_a.trys.push([0, 2, , 3]);
|
|
98
118
|
return [4 /*yield*/, fuseApi.patch("/api/v1/importer/templates/".concat(templateSlug), {
|
|
99
|
-
|
|
119
|
+
column_mappings: columnMappings,
|
|
120
|
+
value_mappings: valueMappings,
|
|
100
121
|
})];
|
|
101
122
|
case 1:
|
|
102
123
|
_a.sent();
|
|
@@ -118,13 +139,36 @@ var filterAndMapWithBackendErrors = function (dataSet, errors) {
|
|
|
118
139
|
return __assign(__assign({}, record), { _meta: __assign(__assign({}, meta), { isInvalid: true, backendErrors: errors[rId] }) });
|
|
119
140
|
}, []);
|
|
120
141
|
};
|
|
121
|
-
|
|
122
|
-
var
|
|
142
|
+
var checkWrongData = function (dataSet, errors, reviewFields) {
|
|
143
|
+
var errorsKeys = Object.keys(errors);
|
|
144
|
+
var highestRowIndex = 0;
|
|
145
|
+
Object.values(dataSet).forEach(function (record) {
|
|
146
|
+
highestRowIndex = Math.max(highestRowIndex, record._meta.rowIndex);
|
|
147
|
+
});
|
|
148
|
+
var _loop_1 = function (currErrorId) {
|
|
149
|
+
var allFieldsName = reviewFields.map(function (field) { return field.name; });
|
|
150
|
+
var columnsOnError = Object.keys(errors[currErrorId]);
|
|
151
|
+
columnsOnError.forEach(function (column) {
|
|
152
|
+
if (!allFieldsName.includes(column)) {
|
|
153
|
+
addToast("Invalid column \"".concat(column, "\""), "error");
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (+currErrorId > highestRowIndex) {
|
|
157
|
+
addToast("Invalid row id \"".concat(currErrorId, "\""), "error");
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
for (var _i = 0, errorsKeys_1 = errorsKeys; _i < errorsKeys_1.length; _i++) {
|
|
161
|
+
var currErrorId = errorsKeys_1[_i];
|
|
162
|
+
_loop_1(currErrorId);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
export var useSubmitToServer = function (setHasTransformedRecords) {
|
|
166
|
+
var _a = useImporterContext(), enumFieldValueMatchings = _a.enumFieldValueMatchings, templateHeaderMatchings = _a.templateHeaderMatchings, templateHeaders = _a.templateHeaders, integrations = _a.integrations, templateSlug = _a.templateSlug, fuseApi = _a.fuseApi, previewMode = _a.importerOptions.previewMode, onSubmit = _a.onSubmit;
|
|
123
167
|
var _b = useState(false), isSubmitting = _b[0], setIsSubmitting = _b[1];
|
|
124
168
|
var _c = useState(false), importWasSuccessful = _c[0], setImportWasSuccessful = _c[1];
|
|
125
169
|
var _d = useState(null), appResponse = _d[0], setAppResponse = _d[1];
|
|
126
170
|
var onSubmitToServer = function (dataSet, afterSubmitCallback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
-
var dataSetValues, reviewFields_1, validDataSetValues, validDataSetLength, invalidRecords_1, applicationResponse, isAppResponseSuccessful, _a, errors, isDataValid, recordsToDisplayFiltered, invalidDataSet, columnMappings, error_3;
|
|
171
|
+
var dataSetValues, reviewFields_1, validDataSetValues, validDataSetLength, invalidRecords_1, applicationResponse, isAppResponseSuccessful, _a, errors, isDataValid, recordsToDisplayFiltered, invalidDataSet, columnMappings, valueMappings, error_3;
|
|
128
172
|
return __generator(this, function (_b) {
|
|
129
173
|
switch (_b.label) {
|
|
130
174
|
case 0:
|
|
@@ -146,6 +190,7 @@ export var useSubmitToServer = function (setIsTransformTooltipOpened) {
|
|
|
146
190
|
if (!isAppResponseSuccessful) {
|
|
147
191
|
_a = (applicationResponse !== null && applicationResponse !== void 0 ? applicationResponse : {}).errors, errors = _a === void 0 ? {} : _a;
|
|
148
192
|
invalidRecords_1 = __spreadArray(__spreadArray([], filterAndMapWithBackendErrors(dataSet, errors), true), invalidRecords_1, true);
|
|
193
|
+
checkWrongData(dataSet, errors, reviewFields_1);
|
|
149
194
|
}
|
|
150
195
|
isDataValid = invalidRecords_1.length === 0;
|
|
151
196
|
setImportWasSuccessful(isDataValid && isAppResponseSuccessful);
|
|
@@ -158,7 +203,7 @@ export var useSubmitToServer = function (setIsTransformTooltipOpened) {
|
|
|
158
203
|
invalidRecords_1 = __spreadArray(__spreadArray([], invalidRecords_1, true), (recordsToDisplayFiltered || []), true);
|
|
159
204
|
}
|
|
160
205
|
invalidDataSet = recordListToDataSet(invalidRecords_1, reviewFields_1, false).dataSet;
|
|
161
|
-
|
|
206
|
+
setHasTransformedRecords(false);
|
|
162
207
|
afterSubmitCallback(invalidDataSet);
|
|
163
208
|
if (!!previewMode) return [3 /*break*/, 5];
|
|
164
209
|
return [4 /*yield*/, trackImportedRowsCount(fuseApi, templateSlug, validDataSetLength)];
|
|
@@ -168,7 +213,8 @@ export var useSubmitToServer = function (setIsTransformTooltipOpened) {
|
|
|
168
213
|
case 3:
|
|
169
214
|
_b.sent();
|
|
170
215
|
columnMappings = buildColumnMappingsFromHeaderMatchings(templateHeaders, templateHeaderMatchings);
|
|
171
|
-
|
|
216
|
+
valueMappings = buildValueMappingsFromHeaderValueMatchings(enumFieldValueMatchings);
|
|
217
|
+
return [4 /*yield*/, saveMappedColumns(columnMappings, valueMappings, fuseApi, templateSlug)];
|
|
172
218
|
case 4:
|
|
173
219
|
_b.sent();
|
|
174
220
|
_b.label = 5;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CircleSpinner: () => JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import styled from "styled-components";
|
|
7
|
+
var SpinnerContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n animation: spin 1s linear infinite;\n background: transparent;\n border-radius: 50%;\n height: 24px;\n overflow: hidden;\n position: relative;\n width: 24px;\n z-index: 0;\n\n @keyframes spin {\n 100% {\n transform: rotate(360deg);\n }\n }\n"], ["\n animation: spin 1s linear infinite;\n background: transparent;\n border-radius: 50%;\n height: 24px;\n overflow: hidden;\n position: relative;\n width: 24px;\n z-index: 0;\n\n @keyframes spin {\n 100% {\n transform: rotate(360deg);\n }\n }\n"])));
|
|
8
|
+
var SpinBlocker = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: black;\n border-radius: 50%;\n height: 80%;\n left: 10%;\n position: absolute;\n top: 10%;\n width: 80%;\n"], ["\n background: black;\n border-radius: 50%;\n height: 80%;\n left: 10%;\n position: absolute;\n top: 10%;\n width: 80%;\n"])));
|
|
9
|
+
var Spin = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: linear-gradient(\n to bottom right,\n rgba(255, 255, 255, 0.85) 50%,\n rgba(0, 0, 0, 0) 150%\n );\n height: 50%;\n left: 0;\n position: absolute;\n top: 50%;\n width: 50%;\n z-index: -1;\n"], ["\n background: linear-gradient(\n to bottom right,\n rgba(255, 255, 255, 0.85) 50%,\n rgba(0, 0, 0, 0) 150%\n );\n height: 50%;\n left: 0;\n position: absolute;\n top: 50%;\n width: 50%;\n z-index: -1;\n"])));
|
|
10
|
+
export var CircleSpinner = function () {
|
|
11
|
+
return (_jsxs(SpinnerContainer, { children: [_jsx(SpinBlocker, {}), _jsx(Spin, {})] }));
|
|
12
|
+
};
|
|
13
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -6,12 +6,19 @@ export var useDragAndDrop = function (_a) {
|
|
|
6
6
|
var onComplete = _a.onComplete, saveFileName = _a.saveFileName, setIsLoading = _a.setIsLoading, validHeadersCount = _a.validHeadersCount;
|
|
7
7
|
var onDrop = function (acceptedFiles) {
|
|
8
8
|
acceptedFiles.forEach(function (file) {
|
|
9
|
+
if (file.size <= 0) {
|
|
10
|
+
addToast("Cannot upload an empty file.", "error");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
9
13
|
setIsLoading && setIsLoading(true);
|
|
10
14
|
saveFileName(file.name);
|
|
11
15
|
var reader = new FileReader();
|
|
12
16
|
var isCsvFile = file.type === "text/csv";
|
|
13
17
|
reader.onabort = function () { return console.log("file reading was aborted"); };
|
|
14
|
-
reader.onerror = function () {
|
|
18
|
+
reader.onerror = function () {
|
|
19
|
+
addToast("An error occurred while reading the file.", "error");
|
|
20
|
+
setIsLoading && setIsLoading(false);
|
|
21
|
+
};
|
|
15
22
|
reader.onload = function (event) {
|
|
16
23
|
var _a;
|
|
17
24
|
var results = event.target.result;
|
|
@@ -22,31 +29,59 @@ export var useDragAndDrop = function (_a) {
|
|
|
22
29
|
onComplete(parserResults.data);
|
|
23
30
|
setIsLoading && setIsLoading(false);
|
|
24
31
|
},
|
|
32
|
+
error: function (error) {
|
|
33
|
+
addToast("An error occurred while parsing the CSV: ".concat(error.message), "error");
|
|
34
|
+
setIsLoading && setIsLoading(false);
|
|
35
|
+
},
|
|
25
36
|
});
|
|
26
37
|
return;
|
|
27
38
|
}
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: "array",
|
|
33
|
-
codepage: 65001,
|
|
34
|
-
raw: true,
|
|
35
|
-
dense: isLargeFile,
|
|
36
|
-
});
|
|
37
|
-
var workBookName = workBook.SheetNames[0];
|
|
38
|
-
var sheet = workBook.Sheets[workBookName];
|
|
39
|
-
return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false });
|
|
40
|
-
};
|
|
41
|
-
var fileData = getDataFromFile(results);
|
|
42
|
-
var headersCount = (_a = fileData[0]) === null || _a === void 0 ? void 0 : _a.length;
|
|
43
|
-
if (validHeadersCount) {
|
|
44
|
-
validHeadersCount(headersCount) && onComplete(fileData);
|
|
39
|
+
var arr = new Uint8Array(event.target.result).subarray(0, 4);
|
|
40
|
+
var header = "";
|
|
41
|
+
for (var i = 0; i < arr.length; i++) {
|
|
42
|
+
header += arr[i].toString(16);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
// Check the file signature
|
|
45
|
+
var isExcelFile = header === "504b34" || header === "d0cf11e0"; // .xlsx or .xls
|
|
46
|
+
if (!isExcelFile) {
|
|
47
|
+
addToast("The file is not a valid Excel file.", "error");
|
|
48
|
+
setIsLoading && setIsLoading(false);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
var getDataFromFile = function (fileResults) {
|
|
53
|
+
// rounded value to 20MB
|
|
54
|
+
var isLargeFile = file.size > 20000000;
|
|
55
|
+
var workBook = XLSX.read(fileResults, {
|
|
56
|
+
type: "array",
|
|
57
|
+
codepage: 65001,
|
|
58
|
+
raw: true,
|
|
59
|
+
dense: isLargeFile,
|
|
60
|
+
});
|
|
61
|
+
var workBookName = workBook.SheetNames[0];
|
|
62
|
+
var sheet = workBook.Sheets[workBookName];
|
|
63
|
+
return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false });
|
|
64
|
+
};
|
|
65
|
+
var fileData = getDataFromFile(results);
|
|
66
|
+
if (!fileData.length) {
|
|
67
|
+
addToast("The file appears to be empty or cannot be parsed.", "error");
|
|
68
|
+
setIsLoading && setIsLoading(false);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var headersCount = (_a = fileData[0]) === null || _a === void 0 ? void 0 : _a.length;
|
|
72
|
+
if (validHeadersCount && !validHeadersCount(headersCount)) {
|
|
73
|
+
addToast("Invalid header count in file.", "error");
|
|
74
|
+
setIsLoading && setIsLoading(false);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
onComplete(fileData);
|
|
78
|
+
setIsLoading && setIsLoading(false);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
addToast("An error occurred while processing the file: ".concat(error.message), "error");
|
|
83
|
+
setIsLoading && setIsLoading(false);
|
|
48
84
|
}
|
|
49
|
-
setIsLoading && setIsLoading(false);
|
|
50
85
|
};
|
|
51
86
|
if (isCsvFile) {
|
|
52
87
|
reader.readAsText(file);
|
|
@@ -105,30 +105,35 @@ export var CustomActions = function () {
|
|
|
105
105
|
var handleCustomAction = function (actionKey) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
106
|
var recordsToRunAction, action, processRecordsInBatches, toastMessage;
|
|
107
107
|
return __generator(this, function (_a) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
processRecordsInBatches(recordsToRunAction, function (batch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
switch (_a.label) {
|
|
120
|
-
case 0: return [4 /*yield*/, processBatch(batch, action)];
|
|
121
|
-
case 1:
|
|
122
|
-
_a.sent();
|
|
123
|
-
return [2 /*return*/];
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
recordsToRunAction = selectedRows.map(function (recordId) {
|
|
111
|
+
return getRecord(recordId);
|
|
112
|
+
});
|
|
113
|
+
action = customActions.find(function (action) { return action.name === actionKey; });
|
|
114
|
+
if (!action || Object.keys(action).length === 0) {
|
|
115
|
+
addToast(t("table_actions.custom_actions.general_error_toast"), "error");
|
|
116
|
+
return [2 /*return*/];
|
|
124
117
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
processRecordsInBatches = useBatchProcessing().processRecordsInBatches;
|
|
119
|
+
return [4 /*yield*/, processRecordsInBatches(recordsToRunAction, function (batch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
switch (_a.label) {
|
|
122
|
+
case 0: return [4 /*yield*/, processBatch(batch, action)];
|
|
123
|
+
case 1:
|
|
124
|
+
_a.sent();
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}); })];
|
|
129
|
+
case 1:
|
|
130
|
+
_a.sent();
|
|
131
|
+
toastMessage = t("table_actions.custom_actions.success_toast", {
|
|
132
|
+
actionName: action.name,
|
|
133
|
+
});
|
|
134
|
+
addToast(toastMessage, "success");
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
}
|
|
132
137
|
});
|
|
133
138
|
}); };
|
|
134
139
|
var onSelect = function (value) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
|
-
import { addToast } from "../../../../common/Toast";
|
|
5
4
|
import { useReviewContext, useSpreadsheetContext } from "../../../../Importer";
|
|
6
5
|
import { useFilteredDataContext } from "../../../../Importer/common/Spreadsheet/FilteredDataContextProvider";
|
|
7
6
|
import { useValidationContext } from "../../../../Importer/common/Spreadsheet/ValidationContextProvider";
|
|
7
|
+
import { addToast } from "../../../../common/Toast";
|
|
8
8
|
import { useEventManagerContext } from "../../../EventManagerContextProvider";
|
|
9
9
|
import * as S from "./FilterByErrors.styles";
|
|
10
10
|
export var FilterByErrors = function () {
|
|
@@ -12,7 +12,7 @@ export var FilterByErrors = function () {
|
|
|
12
12
|
var _c = useFilteredDataContext(), spreadsheetFilter = _c.spreadsheetFilter, resetSpreadsheetFilter = _c.resetSpreadsheetFilter, filterRecordsByFieldErrors = _c.filterRecordsByFieldErrors;
|
|
13
13
|
var _d = useEventManagerContext(), on = _d.on, off = _d.off, EVENTS = _d.EVENTS;
|
|
14
14
|
var fields = useSpreadsheetContext().fields;
|
|
15
|
-
var
|
|
15
|
+
var hasTransformedRecords = useReviewContext().hasTransformedRecords;
|
|
16
16
|
var columnsWithErrorCounts = useValidationContext().columnsWithErrorCounts;
|
|
17
17
|
var t = useTranslation("review").t;
|
|
18
18
|
var _e = useState([]), errorArray = _e[0], setErrorArray = _e[1];
|
|
@@ -72,6 +72,6 @@ export var FilterByErrors = function () {
|
|
|
72
72
|
: isMenuOpened
|
|
73
73
|
? search_or_select
|
|
74
74
|
: prefix;
|
|
75
|
-
var isDisabled = errorArray.length === 0 ||
|
|
75
|
+
var isDisabled = errorArray.length === 0 || hasTransformedRecords;
|
|
76
76
|
return (_jsx(S.StyledAutocomplete, { placement: "bottom", placeholder: inputText, onToggle: function (v) { return !isDisabled && setIsMenuOpened(v); }, onChange: onChange, value: selectedErrorToFilter, options: errorArray, isDisabled: isDisabled, isInputDisabled: isDisabled, inputWidth: inputWidth, "data-testid": "ta-filter-by-errors", prefix: inputText }));
|
|
77
77
|
};
|
|
@@ -45,7 +45,7 @@ export var RowFilters = function () {
|
|
|
45
45
|
var _a = useFilteredDataContext(), spreadsheetFilter = _a.spreadsheetFilter, filterRecordsByRowType = _a.filterRecordsByRowType;
|
|
46
46
|
var _b = useDuplicateDataContext(), duplicateRecordIds = _b.duplicateRecordIds, calculateDuplicateRecords = _b.calculateDuplicateRecords;
|
|
47
47
|
var invalidRowsCountRef = useValidationContext().invalidRowsCountRef;
|
|
48
|
-
var
|
|
48
|
+
var hasTransformedRecords = useReviewContext().hasTransformedRecords;
|
|
49
49
|
var _c = useState(invalidRowsCountRef.current), invalidRowsCount = _c[0], setInvalidRowsCount = _c[1];
|
|
50
50
|
var _d = useDataSetContext(), dataSetLength = _d.dataSetLength, emptyRecordIds = _d.emptyRecordIds;
|
|
51
51
|
var _e = useEventManagerContext(), on = _e.on, off = _e.off, EVENTS = _e.EVENTS;
|
|
@@ -89,6 +89,6 @@ export var RowFilters = function () {
|
|
|
89
89
|
}
|
|
90
90
|
filterRecordsByRowType("invalid");
|
|
91
91
|
};
|
|
92
|
-
return (_jsx(Wrapper, __assign({ isDisabled:
|
|
92
|
+
return (_jsx(Wrapper, __assign({ isDisabled: hasTransformedRecords }, { children: _jsxs(Container, { children: [_jsx(Filter, { isSelected: spreadsheetFilter.byRow === "all", label: all_rows, count: recordsWithValuesCount, onClick: function () { return onAllSelected(); }, "data-test-id": "all_rows_filter" }), _jsx(Filter, { isSelected: spreadsheetFilter.byRow === "invalid", label: invalid_rows, count: invalidRowsCount, onClick: function () { return onInvalidSelected(); }, "data-test-id": "invalid_filter" }), _jsx(Filter, { isSelected: spreadsheetFilter.byRow === "duplicates", label: duplicates, count: duplicateRecordIds.size, onClick: function () { return onDuplicatesSelected(); }, "data-test-id": "duplicates_filter" })] }) })));
|
|
93
93
|
};
|
|
94
94
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -14,18 +14,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
return __assign.apply(this, arguments);
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
-
import { useRef
|
|
17
|
+
import { useRef } from "react";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
18
19
|
import styled, { css } from "styled-components";
|
|
19
|
-
import { useDebounce } from "../../../hooks";
|
|
20
20
|
import { useReviewContext } from "../../../Importer";
|
|
21
|
-
import { colors } from "../../../styled/theme/colorPalette";
|
|
22
|
-
import { textStyles } from "../../../styled/theme/textStyles";
|
|
23
|
-
import { SearchIcon, ReplaceIcon } from "./icons";
|
|
24
|
-
import { TooltipProvider } from "../../../common/TooltipProvider";
|
|
25
|
-
import { useTranslation } from "react-i18next";
|
|
26
|
-
import { Div } from "../../../styled";
|
|
27
21
|
import { useFilteredDataContext } from "../../../Importer/common/Spreadsheet/FilteredDataContextProvider";
|
|
28
22
|
import { FindAndReplaceModal } from "../../../Importer/common/Spreadsheet/components/FindAndReplace";
|
|
23
|
+
import { TooltipProvider } from "../../../common/TooltipProvider";
|
|
24
|
+
import { useDebounce } from "../../../hooks";
|
|
25
|
+
import { Div } from "../../../styled";
|
|
26
|
+
import { colors } from "../../../styled/theme/colorPalette";
|
|
27
|
+
import { textStyles } from "../../../styled/theme/textStyles";
|
|
28
|
+
import { ReplaceIcon, SearchIcon } from "./icons";
|
|
29
|
+
import { useSearchContext } from "../../../Importer/common/Spreadsheet/SearchContextProvider";
|
|
29
30
|
var Wrapper = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n border-radius: 4px;\n cursor: pointer;\n display: flex;\n gap: 8px;\n height: 24px;\n overflow: hidden;\n padding: 8px;\n position: relative;\n transition: width 0.25s ease-in-out;\n width: ", ";\n"], ["\n background: ", ";\n border-radius: 4px;\n cursor: pointer;\n display: flex;\n gap: 8px;\n height: 24px;\n overflow: hidden;\n padding: 8px;\n position: relative;\n transition: width 0.25s ease-in-out;\n width: ", ";\n"])), function (_a) {
|
|
30
31
|
var isOpen = _a.isOpen;
|
|
31
32
|
return (isOpen ? colors.orange50 : "none");
|
|
@@ -43,10 +44,8 @@ var Input = styled.input(templateObject_6 || (templateObject_6 = __makeTemplateO
|
|
|
43
44
|
var SearchInput = function (_a) {
|
|
44
45
|
var testId = _a.testId, value = _a.value, onChange = _a.onChange, isDisabled = _a.isDisabled;
|
|
45
46
|
var _b = useDebounce(value, onChange, 300), _value = _b._value, set_Value = _b.set_Value;
|
|
46
|
-
var inputRef = useRef(null);
|
|
47
47
|
var filteredDataIds = useFilteredDataContext().filteredDataIds;
|
|
48
|
-
var _c =
|
|
49
|
-
var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
|
|
48
|
+
var _c = useSearchContext(), findAndReplaceModalOpen = _c.findAndReplaceModalOpen, setFindAndReplaceModalOpen = _c.setFindAndReplaceModalOpen, openSearchInput = _c.openSearchInput, closeSearchInput = _c.closeSearchInput, searchInputRef = _c.searchInputRef, isOpen = _c.isOpen;
|
|
50
49
|
var actionsRef = useRef();
|
|
51
50
|
var t = useTranslation("review").t;
|
|
52
51
|
var handleInputChange = function (_a) {
|
|
@@ -55,29 +54,22 @@ var SearchInput = function (_a) {
|
|
|
55
54
|
};
|
|
56
55
|
var handleInputOnBlur = function (e) {
|
|
57
56
|
if (!_value && e.relatedTarget !== actionsRef.current) {
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var handleWrapperClick = function () {
|
|
62
|
-
var _a;
|
|
63
|
-
if (!isOpen) {
|
|
64
|
-
setIsOpen(true);
|
|
65
|
-
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
66
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
67
|
-
}
|
|
57
|
+
closeSearchInput();
|
|
68
58
|
}
|
|
69
59
|
};
|
|
70
|
-
return (_jsxs(
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
return (_jsxs(Div, { children: [_jsx(TooltipProvider, __assign({ tooltip: !isOpen && !isDisabled && !findAndReplaceModalOpen
|
|
61
|
+
? t("table_actions.search_rows.tooltip")
|
|
62
|
+
: "", placement: "right", flip: false, centered: true, w: "auto", "data-testid": testId }, { children: _jsxs(Wrapper, __assign({ isOpen: isOpen, onClick: function () { return !isDisabled && openSearchInput(); }, disabledWhen: isDisabled }, { children: [_jsx(IconWrapper, { children: _jsx(SearchIcon, {}) }), _jsx(Input, { isOpen: isOpen, ref: searchInputRef, value: _value, onChange: handleInputChange, onBlur: handleInputOnBlur, type: "text", placeholder: t("table_actions.search_rows.placeholder") }), _jsxs(ActionsWrapper, __assign({ "data-cy": "open-find-replace", ref: actionsRef, onClick: function () { return setFindAndReplaceModalOpen(true); }, tabIndex: 0 }, { children: [_jsx(ResultsText, { children: t("table_actions.search_rows.number_of_results", {
|
|
63
|
+
length: value ? filteredDataIds.length : 0,
|
|
64
|
+
}) }), _jsx(IconWrapper, { children: _jsx(ReplaceIcon, {}) })] }))] })) })), _jsx(Div, { children: findAndReplaceModalOpen && (_jsx(FindAndReplaceModal, { initialText: value, onClose: function () { return setFindAndReplaceModalOpen(false); } })) })] }));
|
|
73
65
|
};
|
|
74
66
|
export var SearchRows = function (_a) {
|
|
75
67
|
var _b = _a.testId, testId = _b === void 0 ? "ta-search-rows" : _b;
|
|
76
68
|
var _c = useFilteredDataContext(), filteredInputValue = _c.filteredInputValue, setFilteredInputValue = _c.setFilteredInputValue;
|
|
77
|
-
var
|
|
69
|
+
var hasTransformedRecords = useReviewContext().hasTransformedRecords;
|
|
78
70
|
var handleChangeInputValue = function (value) {
|
|
79
71
|
setFilteredInputValue(value);
|
|
80
72
|
};
|
|
81
|
-
return (_jsx(_Fragment, { children: _jsx(SearchInput, { testId: testId, value: filteredInputValue, onChange: handleChangeInputValue, isDisabled:
|
|
73
|
+
return (_jsx(_Fragment, { children: _jsx(SearchInput, { testId: testId, value: filteredInputValue, onChange: handleChangeInputValue, isDisabled: hasTransformedRecords }) }));
|
|
82
74
|
};
|
|
83
75
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useReviewContext } from "../../../Importer";
|
|
25
|
-
import {
|
|
25
|
+
import { useValidationContext } from "../../../Importer/common/Spreadsheet/ValidationContextProvider";
|
|
26
26
|
import { CustomActions } from "./CustomActions";
|
|
27
27
|
import { DeleteSelectedRows } from "./DeleteSelectedRows";
|
|
28
28
|
import { ExportData } from "./ExportData";
|
|
@@ -32,11 +32,14 @@ import { SearchRows } from "./SearchRows";
|
|
|
32
32
|
import * as S from "./TableActions.styles";
|
|
33
33
|
import { TransformedRecordsCount } from "./TransformedRecordsCount";
|
|
34
34
|
import ValidationProgress from "./ValidationProgress";
|
|
35
|
+
import { defaultTableActionsHeightPx } from "./common";
|
|
35
36
|
export var TableActions = function (_a) {
|
|
36
37
|
var _b = _a.tableActionsHeight, tableActionsHeight = _b === void 0 ? defaultTableActionsHeightPx : _b, props = __rest(_a, ["tableActionsHeight"]);
|
|
37
|
-
var _c = useReviewContext(),
|
|
38
|
+
var _c = useReviewContext(), hasTransformedRecords = _c.hasTransformedRecords, setHasTransformedRecords = _c.setHasTransformedRecords;
|
|
39
|
+
var isValidationCompleted = useValidationContext().isValidationCompleted;
|
|
38
40
|
var onCloseTransformsTooltip = function () {
|
|
39
|
-
|
|
41
|
+
setHasTransformedRecords(false);
|
|
40
42
|
};
|
|
41
|
-
|
|
43
|
+
var shouldShowTransformedCount = hasTransformedRecords && isValidationCompleted;
|
|
44
|
+
return (_jsxs(S.TableActionsContainer, __assign({ height: tableActionsHeight }, props, { children: [_jsxs(S.TableActionsContent, { children: [_jsx(SearchRows, {}), _jsx(RowFilters, {}), _jsx(FilterByErrors, {}), _jsxs(S.ButtonActionsContainer, { children: [_jsx(DeleteSelectedRows, {}), _jsx(ExportData, {}), _jsx(CustomActions, {})] })] }), _jsxs(S.TableActionsInformations, { children: [_jsx(ValidationProgress, {}), shouldShowTransformedCount && (_jsx(TransformedRecordsCount, { onClose: onCloseTransformsTooltip }))] })] })));
|
|
42
45
|
};
|
|
@@ -13,6 +13,6 @@ export var TableActionsContainer = styled(Div)(templateObject_1 || (templateObje
|
|
|
13
13
|
});
|
|
14
14
|
export var ButtonActionsContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 8px;\n"], ["\n align-items: center;\n display: flex;\n gap: 8px;\n"])));
|
|
15
15
|
export var TableActionsContent = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n"], ["\n align-items: center;\n display: flex;\n gap: 16px;\n"])));
|
|
16
|
-
export var TableActionsInformations = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n position: relative;\n
|
|
16
|
+
export var TableActionsInformations = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n position: relative;\n"], ["\n align-items: center;\n display: flex;\n gap: 16px;\n position: relative;\n"])));
|
|
17
17
|
export var ActionButton = styled.button(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"], ["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"])));
|
|
18
18
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -17,11 +17,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
17
17
|
import { useEffect, useMemo, useState } from "react";
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
19
|
import styled from "styled-components";
|
|
20
|
-
import { Button } from "../../../common/buttons";
|
|
21
20
|
import { useSpreadsheetContext } from "../../../Importer";
|
|
22
21
|
import { useDataSetContext } from "../../../Importer/common/Spreadsheet/DataSetContextProvider";
|
|
23
22
|
import { useFilteredDataContext } from "../../../Importer/common/Spreadsheet/FilteredDataContextProvider";
|
|
24
|
-
import {
|
|
23
|
+
import { Button } from "../../../common/buttons";
|
|
24
|
+
import { Div, colors } from "../../../styled";
|
|
25
25
|
import { truncateString } from "../../../utils";
|
|
26
26
|
import { CheckIcon } from "./icons";
|
|
27
27
|
var formatToLocaleString = function (number) {
|
|
@@ -30,7 +30,7 @@ var formatToLocaleString = function (number) {
|
|
|
30
30
|
maximumFractionDigits: 0,
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
var RecordsCountContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n
|
|
33
|
+
var RecordsCountContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n\n * {\n box-sizing: border-box;\n }\n"], ["\n position: relative;\n\n * {\n box-sizing: border-box;\n }\n"])));
|
|
34
34
|
var Counter = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border-radius: 35px;\n display: flex;\n padding: 0px 18px;\n position: relative;\n user-select: none;\n z-index: 101;\n"], ["\n align-items: center;\n background: ", ";\n border-radius: 35px;\n display: flex;\n padding: 0px 18px;\n position: relative;\n user-select: none;\n z-index: 101;\n"])), colors.blue100);
|
|
35
35
|
var TooltipContainer = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", ";\n border-radius: 8px;\n box-shadow: 0px 3.53px 63.58px 0px #b7a6a640;\n display: flex;\n flex-direction: column;\n gap: 18px;\n padding: 16px 32px 24px 24px;\n position: absolute;\n right: 0px;\n top: 66px;\n width: clamp(150px, 379px, 379px);\n z-index: 101;\n\n &::before {\n border-color: transparent transparent #ffffff transparent;\n border-radius: 4px;\n border-style: solid;\n border-width: 0 14.5px 24px 14.5px;\n content: \"\";\n height: 0;\n position: absolute;\n right: -4px;\n top: -6px;\n transform: rotate(120deg);\n width: 0;\n }\n"], ["\n background: ", ";\n border-radius: 8px;\n box-shadow: 0px 3.53px 63.58px 0px #b7a6a640;\n display: flex;\n flex-direction: column;\n gap: 18px;\n padding: 16px 32px 24px 24px;\n position: absolute;\n right: 0px;\n top: 66px;\n width: clamp(150px, 379px, 379px);\n z-index: 101;\n\n &::before {\n border-color: transparent transparent #ffffff transparent;\n border-radius: 4px;\n border-style: solid;\n border-width: 0 14.5px 24px 14.5px;\n content: \"\";\n height: 0;\n position: absolute;\n right: -4px;\n top: -6px;\n transform: rotate(120deg);\n width: 0;\n }\n"])), colors.white);
|
|
36
36
|
var ExampleCode = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border-radius: 4px;\n display: flex;\n justify-content: space-between;\n padding: 4px;\n"], ["\n align-items: center;\n background: ", ";\n border-radius: 4px;\n display: flex;\n justify-content: space-between;\n padding: 4px;\n"])), colors.blue100);
|
|
@@ -51,7 +51,7 @@ export var TableRow = function (_a) {
|
|
|
51
51
|
var isLastColumn = indexJ === columns.length - 1;
|
|
52
52
|
return (_jsx(Cell, __assign({ row: row, onClick: onRowClick && !column.preventRowClick
|
|
53
53
|
? function () { return onRowClick(row); }
|
|
54
|
-
: null, isLast: isLastColumn, className: isLastColumn ? "last-column" : "", w: columnWidthPercentage }, { children: Content ? (_jsx(Content, __assign({}, row, { columnWidth: columnWidthPercentage, rowIndex: indexI }))) : (_jsx(Div, __assign({ truncateText: true }, { children: row[column.dataAccessor] || "-" }))) }), resolvedKey));
|
|
54
|
+
: null, isLast: isLastColumn, className: isLastColumn ? "last-column" : "", w: columnWidthPercentage }, { children: Content ? (_jsx(Content, __assign({}, row, { columnWidth: columnWidthPercentage, colIndex: indexJ, rowIndex: indexI }))) : (_jsx(Div, __assign({ truncateText: true }, { children: row[column.dataAccessor] || "-" }))) }), resolvedKey));
|
|
55
55
|
}) })));
|
|
56
56
|
};
|
|
57
57
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -8,4 +8,4 @@ type TableViewWrapperProps = {
|
|
|
8
8
|
checkboxColumnWidth?: number;
|
|
9
9
|
};
|
|
10
10
|
export declare const TableViewWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableViewWrapperProps, never>;
|
|
11
|
-
export declare const TableView: React.MemoExoticComponent<({ data, dataRefIds, columns, pageSize, onRowClick, sortBy, isLoading, setSortBy, rowWidthScalingFactor, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: TableViewProps) => JSX.Element>;
|
|
11
|
+
export declare const TableView: React.MemoExoticComponent<({ data, dataRefIds, columns, pageSize, onRowClick, sortBy, isLoading, setSortBy, rowWidthScalingFactor, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, shouldHideTable, ...props }: TableViewProps) => JSX.Element>;
|
|
@@ -66,7 +66,7 @@ var buildGridStyles = function (rowWidthScalingFactor) {
|
|
|
66
66
|
return gridStyles;
|
|
67
67
|
};
|
|
68
68
|
export var TableView = React.memo(function (_a) {
|
|
69
|
-
var _b = _a.data, data = _b === void 0 ? null : _b, _c = _a.dataRefIds, dataRefIds = _c === void 0 ? null : _c, columns = _a.columns, pageSize = _a.pageSize, _d = _a.onRowClick, onRowClick = _d === void 0 ? null : _d, _e = _a.sortBy, sortBy = _e === void 0 ? { field: null, direction: null } : _e, _f = _a.isLoading, isLoading = _f === void 0 ? false : _f, _g = _a.setSortBy, setSortBy = _g === void 0 ? null : _g, _h = _a.rowWidthScalingFactor, rowWidthScalingFactor = _h === void 0 ? 1 : _h, _j = _a.tableHeadersHeight, tableHeadersHeight = _j === void 0 ? defaultTableHeaderHeightPx : _j, _k = _a.rowHeight, rowHeight = _k === void 0 ? defaultTableRowHeightPx : _k, _l = _a.h, h = _l === void 0 ? 500 : _l, _m = _a.onTableScroll, onTableScroll = _m === void 0 ? null : _m, _o = _a.getItemKey, getItemKey = _o === void 0 ? null : _o, _p = _a.isDraggable, isDraggable = _p === void 0 ? false : _p, checkboxColumnWidth = _a.checkboxColumnWidth, _q = _a.isFiltering, isFiltering = _q === void 0 ? false : _q, props = __rest(_a, ["data", "dataRefIds", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "setSortBy", "rowWidthScalingFactor", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering"]);
|
|
69
|
+
var _b = _a.data, data = _b === void 0 ? null : _b, _c = _a.dataRefIds, dataRefIds = _c === void 0 ? null : _c, columns = _a.columns, pageSize = _a.pageSize, _d = _a.onRowClick, onRowClick = _d === void 0 ? null : _d, _e = _a.sortBy, sortBy = _e === void 0 ? { field: null, direction: null } : _e, _f = _a.isLoading, isLoading = _f === void 0 ? false : _f, _g = _a.setSortBy, setSortBy = _g === void 0 ? null : _g, _h = _a.rowWidthScalingFactor, rowWidthScalingFactor = _h === void 0 ? 1 : _h, _j = _a.tableHeadersHeight, tableHeadersHeight = _j === void 0 ? defaultTableHeaderHeightPx : _j, _k = _a.rowHeight, rowHeight = _k === void 0 ? defaultTableRowHeightPx : _k, _l = _a.h, h = _l === void 0 ? 500 : _l, _m = _a.onTableScroll, onTableScroll = _m === void 0 ? null : _m, _o = _a.getItemKey, getItemKey = _o === void 0 ? null : _o, _p = _a.isDraggable, isDraggable = _p === void 0 ? false : _p, checkboxColumnWidth = _a.checkboxColumnWidth, _q = _a.isFiltering, isFiltering = _q === void 0 ? false : _q, _r = _a.shouldHideTable, shouldHideTable = _r === void 0 ? false : _r, props = __rest(_a, ["data", "dataRefIds", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "setSortBy", "rowWidthScalingFactor", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering", "shouldHideTable"]);
|
|
70
70
|
var headerContainerRef = useRef();
|
|
71
71
|
var rowCount = dataRefIds ? dataRefIds.ids.length : data.length;
|
|
72
72
|
var onScroll = function (_a) {
|
|
@@ -106,7 +106,7 @@ export var TableView = React.memo(function (_a) {
|
|
|
106
106
|
width: autosizerWidth,
|
|
107
107
|
columnCount: 1,
|
|
108
108
|
onScroll: onScroll,
|
|
109
|
-
columnWidth: rowWidth,
|
|
109
|
+
columnWidth: shouldHideTable ? 0 : rowWidth,
|
|
110
110
|
height: autosizerHeight - tableHeadersHeight,
|
|
111
111
|
rowHeight: rowHeight,
|
|
112
112
|
rowCount: rowCount,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
1
2
|
import { ToastOptions } from "react-hot-toast";
|
|
2
3
|
type ToastProps = {
|
|
3
4
|
zIndex?: number;
|
|
5
|
+
toastStyle?: CSSProperties;
|
|
4
6
|
};
|
|
5
7
|
type ToastTypes = keyof typeof toastTypeStyles;
|
|
6
8
|
export declare const addToast: (msg: JSX.Element | string, type?: ToastTypes, toastOptions?: ToastOptions) => void;
|
|
9
|
+
export declare const addLoadingToast: (msg: JSX.Element | string, helperMsg: JSX.Element | string, toastOptions?: ToastOptions, minW?: number) => void;
|
|
7
10
|
declare const toastTypeStyles: {
|
|
8
11
|
error: {
|
|
9
12
|
color: string;
|
|
@@ -30,6 +33,11 @@ declare const toastTypeStyles: {
|
|
|
30
33
|
backgroundColor: string;
|
|
31
34
|
icon: JSX.Element;
|
|
32
35
|
};
|
|
36
|
+
loadingNotification: {
|
|
37
|
+
color: string;
|
|
38
|
+
backgroundColor: string;
|
|
39
|
+
icon: JSX.Element;
|
|
40
|
+
};
|
|
33
41
|
};
|
|
34
|
-
declare const Toast: ({ zIndex }: ToastProps) => JSX.Element;
|
|
42
|
+
declare const Toast: ({ zIndex, toastStyle }: ToastProps) => JSX.Element;
|
|
35
43
|
export { Toast };
|