fuse-importer 0.0.6-testing → 0.0.8-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/common/Spreadsheet/components/inputs/index.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +1 -1
- package/lib/esm/common/columnsValidations.d.ts +1 -1
- package/lib/esm/hooks/index.d.ts +0 -1
- package/lib/esm/types.d.ts +2 -2
- package/lib/main.js +11 -11
- package/package.json +1 -1
- package/lib/esm/Importer/ImporterWithContext.js +0 -63
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +0 -68
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +0 -58
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.js +0 -21
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +0 -23
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +0 -61
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +0 -55
- package/lib/esm/Importer/Matcher/common/icons/index.js +0 -14
- package/lib/esm/Importer/Matcher/common/index.js +0 -39
- package/lib/esm/Importer/Matcher/common/types.js +0 -9
- package/lib/esm/Importer/Matcher/index.js +0 -22
- package/lib/esm/Importer/PreviewFirstTime.js +0 -81
- package/lib/esm/Importer/PreviewModeBanner.js +0 -19
- package/lib/esm/Importer/Review/AppResponseModal.js +0 -35
- package/lib/esm/Importer/Review/ReviewContextProvider.js +0 -315
- package/lib/esm/Importer/Review/ReviewWithContext.js +0 -33
- package/lib/esm/Importer/Review/index.js +0 -4
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +0 -24
- package/lib/esm/Importer/Stepper/Step.js +0 -19
- package/lib/esm/Importer/Stepper/StepIndex.js +0 -27
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +0 -24
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +0 -31
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +0 -33
- package/lib/esm/Importer/Stepper/common/icons.js +0 -18
- package/lib/esm/Importer/Stepper/index.js +0 -118
- package/lib/esm/Importer/TrialModeBanner.js +0 -22
- package/lib/esm/Importer/Uploader/DragAndDropImporter/DragAndDropImporter.styles.js +0 -11
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +0 -123
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/ImporterSectionHeader.styles.js +0 -11
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +0 -44
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.js +0 -14
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +0 -45
- package/lib/esm/Importer/Uploader/HeaderButtons.js +0 -28
- package/lib/esm/Importer/Uploader/HeadersPreview.js +0 -44
- package/lib/esm/Importer/Uploader/UploaderContextProvider.js +0 -27
- package/lib/esm/Importer/Uploader/index.js +0 -13
- package/lib/esm/Importer/common/AppLoading.js +0 -24
- package/lib/esm/Importer/common/Footer.js +0 -17
- package/lib/esm/Importer/common/FuseApi.js +0 -48
- package/lib/esm/Importer/common/GlobalStyle.js +0 -7
- package/lib/esm/Importer/common/ImporterFonts.js +0 -5
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +0 -56
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +0 -176
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +0 -45
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +0 -14
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +0 -63
- package/lib/esm/Importer/common/Spreadsheet/common/types.js +0 -5
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +0 -66
- package/lib/esm/Importer/common/Spreadsheet/components/GlobalStyle.js +0 -9
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +0 -110
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +0 -186
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +0 -55
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +0 -19
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +0 -43
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +0 -70
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +0 -108
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/Boolean.js +0 -18
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +0 -14
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.js +0 -30
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/FloatInput.js +0 -16
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/IntegerInput.js +0 -16
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/StringInput.js +0 -14
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +0 -20
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +0 -245
- package/lib/esm/Importer/common/Spreadsheet/index.js +0 -119
- package/lib/esm/Importer/common/Spreadsheet/styles.js +0 -16
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +0 -47
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +0 -199
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +0 -202
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +0 -176
- package/lib/esm/Importer/common/icons/index.js +0 -18
- package/lib/esm/Importer/common/index.js +0 -13
- package/lib/esm/Importer/common/theme.js +0 -19
- package/lib/esm/Importer/common/utils.js +0 -100
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +0 -247
- package/lib/esm/Importer/data/index.js +0 -152
- package/lib/esm/Importer/index.js +0 -28
- package/lib/esm/api/index.js +0 -93
- package/lib/esm/api/responseHandlers.js +0 -49
- package/lib/esm/common/AppLoadingContextProvider/AppLoadingUI.js +0 -26
- package/lib/esm/common/AppLoadingContextProvider/index.js +0 -25
- package/lib/esm/common/ConfirmationModal.js +0 -19
- package/lib/esm/common/Modal.js +0 -31
- package/lib/esm/common/Spinner.js +0 -41
- package/lib/esm/common/Table/Pagination/icons.js +0 -42
- package/lib/esm/common/Table/Pagination/index.js +0 -32
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +0 -50
- package/lib/esm/common/Table/TableActions/ExportData.js +0 -23
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +0 -47
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +0 -24
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +0 -35
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +0 -1
- package/lib/esm/common/Table/TableActions/RowFilters.js +0 -42
- package/lib/esm/common/Table/TableActions/SearchRows.js +0 -72
- package/lib/esm/common/Table/TableActions/TableActions.js +0 -35
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +0 -18
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +0 -67
- package/lib/esm/common/Table/TableActions/common.js +0 -1
- package/lib/esm/common/Table/TableActions/hooks.js +0 -41
- package/lib/esm/common/Table/TableActions/icons.js +0 -17
- package/lib/esm/common/Table/TableActions/index.js +0 -1
- package/lib/esm/common/Table/TableDataProvider.js +0 -127
- package/lib/esm/common/Table/TableView/TableHeaders.js +0 -69
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +0 -57
- package/lib/esm/common/Table/TableView/TableRows/index.js +0 -48
- package/lib/esm/common/Table/TableView/common/index.js +0 -37
- package/lib/esm/common/Table/TableView/index.js +0 -132
- package/lib/esm/common/Table/TableView/types.js +0 -1
- package/lib/esm/common/Table/icons.js +0 -15
- package/lib/esm/common/Table/index.js +0 -140
- package/lib/esm/common/Table/useReorderRows.js +0 -83
- package/lib/esm/common/Toast.js +0 -69
- package/lib/esm/common/TooltipProvider.js +0 -57
- package/lib/esm/common/buttons.js +0 -97
- package/lib/esm/common/columnsTransformations.js +0 -94
- package/lib/esm/common/columnsValidations.js +0 -431
- package/lib/esm/common/icons/index.js +0 -30
- package/lib/esm/common/index.js +0 -45
- package/lib/esm/common/inputs/Autocomplete.js +0 -110
- package/lib/esm/common/inputs/Checkbox.js +0 -53
- package/lib/esm/common/inputs/SelectMenu.js +0 -67
- package/lib/esm/common/inputs/TextInput.js +0 -89
- package/lib/esm/common/inputs/index.js +0 -5
- package/lib/esm/common/inputs/tooltip.js +0 -38
- package/lib/esm/common/logo.js +0 -13
- package/lib/esm/hooks/index.js +0 -16
- package/lib/esm/index.js +0 -218
- package/lib/esm/locales/de.js +0 -126
- package/lib/esm/locales/en.js +0 -126
- package/lib/esm/locales/es.js +0 -126
- package/lib/esm/locales/fr.js +0 -126
- package/lib/esm/locales/index.js +0 -4
- package/lib/esm/styled/fontsURL.js +0 -27
- package/lib/esm/styled/index.js +0 -3
- package/lib/esm/styled/theme/animations.js +0 -9
- package/lib/esm/styled/theme/colorPalette.js +0 -109
- package/lib/esm/styled/theme/debugCss.js +0 -16
- package/lib/esm/styled/theme/dimensionsCss.js +0 -20
- package/lib/esm/styled/theme/fontCss.js +0 -17
- package/lib/esm/styled/theme/globalCss.js +0 -26
- package/lib/esm/styled/theme/index.js +0 -33
- package/lib/esm/styled/theme/layoutCss.js +0 -26
- package/lib/esm/styled/theme/mediaQueries.js +0 -4
- package/lib/esm/styled/theme/positionCss.js +0 -27
- package/lib/esm/styled/theme/textCss.js +0 -18
- package/lib/esm/styled/theme/textStyles.js +0 -27
- package/lib/esm/styled/themeType.js +0 -6
- package/lib/esm/styled/utils.js +0 -17
- package/lib/esm/types.js +0 -65
- package/lib/esm/utils/hooks/useWindowSize.js +0 -23
- package/lib/esm/utils/hooks.js +0 -1
- package/lib/esm/utils/index.js +0 -37
|
@@ -1,20 +0,0 @@
|
|
|
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);
|
|
@@ -1,245 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
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";
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,199 +0,0 @@
|
|
|
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 { DateTime } from "luxon";
|
|
13
|
-
var isTransformationNeeded = function (fieldValue, transformedValue) { return ({
|
|
14
|
-
transformationWasNeeded: fieldValue !== transformedValue,
|
|
15
|
-
original: fieldValue,
|
|
16
|
-
transformed: fieldValue === transformedValue ? null : transformedValue,
|
|
17
|
-
}); };
|
|
18
|
-
var isNotANumber = function (fieldValue) {
|
|
19
|
-
return fieldValue === null || fieldValue === undefined || isNaN(fieldValue);
|
|
20
|
-
};
|
|
21
|
-
var isNotAString = function (fieldValue) {
|
|
22
|
-
return !fieldValue || typeof fieldValue !== "string" || fieldValue.trim() === "";
|
|
23
|
-
};
|
|
24
|
-
var stringFieldTransformations = {
|
|
25
|
-
sentence_case: function (fieldValue) {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
if (isNotAString(fieldValue))
|
|
28
|
-
return {
|
|
29
|
-
transformationWasNeeded: false,
|
|
30
|
-
original: fieldValue,
|
|
31
|
-
transformed: null,
|
|
32
|
-
};
|
|
33
|
-
var transformedValue = ((_b = (_a = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase()) === null || _a === void 0 ? void 0 : _a.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
|
34
|
-
(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.slice(1).toLowerCase());
|
|
35
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
36
|
-
},
|
|
37
|
-
capitalize: function (fieldValue) {
|
|
38
|
-
if (isNotAString(fieldValue)) {
|
|
39
|
-
return {
|
|
40
|
-
transformationWasNeeded: false,
|
|
41
|
-
original: fieldValue,
|
|
42
|
-
transformed: null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
var transformedValue = fieldValue
|
|
46
|
-
.split(" ")
|
|
47
|
-
.map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); })
|
|
48
|
-
.join(" ");
|
|
49
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
50
|
-
},
|
|
51
|
-
uppercase: function (fieldValue) {
|
|
52
|
-
if (isNotAString(fieldValue))
|
|
53
|
-
return {
|
|
54
|
-
transformationWasNeeded: false,
|
|
55
|
-
original: fieldValue,
|
|
56
|
-
transformed: null,
|
|
57
|
-
};
|
|
58
|
-
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toUpperCase();
|
|
59
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
60
|
-
},
|
|
61
|
-
lowercase: function (fieldValue) {
|
|
62
|
-
if (isNotAString(fieldValue))
|
|
63
|
-
return {
|
|
64
|
-
transformationWasNeeded: false,
|
|
65
|
-
original: fieldValue,
|
|
66
|
-
transformed: null,
|
|
67
|
-
};
|
|
68
|
-
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase();
|
|
69
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
70
|
-
},
|
|
71
|
-
trim_whitespace: function (fieldValue) {
|
|
72
|
-
if (typeof fieldValue !== "string")
|
|
73
|
-
return {
|
|
74
|
-
transformationWasNeeded: false,
|
|
75
|
-
original: fieldValue,
|
|
76
|
-
transformed: null,
|
|
77
|
-
};
|
|
78
|
-
var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.trim();
|
|
79
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
var datesDateTimesAndTimesTransformations = {
|
|
83
|
-
autoformat: function (fieldValue, _, fieldOptions) {
|
|
84
|
-
var JSDate = new Date(fieldValue);
|
|
85
|
-
var pattern = fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.pattern;
|
|
86
|
-
var defaultObj = {
|
|
87
|
-
transformationWasNeeded: false,
|
|
88
|
-
original: fieldValue,
|
|
89
|
-
transformed: null,
|
|
90
|
-
};
|
|
91
|
-
if (!fieldValue || !pattern || isNotANumber(JSDate.getTime())) {
|
|
92
|
-
return defaultObj;
|
|
93
|
-
}
|
|
94
|
-
var luxonDate = DateTime.fromJSDate(JSDate);
|
|
95
|
-
if (!luxonDate.isValid) {
|
|
96
|
-
return defaultObj;
|
|
97
|
-
}
|
|
98
|
-
var transformedValue = luxonDate === null || luxonDate === void 0 ? void 0 : luxonDate.toFormat(fieldOptions.pattern);
|
|
99
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
var urlTransformations = {
|
|
103
|
-
prefix: function (fieldValue, transformation) {
|
|
104
|
-
var _a;
|
|
105
|
-
var prefixValue = (_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
106
|
-
var fieldValueHasPrefix = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.startsWith(prefixValue);
|
|
107
|
-
if (isNotAString(prefixValue) ||
|
|
108
|
-
isNotAString(fieldValue) ||
|
|
109
|
-
fieldValueHasPrefix)
|
|
110
|
-
return {
|
|
111
|
-
transformationWasNeeded: false,
|
|
112
|
-
original: fieldValue,
|
|
113
|
-
transformed: null,
|
|
114
|
-
};
|
|
115
|
-
var transformedValue = "".concat(prefixValue).concat(fieldValue);
|
|
116
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
var floatTransformations = {
|
|
120
|
-
number_of_decimals: function (fieldValue, transformation) {
|
|
121
|
-
var _a;
|
|
122
|
-
var numberOfDecimalsValue = Number((_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.number_of_decimals);
|
|
123
|
-
if (isNotANumber(numberOfDecimalsValue) || isNotANumber(fieldValue)) {
|
|
124
|
-
return {
|
|
125
|
-
transformationWasNeeded: false,
|
|
126
|
-
original: fieldValue,
|
|
127
|
-
transformed: null,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
var transformedValue = parseFloat(Number(fieldValue).toFixed(numberOfDecimalsValue));
|
|
131
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
var integerTransformations = {
|
|
135
|
-
round: function (fieldValue) {
|
|
136
|
-
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
137
|
-
return {
|
|
138
|
-
transformationWasNeeded: false,
|
|
139
|
-
original: fieldValue,
|
|
140
|
-
transformed: null,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
var typeofFieldValue = typeof fieldValue;
|
|
144
|
-
var roundedValue = Math.round(fieldValue);
|
|
145
|
-
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(roundedValue) : roundedValue;
|
|
146
|
-
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
147
|
-
},
|
|
148
|
-
floor: function (fieldValue) {
|
|
149
|
-
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
150
|
-
return {
|
|
151
|
-
transformationWasNeeded: false,
|
|
152
|
-
original: fieldValue,
|
|
153
|
-
transformed: null,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
var typeofFieldValue = typeof fieldValue;
|
|
157
|
-
var flooredValue = Math.floor(fieldValue);
|
|
158
|
-
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(flooredValue) : flooredValue;
|
|
159
|
-
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
160
|
-
},
|
|
161
|
-
ceiling: function (fieldValue) {
|
|
162
|
-
if (fieldValue === "" || isNotANumber(fieldValue)) {
|
|
163
|
-
return {
|
|
164
|
-
transformationWasNeeded: false,
|
|
165
|
-
original: fieldValue,
|
|
166
|
-
transformed: null,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
var typeofFieldValue = typeof fieldValue;
|
|
170
|
-
var ceilingValue = Math.ceil(fieldValue);
|
|
171
|
-
var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(ceilingValue) : ceilingValue;
|
|
172
|
-
return isTransformationNeeded(fieldValue, valueWithCorrectType);
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
var enumTransformations = {
|
|
176
|
-
autodetect: function (fieldValue, _, fieldOptions) {
|
|
177
|
-
var options = fieldOptions.options.map(function (option) {
|
|
178
|
-
return option.toLowerCase();
|
|
179
|
-
});
|
|
180
|
-
if (!fieldValue || options.length === 0)
|
|
181
|
-
return {
|
|
182
|
-
transformationWasNeeded: false,
|
|
183
|
-
original: fieldValue,
|
|
184
|
-
transformed: null,
|
|
185
|
-
};
|
|
186
|
-
var parsedRecord = String(fieldValue).toLowerCase();
|
|
187
|
-
var trueOptionIndex = options.findIndex(function (option) { return option === "true" || option === "1"; });
|
|
188
|
-
var falseOptionIndex = options.findIndex(function (option) { return option === "false" || option === "0"; });
|
|
189
|
-
if (trueOptionIndex !== -1 && falseOptionIndex !== -1) {
|
|
190
|
-
var transformedValue_1 = parsedRecord === options[trueOptionIndex]
|
|
191
|
-
? fieldOptions.options[trueOptionIndex]
|
|
192
|
-
: fieldOptions.options[falseOptionIndex];
|
|
193
|
-
return isTransformationNeeded(fieldValue, transformedValue_1);
|
|
194
|
-
}
|
|
195
|
-
var transformedValue = fieldOptions.options[0];
|
|
196
|
-
return isTransformationNeeded(fieldValue, transformedValue);
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
export var fieldTransformations = __assign(__assign(__assign(__assign(__assign(__assign({}, stringFieldTransformations), datesDateTimesAndTimesTransformations), urlTransformations), floatTransformations), integerTransformations), enumTransformations);
|