fuse-importer 0.0.8-testing → 0.1.1-testing
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/ImporterWithContext.js +63 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +68 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +58 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.js +21 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +23 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +61 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +55 -0
- package/lib/esm/Importer/Matcher/common/icons/index.js +14 -0
- package/lib/esm/Importer/Matcher/common/index.js +39 -0
- package/lib/esm/Importer/Matcher/common/types.js +9 -0
- package/lib/esm/Importer/Matcher/index.js +22 -0
- package/lib/esm/Importer/PreviewFirstTime.js +81 -0
- package/lib/esm/Importer/PreviewModeBanner.js +19 -0
- package/lib/esm/Importer/Review/AppResponseModal.js +35 -0
- package/lib/esm/Importer/Review/ReviewContextProvider.js +318 -0
- package/lib/esm/Importer/Review/ReviewWithContext.js +33 -0
- package/lib/esm/Importer/Review/index.js +4 -0
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +24 -0
- package/lib/esm/Importer/Stepper/Step.js +19 -0
- package/lib/esm/Importer/Stepper/StepIndex.js +27 -0
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +24 -0
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +31 -0
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +33 -0
- package/lib/esm/Importer/Stepper/common/icons.js +18 -0
- package/lib/esm/Importer/Stepper/index.js +118 -0
- package/lib/esm/Importer/TrialModeBanner.js +22 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/DragAndDropImporter.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +123 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/ImporterSectionHeader.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +44 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.js +14 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +45 -0
- package/lib/esm/Importer/Uploader/HeaderButtons.js +28 -0
- package/lib/esm/Importer/Uploader/HeadersPreview.js +44 -0
- package/lib/esm/Importer/Uploader/UploaderContextProvider.js +27 -0
- package/lib/esm/Importer/Uploader/index.js +13 -0
- package/lib/esm/Importer/common/AppLoading.js +24 -0
- package/lib/esm/Importer/common/Footer.js +17 -0
- package/lib/esm/Importer/common/FuseApi.js +48 -0
- package/lib/esm/Importer/common/GlobalStyle.js +7 -0
- package/lib/esm/Importer/common/ImporterFonts.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +56 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +176 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +66 -0
- package/lib/esm/Importer/common/Spreadsheet/components/GlobalStyle.js +9 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +110 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +186 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +55 -0
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +19 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +43 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +74 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +114 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.d.ts +11 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.js +29 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/Boolean.js +18 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.js +30 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/FloatInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/IntegerInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/StringInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +20 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +245 -0
- package/lib/esm/Importer/common/Spreadsheet/index.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/styles.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +47 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +236 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +202 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +181 -0
- package/lib/esm/Importer/common/icons/index.js +18 -0
- package/lib/esm/Importer/common/index.js +13 -0
- package/lib/esm/Importer/common/theme.js +19 -0
- package/lib/esm/Importer/common/utils.js +100 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +247 -0
- package/lib/esm/Importer/data/index.js +172 -0
- package/lib/esm/Importer/index.js +28 -0
- package/lib/esm/api/index.js +93 -0
- package/lib/esm/api/responseHandlers.js +49 -0
- package/lib/esm/common/AppLoadingContextProvider/AppLoadingUI.js +26 -0
- package/lib/esm/common/AppLoadingContextProvider/index.js +25 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Modal.js +31 -0
- package/lib/esm/common/Spinner.js +41 -0
- package/lib/esm/common/Table/Pagination/icons.js +42 -0
- package/lib/esm/common/Table/Pagination/index.js +32 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +50 -0
- package/lib/esm/common/Table/TableActions/ExportData.js +23 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +47 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +72 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +35 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +18 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +83 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/hooks.js +41 -0
- package/lib/esm/common/Table/TableActions/icons.js +17 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableDataProvider.js +127 -0
- package/lib/esm/common/Table/TableView/TableHeaders.js +69 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +57 -0
- package/lib/esm/common/Table/TableView/TableRows/index.js +48 -0
- package/lib/esm/common/Table/TableView/common/index.js +37 -0
- package/lib/esm/common/Table/TableView/index.js +132 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/icons.js +15 -0
- package/lib/esm/common/Table/index.js +140 -0
- package/lib/esm/common/Table/useReorderRows.js +83 -0
- package/lib/esm/common/Toast.js +69 -0
- package/lib/esm/common/TooltipProvider.js +57 -0
- package/lib/esm/common/buttons.js +97 -0
- package/lib/esm/common/columnsTransformations.js +94 -0
- package/lib/esm/common/columnsValidations.d.ts +1 -27
- package/lib/esm/common/columnsValidations.js +401 -0
- package/lib/esm/common/datePatterns.d.ts +26 -0
- package/lib/esm/common/datePatterns.js +327 -0
- package/lib/esm/common/icons/index.js +30 -0
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +46 -0
- package/lib/esm/common/inputs/Autocomplete.js +110 -0
- package/lib/esm/common/inputs/Checkbox.js +53 -0
- package/lib/esm/common/inputs/SelectMenu.js +74 -0
- package/lib/esm/common/inputs/TextInput.js +89 -0
- package/lib/esm/common/inputs/index.js +5 -0
- package/lib/esm/common/inputs/tooltip.js +38 -0
- package/lib/esm/common/logo.js +13 -0
- package/lib/esm/hooks/index.d.ts +1 -0
- package/lib/esm/hooks/index.js +16 -0
- package/lib/esm/index.js +218 -0
- package/lib/esm/locales/de.js +126 -0
- package/lib/esm/locales/en.js +126 -0
- package/lib/esm/locales/es.js +126 -0
- package/lib/esm/locales/fr.js +126 -0
- package/lib/esm/locales/index.js +4 -0
- package/lib/esm/styled/fontsURL.js +27 -0
- package/lib/esm/styled/index.js +3 -0
- package/lib/esm/styled/theme/animations.js +9 -0
- package/lib/esm/styled/theme/colorPalette.js +109 -0
- package/lib/esm/styled/theme/debugCss.js +16 -0
- package/lib/esm/styled/theme/dimensionsCss.js +20 -0
- package/lib/esm/styled/theme/fontCss.js +17 -0
- package/lib/esm/styled/theme/globalCss.js +26 -0
- package/lib/esm/styled/theme/index.js +33 -0
- package/lib/esm/styled/theme/layoutCss.js +26 -0
- package/lib/esm/styled/theme/mediaQueries.js +4 -0
- package/lib/esm/styled/theme/positionCss.js +27 -0
- package/lib/esm/styled/theme/textCss.js +18 -0
- package/lib/esm/styled/theme/textStyles.js +27 -0
- package/lib/esm/styled/themeType.js +6 -0
- package/lib/esm/styled/utils.js +17 -0
- package/lib/esm/types.d.ts +7 -6
- package/lib/esm/types.js +65 -0
- package/lib/esm/utils/hooks/useWindowSize.js +23 -0
- package/lib/esm/utils/hooks.js +1 -0
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +41 -0
- package/lib/main.js +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { SpreadsheetInput, } from "../fields/SpreadsheetInput";
|
|
14
|
+
export var FloatInput = function (props) {
|
|
15
|
+
return _jsx(SpreadsheetInput, __assign({}, props, { type: "text" }));
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { SpreadsheetInput, } from "../fields/SpreadsheetInput";
|
|
14
|
+
export var IntegerInput = function (props) {
|
|
15
|
+
return _jsx(SpreadsheetInput, __assign({}, props, { type: "text", step: "1" }));
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { SpreadsheetInput, } from "../fields/SpreadsheetInput";
|
|
14
|
+
export var StringInput = function (props) { return (_jsx(SpreadsheetInput, __assign({}, props, { type: "text" }))); };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { FieldTypes } from "../../../../../types";
|
|
3
|
+
import { BooleanInput } from "./Boolean";
|
|
4
|
+
import { EmailInput } from "./EmailInput";
|
|
5
|
+
import { EnumInput } from "./EnumInput";
|
|
6
|
+
import { FloatInput } from "./FloatInput";
|
|
7
|
+
import { IntegerInput } from "./IntegerInput";
|
|
8
|
+
import { StringInput } from "./StringInput";
|
|
9
|
+
export var inputTypes = (_a = {},
|
|
10
|
+
_a[FieldTypes.boolean] = BooleanInput,
|
|
11
|
+
_a[FieldTypes.email] = EmailInput,
|
|
12
|
+
_a[FieldTypes.enum] = EnumInput,
|
|
13
|
+
_a[FieldTypes.float] = FloatInput,
|
|
14
|
+
_a[FieldTypes.integer] = IntegerInput,
|
|
15
|
+
_a[FieldTypes.string] = StringInput,
|
|
16
|
+
_a[FieldTypes.url] = StringInput,
|
|
17
|
+
_a[FieldTypes.date] = StringInput,
|
|
18
|
+
_a[FieldTypes.datetime] = StringInput,
|
|
19
|
+
_a[FieldTypes.time] = StringInput,
|
|
20
|
+
_a);
|
|
@@ -0,0 +1,245 @@
|
|
|
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 { omit, set } from "lodash";
|
|
49
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
50
|
+
import { useTableActions, } from "../../../common/Table/TableActions/hooks";
|
|
51
|
+
import { selectValidatorsFor, validateRecord } from "./validation";
|
|
52
|
+
import { useAppLoadingContext } from "../../../common/AppLoadingContextProvider";
|
|
53
|
+
var checkIfHasErrors = function (errors) {
|
|
54
|
+
return errors && Object.keys(errors).length > 0;
|
|
55
|
+
};
|
|
56
|
+
export var useValidationState = function (_a) {
|
|
57
|
+
var initialDataSet = _a.initialDataSet, //Initial Data Set, used to run the initial validation
|
|
58
|
+
dataSet = _a.dataSet, //Current Updated Data Set
|
|
59
|
+
fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly, setDataSet = _a.setDataSet, setIsLoading = _a.setIsLoading, onValidateRecord = _a.onValidateRecord;
|
|
60
|
+
var _b = useState({}), errors = _b[0], setErrors = _b[1];
|
|
61
|
+
var _c = useState({}), warnings = _c[0], setWarnings = _c[1];
|
|
62
|
+
var _d = useState(0), validationPercentage = _d[0], setValidationPercentage = _d[1];
|
|
63
|
+
var validatorsCache = useMemo(function () { return selectValidatorsFor(fields); }, [fields]);
|
|
64
|
+
var setIsLoadingApp = useAppLoadingContext().setIsLoadingApp;
|
|
65
|
+
var deleteRecords = useTableActions({
|
|
66
|
+
setDataSet: setDataSet,
|
|
67
|
+
setErrors: setErrors,
|
|
68
|
+
setWarnings: setWarnings,
|
|
69
|
+
}).deleteRecords;
|
|
70
|
+
// Validate record and update dataSet
|
|
71
|
+
var updateRecordAndRevalidate = useCallback(function (record) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var recordId, newDataSet, data, _a, recordErrors, recordWarnings, hasError, hasWarning;
|
|
73
|
+
var _b;
|
|
74
|
+
return __generator(this, function (_c) {
|
|
75
|
+
switch (_c.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
recordId = record._meta.id;
|
|
78
|
+
newDataSet = __assign(__assign({}, dataSet), (_b = {}, _b[recordId] = __assign({}, record), _b));
|
|
79
|
+
// 'touched' should be set before validation
|
|
80
|
+
newDataSet[recordId]._meta.touched = true;
|
|
81
|
+
data = Object.values(newDataSet);
|
|
82
|
+
return [4 /*yield*/, validateRecord({
|
|
83
|
+
validatorsCache: validatorsCache,
|
|
84
|
+
onValidateRecord: onValidateRecord,
|
|
85
|
+
data: data,
|
|
86
|
+
fields: fields,
|
|
87
|
+
record: record,
|
|
88
|
+
})];
|
|
89
|
+
case 1:
|
|
90
|
+
_a = _c.sent(), recordErrors = _a.errors, recordWarnings = _a.warnings;
|
|
91
|
+
hasError = checkIfHasErrors(recordErrors);
|
|
92
|
+
hasWarning = checkIfHasErrors(recordWarnings);
|
|
93
|
+
newDataSet[recordId]._meta.isInvalid = hasError;
|
|
94
|
+
newDataSet[recordId]._meta.hasWarning = hasWarning;
|
|
95
|
+
setErrors(function (errors) {
|
|
96
|
+
var newErrors = __assign({}, errors);
|
|
97
|
+
var newState = hasError
|
|
98
|
+
? set(newErrors, recordId, recordErrors)
|
|
99
|
+
: omit(newErrors, recordId);
|
|
100
|
+
return newState;
|
|
101
|
+
});
|
|
102
|
+
setWarnings(function (warnings) {
|
|
103
|
+
var newWarnings = __assign({}, warnings);
|
|
104
|
+
var newState = hasWarning
|
|
105
|
+
? set(newWarnings, recordId, recordWarnings)
|
|
106
|
+
: omit(newWarnings, recordId);
|
|
107
|
+
return newState;
|
|
108
|
+
});
|
|
109
|
+
setDataSet(newDataSet); //Update the dataSet
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); }, [dataSet, validatorsCache]);
|
|
114
|
+
// Initial data validation and update dataSet
|
|
115
|
+
useEffect(function () {
|
|
116
|
+
if (!initialDataSet || isReadOnly)
|
|
117
|
+
return;
|
|
118
|
+
setIsLoading(true);
|
|
119
|
+
var initialValidation = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
var errors, warnings, initialData, length, _a, batchValidationDelayMs, _b, batchValidationSize, batchSize, batchCount, batchIdx, idx, batch, index, record, recordId, _c, recordErrors, recordWarnings, hasError, hasWarning, validationPercentage_1;
|
|
121
|
+
return __generator(this, function (_d) {
|
|
122
|
+
switch (_d.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
errors = {};
|
|
125
|
+
warnings = {};
|
|
126
|
+
initialData = Object.values(initialDataSet);
|
|
127
|
+
length = initialData.length;
|
|
128
|
+
_a = options.batchValidationDelayMs, batchValidationDelayMs = _a === void 0 ? 400 : _a, _b = options.batchValidationSize, batchValidationSize = _b === void 0 ? length : _b;
|
|
129
|
+
batchSize = Math.min(Math.floor(batchValidationSize), length) || length;
|
|
130
|
+
batchCount = Math.ceil(length / batchSize);
|
|
131
|
+
batchIdx = 0;
|
|
132
|
+
_d.label = 1;
|
|
133
|
+
case 1:
|
|
134
|
+
if (!(batchIdx < batchCount)) return [3 /*break*/, 8];
|
|
135
|
+
idx = batchIdx * batchSize;
|
|
136
|
+
batch = initialData.slice(idx, idx + batchSize);
|
|
137
|
+
index = 0;
|
|
138
|
+
_d.label = 2;
|
|
139
|
+
case 2:
|
|
140
|
+
if (!(index < batch.length)) return [3 /*break*/, 5];
|
|
141
|
+
record = batch[index];
|
|
142
|
+
recordId = record._meta.id;
|
|
143
|
+
return [4 /*yield*/, validateRecord({
|
|
144
|
+
onValidateRecord: onValidateRecord,
|
|
145
|
+
data: initialData,
|
|
146
|
+
fields: fields,
|
|
147
|
+
record: record,
|
|
148
|
+
validatorsCache: validatorsCache,
|
|
149
|
+
})];
|
|
150
|
+
case 3:
|
|
151
|
+
_c = _d.sent(), recordErrors = _c.errors, recordWarnings = _c.warnings;
|
|
152
|
+
hasError = checkIfHasErrors(recordErrors);
|
|
153
|
+
hasWarning = checkIfHasErrors(recordWarnings);
|
|
154
|
+
record._meta.isInvalid = hasError;
|
|
155
|
+
record._meta.hasWarning = hasWarning;
|
|
156
|
+
if (hasError)
|
|
157
|
+
errors[recordId] = recordErrors;
|
|
158
|
+
if (hasWarning)
|
|
159
|
+
warnings[recordId] = recordWarnings;
|
|
160
|
+
_d.label = 4;
|
|
161
|
+
case 4:
|
|
162
|
+
index++;
|
|
163
|
+
return [3 /*break*/, 2];
|
|
164
|
+
case 5:
|
|
165
|
+
validationPercentage_1 = (Math.min(idx + batchSize, initialData.length) / initialData.length) *
|
|
166
|
+
100;
|
|
167
|
+
setValidationPercentage(Math.round((validationPercentage_1 + Number.EPSILON) * 10) / 10);
|
|
168
|
+
return [4 /*yield*/, sleep(batchValidationDelayMs)];
|
|
169
|
+
case 6:
|
|
170
|
+
_d.sent();
|
|
171
|
+
setErrors(errors);
|
|
172
|
+
setWarnings(warnings);
|
|
173
|
+
_d.label = 7;
|
|
174
|
+
case 7:
|
|
175
|
+
batchIdx++;
|
|
176
|
+
return [3 /*break*/, 1];
|
|
177
|
+
case 8: return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); };
|
|
181
|
+
var sleep = function (n) { return new Promise(function (resolve) { return setTimeout(resolve, n); }); };
|
|
182
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
switch (_a.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
setIsLoadingApp(true);
|
|
187
|
+
if (!(Object.values(initialDataSet).length > 10000)) return [3 /*break*/, 2];
|
|
188
|
+
// wait for the first render to complete before blocking main thread with review step logic
|
|
189
|
+
return [4 /*yield*/, sleep(200)];
|
|
190
|
+
case 1:
|
|
191
|
+
// wait for the first render to complete before blocking main thread with review step logic
|
|
192
|
+
_a.sent();
|
|
193
|
+
_a.label = 2;
|
|
194
|
+
case 2: return [4 /*yield*/, initialValidation()];
|
|
195
|
+
case 3:
|
|
196
|
+
_a.sent();
|
|
197
|
+
setIsLoading(false);
|
|
198
|
+
setIsLoadingApp(false);
|
|
199
|
+
return [2 /*return*/];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}); })();
|
|
203
|
+
}, [initialDataSet]);
|
|
204
|
+
var columnErrorCounts = useMemo(function () {
|
|
205
|
+
return Object.keys(errors).reduce(function (errorsByColumns, rowId) {
|
|
206
|
+
var recordErrors = errors[rowId];
|
|
207
|
+
return Object.keys(recordErrors).reduce(function (internalErrorsByColumns, fieldKey) {
|
|
208
|
+
var _a;
|
|
209
|
+
var hasError = !!recordErrors[fieldKey];
|
|
210
|
+
var count = (_a = internalErrorsByColumns[fieldKey]) !== null && _a !== void 0 ? _a : 0;
|
|
211
|
+
internalErrorsByColumns[fieldKey] = hasError ? count + 1 : count;
|
|
212
|
+
return internalErrorsByColumns;
|
|
213
|
+
}, errorsByColumns);
|
|
214
|
+
}, {});
|
|
215
|
+
}, [errors]);
|
|
216
|
+
var columnWarningCounts = useMemo(function () {
|
|
217
|
+
return Object.keys(warnings).reduce(function (errorsByColumns, rowId) {
|
|
218
|
+
var recordWarnings = warnings[rowId];
|
|
219
|
+
return Object.keys(recordWarnings).reduce(function (internalErrorsByColumns, fieldKey) {
|
|
220
|
+
var _a;
|
|
221
|
+
var hasError = !!recordWarnings[fieldKey];
|
|
222
|
+
var count = (_a = internalErrorsByColumns[fieldKey]) !== null && _a !== void 0 ? _a : 0;
|
|
223
|
+
internalErrorsByColumns[fieldKey] = hasError ? count + 1 : count;
|
|
224
|
+
return internalErrorsByColumns;
|
|
225
|
+
}, errorsByColumns);
|
|
226
|
+
}, {});
|
|
227
|
+
}, [warnings]);
|
|
228
|
+
var totalErrors = useMemo(function () {
|
|
229
|
+
return Object.keys(columnErrorCounts).reduce(function (count, column) { return count + columnErrorCounts[column]; }, 0);
|
|
230
|
+
}, [columnErrorCounts]);
|
|
231
|
+
var isValidationCompleted = validationPercentage === 100;
|
|
232
|
+
var isValid = isValidationCompleted && totalErrors === 0;
|
|
233
|
+
return {
|
|
234
|
+
errors: errors,
|
|
235
|
+
warnings: warnings,
|
|
236
|
+
totalErrors: totalErrors,
|
|
237
|
+
columnErrorCounts: columnErrorCounts,
|
|
238
|
+
columnWarningCounts: columnWarningCounts,
|
|
239
|
+
validationPercentage: validationPercentage,
|
|
240
|
+
isValidationCompleted: isValidationCompleted,
|
|
241
|
+
isValid: isValid,
|
|
242
|
+
updateRecordAndRevalidate: updateRecordAndRevalidate,
|
|
243
|
+
deleteRecords: deleteRecords,
|
|
244
|
+
};
|
|
245
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
+
import { get } from "lodash";
|
|
25
|
+
import { DateTime } from "luxon";
|
|
26
|
+
import React from "react";
|
|
27
|
+
import { areEqual } from "react-window";
|
|
28
|
+
import { useImporterContext } from "../../contexts/ImporterContextProvider";
|
|
29
|
+
import { SpreadsheetContextProvider } from "./SpreadsheetContextProvider";
|
|
30
|
+
import SpreadsheetData from "./components/SpreadsheetData";
|
|
31
|
+
var useFieldSorting = function () {
|
|
32
|
+
var templateHeaders = useImporterContext().templateHeaders;
|
|
33
|
+
var getDefaultSortCompareFn = function (sortBy) {
|
|
34
|
+
return function (a, b) {
|
|
35
|
+
var aField = get(a, sortBy.field);
|
|
36
|
+
var bField = get(b, sortBy.field);
|
|
37
|
+
var fieldTypes = templateHeaders.reduce(function (acc, header) {
|
|
38
|
+
var type = header.column_type;
|
|
39
|
+
var pattern = header.pattern || null;
|
|
40
|
+
acc[header.internal_key] = { type: type, pattern: pattern };
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
var fieldType = fieldTypes[sortBy.field];
|
|
44
|
+
var isAEmpty = aField === undefined || aField === null || aField === "";
|
|
45
|
+
var isBEmpty = bField === undefined || bField === null || bField === "";
|
|
46
|
+
// sort empty values to the end
|
|
47
|
+
if (isAEmpty && isBEmpty) {
|
|
48
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
49
|
+
return 0;
|
|
50
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
51
|
+
}
|
|
52
|
+
if (isAEmpty)
|
|
53
|
+
return 1;
|
|
54
|
+
if (isBEmpty)
|
|
55
|
+
return -1;
|
|
56
|
+
if (fieldType && fieldType.type === "boolean") {
|
|
57
|
+
var aString = aField ? "true" : "false";
|
|
58
|
+
var bString = bField ? "true" : "false";
|
|
59
|
+
if (aString === bString) {
|
|
60
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
61
|
+
return 0;
|
|
62
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
63
|
+
}
|
|
64
|
+
if (aString === "true")
|
|
65
|
+
return sortBy.direction === "asc" ? -1 : 1;
|
|
66
|
+
if (bString === "true")
|
|
67
|
+
return sortBy.direction === "asc" ? 1 : -1;
|
|
68
|
+
}
|
|
69
|
+
else if (fieldType &&
|
|
70
|
+
(fieldType.type === "date" ||
|
|
71
|
+
fieldType.type === "datetime" ||
|
|
72
|
+
fieldType.type === "time")) {
|
|
73
|
+
var aDateTime = aField
|
|
74
|
+
? DateTime.fromFormat(aField, fieldType.pattern)
|
|
75
|
+
: null;
|
|
76
|
+
var bDateTime = bField
|
|
77
|
+
? DateTime.fromFormat(bField, fieldType.pattern)
|
|
78
|
+
: null;
|
|
79
|
+
// sort invalid date values to the end before empty values
|
|
80
|
+
if (aDateTime && !aDateTime.isValid)
|
|
81
|
+
return 1;
|
|
82
|
+
if (bDateTime && !bDateTime.isValid)
|
|
83
|
+
return -1;
|
|
84
|
+
if (aDateTime && bDateTime && aDateTime.equals(bDateTime)) {
|
|
85
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
86
|
+
return 0;
|
|
87
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
88
|
+
}
|
|
89
|
+
if (sortBy.direction === "asc") {
|
|
90
|
+
return (aDateTime === null || aDateTime === void 0 ? void 0 : aDateTime.valueOf()) - (bDateTime === null || bDateTime === void 0 ? void 0 : bDateTime.valueOf());
|
|
91
|
+
}
|
|
92
|
+
return (bDateTime === null || bDateTime === void 0 ? void 0 : bDateTime.valueOf()) - (aDateTime === null || aDateTime === void 0 ? void 0 : aDateTime.valueOf());
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
if (aField === bField) {
|
|
96
|
+
if (a._meta.rowIndex === b._meta.rowIndex)
|
|
97
|
+
return 0;
|
|
98
|
+
return a._meta.rowIndex < b._meta.rowIndex ? -1 : 1;
|
|
99
|
+
}
|
|
100
|
+
if (sortBy.direction === "asc") {
|
|
101
|
+
return aField > bField ? 1 : -1;
|
|
102
|
+
}
|
|
103
|
+
return aField < bField ? 1 : -1;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
return { getDefaultSortCompareFn: getDefaultSortCompareFn };
|
|
108
|
+
};
|
|
109
|
+
var SpreadsheetWrapper = function (_a) {
|
|
110
|
+
var initialDataSet = _a.initialDataSet, initialDataSetUpdatedAt = _a.initialDataSetUpdatedAt, props = __rest(_a, ["initialDataSet", "initialDataSetUpdatedAt"]);
|
|
111
|
+
return (_jsx(_Fragment, { children: initialDataSet && (_jsx(Spreadsheet, __assign({ initialDataSet: initialDataSet }, props), initialDataSetUpdatedAt || 0)) }));
|
|
112
|
+
};
|
|
113
|
+
var Spreadsheet = function (props) {
|
|
114
|
+
var getDefaultSortCompareFn = useFieldSorting().getDefaultSortCompareFn;
|
|
115
|
+
return (_jsx(SpreadsheetContextProvider, __assign({}, props, { getSortCompareFn: getDefaultSortCompareFn }, { children: _jsx(SpreadsheetData, { className: props.className }) })));
|
|
116
|
+
};
|
|
117
|
+
export default React.memo(SpreadsheetWrapper, areEqual);
|
|
118
|
+
export * from "./SpreadsheetContextProvider";
|
|
119
|
+
export * from "./hooks";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled, { css } from "styled-components";
|
|
6
|
+
import { TableView as TableViewBase, TableViewCellContainer, TableViewRow, } from "../../../common/Table/TableView";
|
|
7
|
+
import { Div } from "../../../styled/utils";
|
|
8
|
+
export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n width: 100%;\n"])));
|
|
9
|
+
export var SpreadSheetWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-bottom: solid 1px ", ";\n border-top: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"], ["\n border-bottom: solid 1px ", ";\n border-top: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; }, function (_a) {
|
|
10
|
+
var canShowCheckboxOnHover = _a.canShowCheckboxOnHover, shouldShowOnlyCheckbox = _a.shouldShowOnlyCheckbox;
|
|
11
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "], ["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "])), shouldShowOnlyCheckbox && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "], ["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "]))), !shouldShowOnlyCheckbox &&
|
|
12
|
+
canShowCheckboxOnHover && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "], ["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "]))));
|
|
13
|
+
});
|
|
14
|
+
export var SpreadSheetContainer = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
|
|
15
|
+
export var TableView = styled(TableViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0 !important;\n box-shadow: inset 0 -1px 0 ", ",\n inset -1px 0 0 ", ";\n &.last-column {\n box-shadow: inset 0 -1px 0 ", ",\n inset 1px 0 0 transparent, inset -1px 0 0 transparent !important;\n }\n }\n"], ["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0 !important;\n box-shadow: inset 0 -1px 0 ", ",\n inset -1px 0 0 ", ";\n &.last-column {\n box-shadow: inset 0 -1px 0 ", ",\n inset 1px 0 0 transparent, inset -1px 0 0 transparent !important;\n }\n }\n"])), function (p) { return p.theme.colors.gray50; }, TableViewRow, TableViewCellContainer, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; });
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { fieldTransformations } from "./transformators";
|
|
2
|
+
var runTransformation = function (record, transformation, field) {
|
|
3
|
+
var transformationType = transformation.transformation_type;
|
|
4
|
+
var transformerFunction = fieldTransformations[transformationType];
|
|
5
|
+
return transformerFunction(record, transformation, field);
|
|
6
|
+
};
|
|
7
|
+
export var transformRecord = function (_a) {
|
|
8
|
+
var record = _a.record, fields = _a.fields;
|
|
9
|
+
var transformedRecords = {};
|
|
10
|
+
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
11
|
+
var currentField = fields_1[_i];
|
|
12
|
+
var fieldTransformations_1 = currentField.transformations;
|
|
13
|
+
var fieldToBeTransformed = record[currentField.name];
|
|
14
|
+
if (!fieldTransformations_1 ||
|
|
15
|
+
fieldTransformations_1.length === 0 ||
|
|
16
|
+
fieldToBeTransformed === undefined) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
var transformedField = {
|
|
20
|
+
original: fieldToBeTransformed,
|
|
21
|
+
transformed: fieldToBeTransformed,
|
|
22
|
+
};
|
|
23
|
+
var fieldWasTransformed = false;
|
|
24
|
+
for (var i = 0; i < fieldTransformations_1.length; i++) {
|
|
25
|
+
var currentTransformation = fieldTransformations_1[i];
|
|
26
|
+
var transformed = runTransformation(transformedField.transformed, currentTransformation, currentField);
|
|
27
|
+
if (transformed.transformationWasNeeded) {
|
|
28
|
+
fieldWasTransformed = true;
|
|
29
|
+
transformedField = {
|
|
30
|
+
original: transformedField.original,
|
|
31
|
+
transformed: transformed.transformed,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!fieldWasTransformed) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// the data have changed
|
|
39
|
+
record[currentField.name] = transformedField.transformed;
|
|
40
|
+
transformedRecords[currentField.name] = {
|
|
41
|
+
original: transformedField.original,
|
|
42
|
+
transformed: transformedField.transformed,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var isTransformedRecordsEmpty = Object.keys(transformedRecords).length === 0;
|
|
46
|
+
return isTransformedRecordsEmpty ? null : transformedRecords;
|
|
47
|
+
};
|