fuse-importer 0.27.1 → 0.30.0
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.d.ts +2 -0
- package/lib/esm/Importer/ImporterWithContext.js +51 -13
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +2 -2
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +4 -3
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +14 -9
- package/lib/esm/Importer/Matcher/index.js +0 -11
- package/lib/esm/Importer/PreviewFirstTime.js +1 -1
- package/lib/esm/Importer/Review/AppResponseModal.js +2 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +8 -6
- package/lib/esm/Importer/Review/ReviewContextProvider.js +72 -195
- package/lib/esm/Importer/Review/ReviewWithContext.js +2 -2
- package/lib/esm/Importer/Stepper/StepperSubmitModal.d.ts +2 -1
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +4 -2
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +1 -1
- package/lib/esm/Importer/Stepper/index.js +36 -13
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.d.ts +2 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +15 -79
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +2 -2
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +11 -3
- package/lib/esm/Importer/Uploader/HeadersPreview.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/DataSetContextProvider/index.d.ts +16 -0
- package/lib/esm/Importer/common/Spreadsheet/DataSetContextProvider/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.d.ts +19 -0
- package/lib/esm/Importer/common/Spreadsheet/DuplicateDataContextProvider/index.js +155 -0
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.d.ts +29 -0
- package/lib/esm/Importer/common/Spreadsheet/FilteredDataContextProvider/index.js +150 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.d.ts +6 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +38 -45
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.d.ts +7 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/hashCalculators.js +152 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +7 -30
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +10 -141
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useBatchProcessing.js +81 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +8 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.d.ts +31 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.js +324 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +18 -9
- package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -3
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.d.ts +0 -2
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +26 -11
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.d.ts +6 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.js +88 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +25 -17
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +48 -47
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +3 -3
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +7 -3
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.d.ts +3 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +45 -11
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +12 -5
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +81 -26
- 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/index.js +1 -2
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/index.js +1 -84
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.js +13 -1
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +35 -13
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/dateTimeAutoformatUtils.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/dateTimeAutoformatUtils.js +231 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/index.d.ts +18 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators/index.js +179 -0
- package/lib/esm/Importer/common/Spreadsheet/useFieldSorting.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/useFieldSorting.js +81 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.d.ts +5 -3
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +13 -17
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +3 -2
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +23 -7
- package/lib/esm/Importer/common/theme.d.ts +1 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +13 -4
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +150 -21
- package/lib/esm/Importer/data/index.d.ts +7 -3
- package/lib/esm/Importer/data/index.js +49 -20
- package/lib/esm/Importer/hooks/useExportDataToFile.d.ts +5 -0
- package/lib/esm/Importer/hooks/useExportDataToFile.js +54 -0
- package/lib/esm/Importer/hooks/useSubmitToServer.d.ts +7 -0
- package/lib/esm/Importer/hooks/useSubmitToServer.js +214 -0
- package/lib/esm/Importer/index.d.ts +4 -3
- package/lib/esm/Importer/index.js +2 -2
- package/lib/esm/common/CircleSpinner.d.ts +1 -0
- package/lib/esm/common/CircleSpinner.js +13 -0
- package/lib/esm/common/ConfirmationModal.js +1 -1
- package/lib/esm/common/EventManagerContextProvider/index.d.ts +22 -0
- package/lib/esm/common/EventManagerContextProvider/index.js +38 -0
- package/lib/esm/common/FileUploadDropzone/ImporterDropzone.d.ts +16 -0
- package/lib/esm/common/FileUploadDropzone/ImporterDropzone.js +143 -0
- package/lib/esm/common/FileUploadDropzone/index.d.ts +1 -0
- package/lib/esm/common/FileUploadDropzone/index.js +1 -0
- package/lib/esm/common/Modal.js +2 -2
- package/lib/esm/common/Table/TableActions/CustomActions/CustomActions.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/CustomActions/CustomActions.js +150 -0
- package/lib/esm/common/Table/TableActions/CustomActions/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/CustomActions/index.js +1 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +25 -8
- package/lib/esm/common/Table/TableActions/ExportData.js +5 -3
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +41 -10
- package/lib/esm/common/Table/TableActions/RowFilters.js +63 -11
- package/lib/esm/common/Table/TableActions/SearchRows.js +28 -17
- package/lib/esm/common/Table/TableActions/TableActions.js +15 -4
- package/lib/esm/common/Table/TableActions/TableActions.styles.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +4 -3
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +71 -0
- package/lib/esm/common/Table/TableActions/ValidationProgress.d.ts +2 -0
- package/lib/esm/common/Table/TableActions/ValidationProgress.js +22 -0
- package/lib/esm/common/Table/TableActions/icons.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/icons.js +3 -0
- package/lib/esm/common/Table/TableActions/useFindAndReplace.d.ts +5 -0
- package/lib/esm/common/Table/TableActions/useFindAndReplace.js +45 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +1 -1
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +3 -3
- package/lib/esm/common/Table/TableView/TableRows/index.js +21 -6
- package/lib/esm/common/Table/TableView/index.d.ts +1 -1
- package/lib/esm/common/Table/TableView/index.js +7 -16
- package/lib/esm/common/Table/TableView/types.d.ts +9 -9
- package/lib/esm/common/Table/index.d.ts +2 -1
- package/lib/esm/common/Table/index.js +2 -2
- package/lib/esm/common/Toast.d.ts +42 -3
- package/lib/esm/common/Toast.js +56 -18
- package/lib/esm/common/TooltipProvider.d.ts +2 -0
- package/lib/esm/common/TooltipProvider.js +12 -9
- package/lib/esm/common/buttons.d.ts +5 -1
- package/lib/esm/common/buttons.js +19 -13
- package/lib/esm/common/columnsTransformations.d.ts +1 -0
- package/lib/esm/common/columnsTransformations.js +10 -16
- package/lib/esm/common/columnsValidations.d.ts +0 -26
- package/lib/esm/common/columnsValidations.js +1 -31
- package/lib/esm/common/datePatterns.d.ts +26 -0
- package/lib/esm/common/datePatterns.js +327 -0
- package/lib/esm/common/icons/index.d.ts +4 -0
- package/lib/esm/common/icons/index.js +6 -2
- package/lib/esm/common/index.d.ts +2 -0
- package/lib/esm/common/index.js +2 -0
- package/lib/esm/common/inputs/Autocomplete.js +2 -2
- package/lib/esm/common/inputs/Checkbox.d.ts +2 -1
- package/lib/esm/common/inputs/Checkbox.js +9 -7
- package/lib/esm/common/inputs/SelectMenu.d.ts +2 -1
- package/lib/esm/common/inputs/SelectMenu.js +14 -3
- package/lib/esm/common/inputs/TextInput.js +1 -1
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +9 -2
- package/lib/esm/locales/de.d.ts +13 -1
- package/lib/esm/locales/de.js +13 -1
- package/lib/esm/locales/en.d.ts +26 -1
- package/lib/esm/locales/en.js +29 -4
- package/lib/esm/locales/es.d.ts +13 -1
- package/lib/esm/locales/es.js +13 -1
- package/lib/esm/locales/fr.d.ts +13 -1
- package/lib/esm/locales/fr.js +13 -1
- package/lib/esm/styled/theme/colorPalette.d.ts +2 -0
- package/lib/esm/styled/theme/colorPalette.js +1 -0
- package/lib/esm/styled/theme/index.d.ts +1 -0
- package/lib/esm/styled/theme/textCss.js +1 -1
- package/lib/esm/types.d.ts +48 -5
- package/lib/esm/types.js +0 -1
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +4 -0
- package/lib/main.js +24 -24
- package/package.json +7 -6
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.d.ts +0 -8
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +0 -33
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.d.ts +0 -5
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +0 -19
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.d.ts +0 -3
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +0 -14
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +0 -34
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +0 -254
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.d.ts +0 -8
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +0 -106
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.d.ts +0 -11
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +0 -35
- package/lib/esm/common/Table/TableActions/hooks.d.ts +0 -18
- package/lib/esm/common/Table/TableActions/hooks.js +0 -41
- package/lib/esm/common/Table/TableView/CustomScrollbar.d.ts +0 -2
- package/lib/esm/common/Table/TableView/CustomScrollbar.js +0 -34
|
@@ -0,0 +1,324 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
58
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
59
|
+
import { useAppLoadingContext } from "../../../../common/AppLoadingContextProvider";
|
|
60
|
+
import { useEventManagerContext } from "../../../../common/EventManagerContextProvider";
|
|
61
|
+
import { useImporterContext } from "../../../contexts/ImporterContextProvider";
|
|
62
|
+
import { useDataSetContext } from "../DataSetContextProvider";
|
|
63
|
+
import { useDuplicateDataContext } from "../DuplicateDataContextProvider";
|
|
64
|
+
import { useBatchProcessing } from "../SpreadsheetContextProvider/useBatchProcessing";
|
|
65
|
+
import { selectValidatorsFor, validateRecord } from "../validation";
|
|
66
|
+
// this is the fastest check for empty object as per
|
|
67
|
+
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object/785768#785768
|
|
68
|
+
var isObjectEmpty = function (obj) {
|
|
69
|
+
for (var i in obj) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
var checkIfHasErrors = function (_errors) {
|
|
75
|
+
return _errors && !isObjectEmpty(_errors);
|
|
76
|
+
};
|
|
77
|
+
var calculateFieldCountChangeInRecord = function (prevCountsInRecord, currCountsInRecord, globalFieldCounts, totalGlobalFieldCount) {
|
|
78
|
+
if (prevCountsInRecord === void 0) { prevCountsInRecord = {}; }
|
|
79
|
+
if (currCountsInRecord === void 0) { currCountsInRecord = {}; }
|
|
80
|
+
if (totalGlobalFieldCount === void 0) { totalGlobalFieldCount = null; }
|
|
81
|
+
var allFieldsInRecord = new Set(__spreadArray(__spreadArray([], Object.keys(prevCountsInRecord), true), Object.keys(currCountsInRecord), true));
|
|
82
|
+
allFieldsInRecord.forEach(function (fieldName) {
|
|
83
|
+
var _a;
|
|
84
|
+
var countChangeInRecord = (currCountsInRecord[fieldName] ? 1 : 0) -
|
|
85
|
+
(prevCountsInRecord[fieldName] ? 1 : 0);
|
|
86
|
+
if (!countChangeInRecord)
|
|
87
|
+
return;
|
|
88
|
+
globalFieldCounts.current = __assign(__assign({}, globalFieldCounts.current), (_a = {}, _a[fieldName] = (globalFieldCounts.current[fieldName] || 0) + countChangeInRecord, _a));
|
|
89
|
+
if (totalGlobalFieldCount)
|
|
90
|
+
totalGlobalFieldCount.current += countChangeInRecord;
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export var ValidationContext = createContext({});
|
|
94
|
+
export var ValidationContextProvider = function (_a) {
|
|
95
|
+
var fields = _a.fields, isReadOnly = _a.isReadOnly, onValidateRecord = _a.onValidateRecord, children = _a.children;
|
|
96
|
+
var errors = useRef({});
|
|
97
|
+
var warnings = useRef({});
|
|
98
|
+
var _b = useState(0), validationPercentage = _b[0], setValidationPercentage = _b[1];
|
|
99
|
+
var validatorsCache = useMemo(function () { return selectValidatorsFor(fields); }, [fields]);
|
|
100
|
+
var setIsLoadingApp = useAppLoadingContext().setIsLoadingApp;
|
|
101
|
+
var columnsWithErrorCounts = useRef({});
|
|
102
|
+
var columnsWithWarningCounts = useRef({});
|
|
103
|
+
var totalErrorCount = useRef(0);
|
|
104
|
+
var invalidRowsCountRef = useRef(0);
|
|
105
|
+
var _c = useEventManagerContext(), emit = _c.emit, EVENTS = _c.EVENTS;
|
|
106
|
+
var _d = useDataSetContext(), getRecord = _d.getRecord, setRecord = _d.setRecord, dataSet = _d.dataSet, dataSetLength = _d.dataSetLength;
|
|
107
|
+
var _e = useDuplicateDataContext(), duplicateValues = _e.duplicateValues, updateDuplicateValues = _e.updateDuplicateValues, resetDuplicateProvider = _e.resetDuplicateProvider;
|
|
108
|
+
var processRecordsInBatches = useBatchProcessing(10000).processRecordsInBatches;
|
|
109
|
+
var _f = useState(false), spreadsheetInitialized = _f[0], setSpreadsheetInitialized = _f[1];
|
|
110
|
+
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
111
|
+
var _g = useState(false), dataSetChanged = _g[0], setDataSetChanged = _g[1];
|
|
112
|
+
var reset = function () {
|
|
113
|
+
columnsWithErrorCounts.current = {};
|
|
114
|
+
columnsWithWarningCounts.current = {};
|
|
115
|
+
totalErrorCount.current = 0;
|
|
116
|
+
invalidRowsCountRef.current = 0;
|
|
117
|
+
errors.current = {};
|
|
118
|
+
warnings.current = {};
|
|
119
|
+
setSpreadsheetInitialized(false);
|
|
120
|
+
setDataSetChanged(function (prev) { return !prev; });
|
|
121
|
+
};
|
|
122
|
+
var calculateColumnErrorCounts = function (oldErrors, newErrors) {
|
|
123
|
+
if (oldErrors === void 0) { oldErrors = {}; }
|
|
124
|
+
if (newErrors === void 0) { newErrors = {}; }
|
|
125
|
+
if (Object.keys(oldErrors).length === 0 &&
|
|
126
|
+
Object.keys(newErrors).length > 0)
|
|
127
|
+
invalidRowsCountRef.current += 1;
|
|
128
|
+
if (Object.keys(oldErrors).length > 0 &&
|
|
129
|
+
Object.keys(newErrors).length === 0)
|
|
130
|
+
invalidRowsCountRef.current -= 1;
|
|
131
|
+
calculateFieldCountChangeInRecord(oldErrors, newErrors, columnsWithErrorCounts, totalErrorCount);
|
|
132
|
+
};
|
|
133
|
+
var calculateColumnWarningCounts = function (oldWarnings, newWarnings) {
|
|
134
|
+
if (oldWarnings === void 0) { oldWarnings = {}; }
|
|
135
|
+
if (newWarnings === void 0) { newWarnings = {}; }
|
|
136
|
+
calculateFieldCountChangeInRecord(oldWarnings, newWarnings, columnsWithWarningCounts);
|
|
137
|
+
};
|
|
138
|
+
var batchValidationDelayMs = 100;
|
|
139
|
+
var sleep = function (n) { return new Promise(function (resolve) { return setTimeout(resolve, n); }); };
|
|
140
|
+
var getBackendErrors = function (record) {
|
|
141
|
+
var _a;
|
|
142
|
+
var recordBackendErrors = (_a = record === null || record === void 0 ? void 0 : record._meta) === null || _a === void 0 ? void 0 : _a.backendErrors;
|
|
143
|
+
return recordBackendErrors || null;
|
|
144
|
+
};
|
|
145
|
+
var _validateRecord = function (record, initialValidation) {
|
|
146
|
+
if (initialValidation === void 0) { initialValidation = false; }
|
|
147
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
var recordId, oldRecord, newRecord, backendErrors, _a, recordErrors, recordWarnings, hasError, hasWarning;
|
|
149
|
+
return __generator(this, function (_b) {
|
|
150
|
+
switch (_b.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
if (!record)
|
|
153
|
+
return [2 /*return*/];
|
|
154
|
+
recordId = record._meta.id;
|
|
155
|
+
oldRecord = getRecord(recordId);
|
|
156
|
+
updateDuplicateValues(oldRecord, record, initialValidation, updateRecordAndRevalidate);
|
|
157
|
+
newRecord = setRecord(recordId, __assign({}, record));
|
|
158
|
+
backendErrors = getBackendErrors(record);
|
|
159
|
+
return [4 /*yield*/, validateRecord({
|
|
160
|
+
validatorsCache: validatorsCache,
|
|
161
|
+
onValidateRecord: onValidateRecord,
|
|
162
|
+
fields: fields,
|
|
163
|
+
record: newRecord,
|
|
164
|
+
duplicateValues: duplicateValues,
|
|
165
|
+
backendErrors: backendErrors,
|
|
166
|
+
})];
|
|
167
|
+
case 1:
|
|
168
|
+
_a = _b.sent(), recordErrors = _a.errors, recordWarnings = _a.warnings;
|
|
169
|
+
calculateColumnErrorCounts(errors.current[recordId], recordErrors);
|
|
170
|
+
calculateColumnWarningCounts(warnings.current[recordId], recordWarnings);
|
|
171
|
+
hasError = checkIfHasErrors(recordErrors);
|
|
172
|
+
hasWarning = checkIfHasErrors(recordWarnings);
|
|
173
|
+
newRecord._meta.isInvalid = hasError;
|
|
174
|
+
newRecord._meta.hasWarning = hasWarning;
|
|
175
|
+
if (hasError) {
|
|
176
|
+
errors.current[recordId] = recordErrors;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
delete errors.current[recordId];
|
|
180
|
+
}
|
|
181
|
+
if (hasWarning) {
|
|
182
|
+
warnings.current[recordId] = recordWarnings;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
delete warnings.current[recordId];
|
|
186
|
+
}
|
|
187
|
+
if (backendErrors && spreadsheetInitialized) {
|
|
188
|
+
record._meta.backendErrors = {};
|
|
189
|
+
}
|
|
190
|
+
emit(recordId, newRecord);
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
var updateValidationPercentage = function (recordsValidated, totalRecords) {
|
|
197
|
+
var validationPercentage = (Math.min(recordsValidated, totalRecords) / totalRecords) * 100;
|
|
198
|
+
setValidationPercentage(Math.round((validationPercentage + Number.EPSILON) * 10) / 10);
|
|
199
|
+
};
|
|
200
|
+
// Validate record and update dataSet
|
|
201
|
+
var updateRecordAndRevalidate = function (records, initialValidation, loadingIndicator) {
|
|
202
|
+
if (initialValidation === void 0) { initialValidation = false; }
|
|
203
|
+
if (loadingIndicator === void 0) { loadingIndicator = true; }
|
|
204
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
205
|
+
var recordsArray, length, recordsProcessed;
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0:
|
|
209
|
+
recordsArray = Array.isArray(records) ? records : [records];
|
|
210
|
+
length = recordsArray.length;
|
|
211
|
+
if (!(loadingIndicator && length > 10000)) return [3 /*break*/, 2];
|
|
212
|
+
setIsLoadingApp(true);
|
|
213
|
+
// wait for the first render to complete
|
|
214
|
+
// before blocking main thread with review step logic
|
|
215
|
+
return [4 /*yield*/, sleep(200)];
|
|
216
|
+
case 1:
|
|
217
|
+
// wait for the first render to complete
|
|
218
|
+
// before blocking main thread with review step logic
|
|
219
|
+
_a.sent();
|
|
220
|
+
_a.label = 2;
|
|
221
|
+
case 2:
|
|
222
|
+
recordsProcessed = 0;
|
|
223
|
+
return [4 /*yield*/, processRecordsInBatches(recordsArray, function (batch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
+
var i, record;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
i = 0;
|
|
229
|
+
_a.label = 1;
|
|
230
|
+
case 1:
|
|
231
|
+
if (!(i < batch.length)) return [3 /*break*/, 4];
|
|
232
|
+
record = batch[i];
|
|
233
|
+
return [4 /*yield*/, _validateRecord(record, initialValidation)];
|
|
234
|
+
case 2:
|
|
235
|
+
_a.sent();
|
|
236
|
+
recordsProcessed += 1;
|
|
237
|
+
_a.label = 3;
|
|
238
|
+
case 3:
|
|
239
|
+
i++;
|
|
240
|
+
return [3 /*break*/, 1];
|
|
241
|
+
case 4:
|
|
242
|
+
updateValidationPercentage(recordsProcessed, length);
|
|
243
|
+
emit(EVENTS.UPDATE_COLUMN_ERROR_COUNT);
|
|
244
|
+
emit(EVENTS.UPDATE_TOTAL_ERROR_COUNT);
|
|
245
|
+
emit(EVENTS.UPDATE_TOTAL_ROW_COUNT);
|
|
246
|
+
return [4 /*yield*/, sleep(batchValidationDelayMs)];
|
|
247
|
+
case 5:
|
|
248
|
+
_a.sent();
|
|
249
|
+
return [2 /*return*/];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}); })];
|
|
253
|
+
case 3:
|
|
254
|
+
_a.sent();
|
|
255
|
+
if (loadingIndicator) {
|
|
256
|
+
setIsLoadingApp(false);
|
|
257
|
+
}
|
|
258
|
+
return [2 /*return*/];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
// Initial data validation and update dataSet
|
|
264
|
+
useEffect(function () {
|
|
265
|
+
if (dataSet.current && !isReadOnly) {
|
|
266
|
+
resetDuplicateProvider();
|
|
267
|
+
}
|
|
268
|
+
reset();
|
|
269
|
+
}, [dataSet.current]);
|
|
270
|
+
useEffect(function () {
|
|
271
|
+
var isDataSetInvalid = !dataSet.current || dataSetLength.current === 0;
|
|
272
|
+
if (isDataSetInvalid ||
|
|
273
|
+
isReadOnly ||
|
|
274
|
+
currentStepIndex !== 2 ||
|
|
275
|
+
(fields === null || fields === void 0 ? void 0 : fields.length) === 0)
|
|
276
|
+
return;
|
|
277
|
+
var initialValidation = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
278
|
+
var initialData;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
initialData = Object.values(dataSet.current);
|
|
283
|
+
if (!(initialData.length > 0)) return [3 /*break*/, 2];
|
|
284
|
+
setIsLoadingApp(true);
|
|
285
|
+
return [4 /*yield*/, updateRecordAndRevalidate(initialData, true)];
|
|
286
|
+
case 1:
|
|
287
|
+
_a.sent();
|
|
288
|
+
_a.label = 2;
|
|
289
|
+
case 2: return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}); };
|
|
293
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
294
|
+
return __generator(this, function (_a) {
|
|
295
|
+
switch (_a.label) {
|
|
296
|
+
case 0: return [4 /*yield*/, initialValidation()];
|
|
297
|
+
case 1:
|
|
298
|
+
_a.sent();
|
|
299
|
+
setSpreadsheetInitialized(true);
|
|
300
|
+
return [2 /*return*/];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}); })();
|
|
304
|
+
}, [currentStepIndex, dataSetChanged]);
|
|
305
|
+
var isValidationCompleted = validationPercentage === 100;
|
|
306
|
+
var isValid = isValidationCompleted && totalErrorCount.current === 0;
|
|
307
|
+
var value = {
|
|
308
|
+
errors: errors,
|
|
309
|
+
warnings: warnings,
|
|
310
|
+
totalErrorCount: totalErrorCount,
|
|
311
|
+
invalidRowsCountRef: invalidRowsCountRef,
|
|
312
|
+
columnsWithErrorCounts: columnsWithErrorCounts,
|
|
313
|
+
columnsWithWarningCounts: columnsWithWarningCounts,
|
|
314
|
+
calculateColumnErrorCounts: calculateColumnErrorCounts,
|
|
315
|
+
calculateColumnWarningCounts: calculateColumnWarningCounts,
|
|
316
|
+
validationPercentage: validationPercentage,
|
|
317
|
+
isValidationCompleted: isValidationCompleted,
|
|
318
|
+
isValid: isValid,
|
|
319
|
+
updateRecordAndRevalidate: updateRecordAndRevalidate,
|
|
320
|
+
spreadsheetInitialized: spreadsheetInitialized,
|
|
321
|
+
};
|
|
322
|
+
return (_jsx(ValidationContext.Provider, __assign({ value: value }, { children: children })));
|
|
323
|
+
};
|
|
324
|
+
export var useValidationContext = function () { return useContext(ValidationContext); };
|
|
@@ -5,17 +5,17 @@ export var isNullOrUndefined = function (value) {
|
|
|
5
5
|
return value === null || value === undefined;
|
|
6
6
|
};
|
|
7
7
|
export var isEmpty = function (value) {
|
|
8
|
-
return (value
|
|
9
|
-
value === null ||
|
|
8
|
+
return (isNullOrUndefined(value) ||
|
|
10
9
|
(typeof value === "object" && Object.keys(value).length === 0) ||
|
|
11
|
-
(typeof value === "string" &&
|
|
10
|
+
(typeof value === "string" &&
|
|
11
|
+
(value.length === 0 || value.trim().length === 0)));
|
|
12
12
|
};
|
|
13
13
|
export var isEmail = function (value) {
|
|
14
14
|
var emailRegex = /^[\w+.-]+@([\w-]+\.)+[\w-]{2,4}$/;
|
|
15
15
|
return emailRegex.test(value);
|
|
16
16
|
};
|
|
17
17
|
export var isUrl = function (value) {
|
|
18
|
-
var urlRegex = /^(
|
|
18
|
+
var urlRegex = /^(?:(?:https?|ftp|file|tcp|mailto|tel|data|ssh|irc|gopher|ws|wss):\/\/|www\.)[A-Za-z0-9]+([\-\.]{1}[A-Za-z0-9]+)*\.[A-Za-z]{2,16}(:[0-9]{1,5})?(\/.*)?$/g;
|
|
19
19
|
return urlRegex.test(value);
|
|
20
20
|
};
|
|
21
21
|
export var isTrue = function (value) {
|
|
@@ -46,15 +46,24 @@ export var ignoreNullOrUndefinedKeyValues = function (obj) {
|
|
|
46
46
|
return result;
|
|
47
47
|
};
|
|
48
48
|
export var isRecordEmpty = function (record, fields) {
|
|
49
|
-
|
|
49
|
+
var hasValue = fields.some(function (f) { return !isEmpty(record[f.name]); });
|
|
50
|
+
return !hasValue;
|
|
50
51
|
};
|
|
51
52
|
export var parseValue = function (fieldType, value, enumSet) {
|
|
52
53
|
if (isEmpty(value))
|
|
53
54
|
return value;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
var cleanNumber = function (val) {
|
|
56
|
+
// Remove all non-numeric characters except the decimal point.
|
|
57
|
+
return typeof val === "string" ? val.replace(/[^\d.]/g, "") : val;
|
|
58
|
+
};
|
|
59
|
+
if (fieldType === FieldTypes.float) {
|
|
60
|
+
var cleanedValue = cleanNumber(value);
|
|
61
|
+
return isFloat(cleanedValue) ? parseFloat(cleanedValue) : value;
|
|
62
|
+
}
|
|
63
|
+
if (fieldType === FieldTypes.integer) {
|
|
64
|
+
var cleanedValue = cleanNumber(value);
|
|
65
|
+
return isInteger(cleanedValue) ? parseInt(cleanedValue, 10) : value;
|
|
66
|
+
}
|
|
58
67
|
if (fieldType === FieldTypes.boolean)
|
|
59
68
|
return isTrue(value) ? true : false;
|
|
60
69
|
if (fieldType === FieldTypes.enum && enumSet)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DivCSSProps } from "../../../../styled";
|
|
3
|
-
import {
|
|
4
|
-
import { OnDataSetChanged
|
|
3
|
+
import { Field, OnValidateRecord, Record, RecordDataSet, SpreadsheetOptions } from "../../../../types";
|
|
4
|
+
import { OnDataSetChanged } from "../SpreadsheetContextProvider";
|
|
5
5
|
export declare enum SortOrder {
|
|
6
6
|
ASC = "asc",
|
|
7
7
|
DESC = "desc"
|
|
@@ -18,7 +18,6 @@ export type SpreadsheetProps = {
|
|
|
18
18
|
options?: SpreadsheetOptions;
|
|
19
19
|
onValidateRecord?: OnValidateRecord;
|
|
20
20
|
onDataSetChanged?: OnDataSetChanged;
|
|
21
|
-
onValidationStateChanged?: OnValidationStateChanged;
|
|
22
21
|
selectedRows?: string[];
|
|
23
22
|
setSelectedRows?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
24
23
|
getSortCompareFn?: (sortBy: SortBy) => (a: Record, b: Record) => number;
|
|
@@ -7,8 +7,6 @@ type SortIndicatorProps = {
|
|
|
7
7
|
export declare const SortIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps & SortIndicatorProps, never>;
|
|
8
8
|
export type FieldHeaderProps = {
|
|
9
9
|
field: Field;
|
|
10
|
-
sortByFieldErrors: (name: string) => void;
|
|
11
|
-
sortByFieldWarnings: (name: string) => void;
|
|
12
10
|
};
|
|
13
11
|
export declare const FieldHeader: React.FC<FieldHeaderProps>;
|
|
14
12
|
export declare const chevronDown: JSX.Element;
|
|
@@ -14,11 +14,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
return __assign.apply(this, arguments);
|
|
15
15
|
};
|
|
16
16
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
import {
|
|
17
|
+
import { useEffect, useState } from "react";
|
|
18
18
|
import styled, { css } from "styled-components";
|
|
19
19
|
import { TooltipProvider } from "../../../../common";
|
|
20
|
+
import { useEventManagerContext } from "../../../../common/EventManagerContextProvider";
|
|
21
|
+
import { colors } from "../../../../styled/theme/colorPalette";
|
|
20
22
|
import { Div } from "../../../../styled/utils";
|
|
21
|
-
import {
|
|
23
|
+
import { useFilteredDataContext } from "../FilteredDataContextProvider";
|
|
24
|
+
import { useValidationContext } from "../ValidationContextProvider";
|
|
22
25
|
import { SortOrder } from "../common/types";
|
|
23
26
|
var ErrorCount = styled(Div)(function (_a) {
|
|
24
27
|
var _b = _a.theme, colors = _b.colors, c = _b.css;
|
|
@@ -28,11 +31,23 @@ export var SortIndicator = styled(Div)(templateObject_3 || (templateObject_3 = _
|
|
|
28
31
|
return p.direction === SortOrder.ASC && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n transform: rotate(180deg);\n "], ["\n transform: rotate(180deg);\n "])));
|
|
29
32
|
}, function (p) { return p.theme.colors.gray300; });
|
|
30
33
|
export var FieldHeader = function (_a) {
|
|
31
|
-
var field = _a.field
|
|
32
|
-
var _b =
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var field = _a.field;
|
|
35
|
+
var _b = useValidationContext(), columnsWithErrorCounts = _b.columnsWithErrorCounts, columnsWithWarningCounts = _b.columnsWithWarningCounts;
|
|
36
|
+
var _c = useFilteredDataContext(), handleSortByFieldErrors = _c.handleSortByFieldErrors, handleSortByFieldWarnings = _c.handleSortByFieldWarnings, sortBy = _c.sortBy, setSortBy = _c.setSortBy, spreadsheetFilter = _c.spreadsheetFilter, filteredInputValue = _c.filteredInputValue;
|
|
37
|
+
var _d = useEventManagerContext(), on = _d.on, off = _d.off, EVENTS = _d.EVENTS;
|
|
38
|
+
var _e = useState(columnsWithErrorCounts.current[field.name] || null), fieldErrorCount = _e[0], setFieldErrorCount = _e[1];
|
|
39
|
+
var _f = useState(columnsWithWarningCounts.current[field.name] || null), fieldWarningCount = _f[0], setFieldWarningCount = _f[1];
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
var listener = function () {
|
|
42
|
+
setFieldErrorCount(columnsWithErrorCounts.current[field.name] || null);
|
|
43
|
+
};
|
|
44
|
+
on(EVENTS.UPDATE_COLUMN_ERROR_COUNT, listener);
|
|
45
|
+
return function () {
|
|
46
|
+
off(EVENTS.UPDATE_COLUMN_ERROR_COUNT, listener);
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
var shouldRenderErrorCount = fieldErrorCount !== null &&
|
|
50
|
+
fieldErrorCount > 0 &&
|
|
36
51
|
filteredInputValue === "" &&
|
|
37
52
|
spreadsheetFilter.type === "rowBased" &&
|
|
38
53
|
spreadsheetFilter.byRow === "all";
|
|
@@ -50,16 +65,16 @@ export var FieldHeader = function (_a) {
|
|
|
50
65
|
});
|
|
51
66
|
}
|
|
52
67
|
};
|
|
53
|
-
return (_jsxs(Div, __assign({ "data-test-id": "column-header-".concat(field.name), p: "0 16px", spaceBetween: true, w100: true, alignCenter: true, onClick: onHeaderClick }, { children: [_jsxs(Div, __assign({ dflex: true }, { children: [_jsxs(Div, __assign({ truncateText: true, selectNone: true }, { children: [field.label, field.isRequired && "*"] })), _jsx(Div, __assign({ ml: 8, centered: true }, { children: (sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === field.name && (_jsx(SortIndicator, __assign({ direction: sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction }, { children: chevronDown }))) }))] })), shouldRenderErrorCount && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ "data-test-id": "column-errors-count-".concat(field.name), onClick: function (ev) {
|
|
68
|
+
return (_jsxs(Div, __assign({ "data-cy": "column-header", "data-test-id": "column-header-".concat(field.name), p: "0 16px", spaceBetween: true, w100: true, alignCenter: true, onClick: onHeaderClick }, { children: [_jsxs(Div, __assign({ dflex: true }, { children: [_jsxs(Div, __assign({ truncateText: true, selectNone: true }, { children: [field.label, field.isRequired && "*"] })), _jsx(Div, __assign({ ml: 8, centered: true }, { children: (sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === field.name && (_jsx(SortIndicator, __assign({ direction: sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction }, { children: chevronDown }))) }))] })), shouldRenderErrorCount && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, "data-cy": "tool-tip-message", tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ "data-cy": "column-error", "data-test-id": "column-errors-count-".concat(field.name), onClick: function (ev) {
|
|
54
69
|
ev.stopPropagation();
|
|
55
|
-
|
|
56
|
-
} }, { children: _jsx(Div, __assign({ centered: true }, { children: _jsx(Div, __assign({ w: 35, textAlignCenter: true, label3: true, truncateText: true }, { children: fieldErrorCount })) })) })) }))), !fieldErrorCount && fieldWarningCount && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ style: {
|
|
70
|
+
handleSortByFieldErrors(field.name);
|
|
71
|
+
} }, { children: _jsx(Div, __assign({ centered: true }, { children: _jsx(Div, __assign({ w: 35, textAlignCenter: true, label3: true, truncateText: true }, { children: fieldErrorCount })) })) })) }))), !fieldErrorCount && fieldWarningCount !== null && fieldWarningCount > 0 && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ style: {
|
|
57
72
|
color: colors.orange1200,
|
|
58
73
|
background: colors.orange1100,
|
|
59
74
|
boxShadow: "0px 0px 0px 1px ".concat(colors.orange500, " inset"),
|
|
60
75
|
}, "data-test-id": "column-errors-count-".concat(field.name), onClick: function (ev) {
|
|
61
76
|
ev.stopPropagation();
|
|
62
|
-
|
|
77
|
+
handleSortByFieldWarnings(field.name);
|
|
63
78
|
} }, { children: _jsx(Div, __assign({ centered: true }, { children: _jsx(Div, __assign({ w: 35, textAlignCenter: true, label3: true, truncateText: true }, { children: fieldWarningCount })) })) })) })))] })));
|
|
64
79
|
};
|
|
65
80
|
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" }) })));
|
|
@@ -0,0 +1,88 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { Div } from "../../../../../styled";
|
|
50
|
+
import { Button, Modal, addToast } from "../../../../../common";
|
|
51
|
+
import { useTranslation } from "react-i18next";
|
|
52
|
+
import { TextInput } from "../../../../../common/inputs/TextInput";
|
|
53
|
+
import { Checkbox } from "../../../../../common";
|
|
54
|
+
import { useState } from "react";
|
|
55
|
+
import { useDataSetManipulation } from "../../SpreadsheetContextProvider/useDataSetManipulation";
|
|
56
|
+
import { useFilteredDataContext } from "../../FilteredDataContextProvider";
|
|
57
|
+
export var FindAndReplaceModal = function (_a) {
|
|
58
|
+
var initialText = _a.initialText, onClose = _a.onClose;
|
|
59
|
+
var t = useTranslation("general").t;
|
|
60
|
+
var _b = useState(initialText), searchText = _b[0], setSearchText = _b[1];
|
|
61
|
+
var _c = useState(""), replaceText = _c[0], setReplaceText = _c[1];
|
|
62
|
+
var findAndReplaceInSpreadsheet = useDataSetManipulation().findAndReplaceInSpreadsheet;
|
|
63
|
+
var _d = useState(false), useRegex = _d[0], setUseRegex = _d[1];
|
|
64
|
+
var _e = useState(true), matchCase = _e[0], setMatchCase = _e[1];
|
|
65
|
+
var setFilteredInputValue = useFilteredDataContext().setFilteredInputValue;
|
|
66
|
+
var findAndReplace = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
var records;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0: return [4 /*yield*/, findAndReplaceInSpreadsheet(searchText, replaceText, matchCase, useRegex)];
|
|
71
|
+
case 1:
|
|
72
|
+
records = _a.sent();
|
|
73
|
+
if (records.length > 0) {
|
|
74
|
+
addToast(t("find_and_replace_modal.records_replaced", {
|
|
75
|
+
length: records.length,
|
|
76
|
+
}), "success");
|
|
77
|
+
onClose();
|
|
78
|
+
setFilteredInputValue("");
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
addToast(t("find_and_replace_modal.no_records_found"), "error");
|
|
82
|
+
}
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}); };
|
|
87
|
+
return (_jsx(Modal, __assign({ isOpen: true, onClose: function () { return onClose(); } }, { children: _jsxs(Div, __assign({ p: "17px 20px", w: 500 }, { children: [_jsx(Div, __assign({ textAlignCenter: true, h5: true }, { children: t("find_and_replace_modal.title") })), _jsx(Div, __assign({ mt: 20, mb: 20, textAlignCenter: true, body1: true }, { children: t("find_and_replace_modal.description") })), _jsxs(Div, __assign({ mb: 20, w: 500, textAlignCenter: true, body1: true }, { children: [_jsx(TextInput, { "data-cy": "find-input", mb: 20, name: t("find_and_replace_modal.find"), label: t("find_and_replace_modal.find"), value: searchText, onChange: function (value) { return setSearchText(value); } }), _jsx(TextInput, { "data-cy": "replace-input", label: t("find_and_replace_modal.replace_with"), value: replaceText, onChange: function (value) { return setReplaceText(value); } })] })), _jsx(Div, __assign({ mb: 12 }, { children: _jsx(Checkbox, { "data-cy": "use-regex", label: t("find_and_replace_modal.use_regex"), isChecked: useRegex, onChange: function (v) { return setUseRegex(v); } }) })), _jsx(Div, __assign({ mb: 12 }, { children: _jsx(Checkbox, { "data-cy": "case-sensitive", label: t("find_and_replace_modal.use_case_sensitive"), isChecked: matchCase, onChange: function (v) { return setMatchCase(v); } }) })), _jsxs(Div, __assign({ dflex: true, centered: true, mt: 40 }, { children: [_jsx(Button, __assign({ variant: "secondary", onClick: function () { return onClose(); }, w: 160, mr: 16 }, { children: t("find_and_replace_modal.cancel") })), _jsx(Button, __assign({ "data-cy": "find-replace-submit", variant: "primary", onClick: function () { return findAndReplace(); } }, { children: t("find_and_replace_modal.submit") }))] }))] })) })));
|
|
88
|
+
};
|