fuse-importer 0.1.6-testing → 0.1.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/ImporterWithContext.js +1 -1
- package/lib/esm/Importer/Review/AppResponseModal.js +2 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +2 -0
- package/lib/esm/Importer/Review/ReviewContextProvider.js +18 -13
- package/lib/esm/Importer/Stepper/index.js +26 -13
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +0 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +3 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.js +29 -0
- package/lib/esm/Importer/common/Spreadsheet/ValidationContextProvider/index.js +17 -8
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.d.ts +6 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FindAndReplace/index.js +44 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +6 -4
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +5 -9
- 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.d.ts → transformators/index.d.ts} +6 -6
- package/lib/esm/Importer/common/Spreadsheet/transformation/{transformators.js → transformators/index.js} +24 -45
- package/lib/esm/Importer/common/theme.d.ts +1 -0
- package/lib/esm/Importer/data/index.d.ts +5 -2
- package/lib/esm/Importer/data/index.js +14 -46
- package/lib/esm/Importer/hooks/useSubmitToServer.d.ts +1 -1
- package/lib/esm/Importer/hooks/useSubmitToServer.js +3 -2
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +6 -5
- package/lib/esm/common/Table/TableActions/RowFilters.js +3 -3
- package/lib/esm/common/Table/TableActions/SearchRows.js +21 -13
- package/lib/esm/common/Table/TableActions/TableActions.js +9 -4
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +1 -1
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.d.ts +5 -1
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +19 -39
- package/lib/esm/common/Table/TableActions/icons.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/icons.js +1 -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/Toast.d.ts +34 -3
- package/lib/esm/common/Toast.js +31 -15
- package/lib/esm/common/buttons.js +6 -6
- package/lib/esm/common/datePatterns.d.ts +0 -1
- package/lib/esm/common/datePatterns.js +0 -10
- package/lib/esm/common/icons/index.d.ts +3 -0
- package/lib/esm/common/icons/index.js +5 -2
- package/lib/esm/common/inputs/Checkbox.d.ts +2 -1
- package/lib/esm/common/inputs/Checkbox.js +9 -7
- package/lib/esm/locales/en.d.ts +13 -0
- package/lib/esm/locales/en.js +13 -0
- 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/main.js +6 -6
- package/package.json +1 -1
|
@@ -93,6 +93,6 @@ export var ImporterWithContext = function () {
|
|
|
93
93
|
currentStepIndex: currentStepIndex,
|
|
94
94
|
templateHeaders: templateHeaders,
|
|
95
95
|
};
|
|
96
|
-
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AppLoadingContextProvider, { children: _jsxs(EventManagerContextProvider, { children: [_jsx(Toast, {}), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), templateHeaders ? (_jsx(ReviewContextProvider, __assign({ initialRecords: initialRecords }, { children: _jsxs(_Fragment, { children: [isModal && _jsx(Backdrop, {}), _jsx(Layout, __assign({ zIndex: zIndex, ref: layoutRef, isModal: isModal }, { children: shouldShowPreviewFirstTime ? (_jsx(PreviewFirstTime, {})) : (_jsx(ContentRenderer, __assign({}, contentRendererProps))) }))] }) }))) : (_jsx(AppLoading, {}))] }) }) })));
|
|
96
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AppLoadingContextProvider, { children: _jsxs(EventManagerContextProvider, { children: [_jsx(Toast, { zIndex: zIndex + 1 }), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), templateHeaders ? (_jsx(ReviewContextProvider, __assign({ initialRecords: initialRecords }, { children: _jsxs(_Fragment, { children: [isModal && _jsx(Backdrop, {}), _jsx(Layout, __assign({ zIndex: zIndex, ref: layoutRef, isModal: isModal }, { children: shouldShowPreviewFirstTime ? (_jsx(PreviewFirstTime, {})) : (_jsx(ContentRenderer, __assign({}, contentRendererProps))) }))] }) }))) : (_jsx(AppLoading, {}))] }) }) })));
|
|
97
97
|
};
|
|
98
98
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useState } from "react";
|
|
14
|
-
import {
|
|
14
|
+
import { Button, Modal } from "../..";
|
|
15
15
|
import { Div } from "../../styled/utils";
|
|
16
16
|
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
17
17
|
import { useReviewContext } from "./ReviewContextProvider";
|
|
@@ -31,5 +31,5 @@ export var AppResponseModal = function () {
|
|
|
31
31
|
var defaultMessage = importWasSuccessful
|
|
32
32
|
? "Data imported successfully"
|
|
33
33
|
: "Some records could not be imported. Please review the errors and resubmit.";
|
|
34
|
-
return (_jsx(Modal, __assign({ isOpen: isAppResponseModalOpen, onClose: onCloseModal }, { children: _jsxs(Div, __assign({ centered: true, flexColumn: true, p: 40 }, { children: [_jsx(Div, __assign({ h6: true, w: 300, textAlignCenter: true, mt: 20 }, { children: (appResponse === null || appResponse === void 0 ? void 0 : appResponse.message) || defaultMessage })), _jsx(Div, __assign({ dflex: true, mt: 40, w100: true, centered: true }, { children: _jsx(Button, __assign({ ml: 10, onClick: onCloseModal }, { children: "OK" })) }))] })) })));
|
|
34
|
+
return (_jsx(Modal, __assign({ isOpen: isAppResponseModalOpen, onClose: onCloseModal }, { children: _jsxs(Div, __assign({ centered: true, flexColumn: true, p: 40 }, { children: [_jsx(Div, __assign({ h6: true, w: 300, textAlignCenter: true, mt: 20 }, { children: (appResponse === null || appResponse === void 0 ? void 0 : appResponse.message) || defaultMessage })), _jsx(Div, __assign({ dflex: true, mt: 40, w100: true, centered: true }, { children: _jsx(Button, __assign({ ml: 10, onClick: onCloseModal, "data-cy": "app-response-btn" }, { children: "OK" })) }))] })) })));
|
|
35
35
|
};
|
|
@@ -19,6 +19,8 @@ type State = {
|
|
|
19
19
|
onSubmit: (dataSet: RecordDataSet) => Promise<void>;
|
|
20
20
|
setReviewInitialDataSetDeprecated: (dataSet: any) => void;
|
|
21
21
|
setInitialDataSetUpdatedAt: React.Dispatch<any>;
|
|
22
|
+
isTransformTooltipOpened: boolean;
|
|
23
|
+
setIsTransformTooltipOpened: React.Dispatch<React.SetStateAction<boolean>>;
|
|
22
24
|
};
|
|
23
25
|
export type ExportDataType = "csv" | "excel";
|
|
24
26
|
type Props = {
|
|
@@ -57,14 +57,15 @@ var ReviewContext = createContext({});
|
|
|
57
57
|
export var ReviewContextProvider = function (_a) {
|
|
58
58
|
var initialRecords = _a.initialRecords, children = _a.children;
|
|
59
59
|
var _b = useImporterContext(), templateHeaderMatchings = _b.templateHeaderMatchings, enumFieldValueMatchings = _b.enumFieldValueMatchings, templateHeaders = _b.templateHeaders, uploadedDataHeaders = _b.uploadedDataHeaders, headerRowIndex = _b.headerRowIndex, uploadedData = _b.uploadedData, currentStepIndex = _b.currentStepIndex, setSelectedRows = _b.setSelectedRows, _c = _b.importerOptions, disableSubmitIfInvalid = _c.disableSubmitIfInvalid, batchValidationDelayMs = _c.batchValidationDelayMs, batchValidationSize = _c.batchValidationSize, loadingComponent = _c.loadingComponent, onValidateRecord = _b.onValidateRecord, formatRecord = _b.formatRecord;
|
|
60
|
-
var _d =
|
|
60
|
+
var _d = useState(false), isTransformTooltipOpened = _d[0], setIsTransformTooltipOpened = _d[1];
|
|
61
|
+
var _e = useSubmitToServer(setIsTransformTooltipOpened), appResponse = _e.appResponse, isSubmitting = _e.isSubmitting, importWasSuccessful = _e.importWasSuccessful, onSubmitToServer = _e.onSubmitToServer;
|
|
61
62
|
var setIsLoadingApp = useAppLoadingContext().setIsLoadingApp;
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
63
|
+
var _f = useState([]), previewFields = _f[0], setPreviewFields = _f[1];
|
|
64
|
+
var _g = useState(null), previewInitialDataSet = _g[0], setPreviewInitialDataSet = _g[1];
|
|
65
|
+
var _h = useState([]), reviewFields = _h[0], setReviewFields = _h[1];
|
|
65
66
|
var reviewInitialDataSet = useRef(null);
|
|
66
|
-
var
|
|
67
|
-
var
|
|
67
|
+
var _j = useState(null), initialDataSetUpdatedAt = _j[0], setInitialDataSetUpdatedAt = _j[1];
|
|
68
|
+
var _k = useState(false), _ = _k[0], setInefficientRerender = _k[1];
|
|
68
69
|
var setReviewInitialDataSetDeprecated = function (dataSet) {
|
|
69
70
|
reviewInitialDataSet.current = dataSet;
|
|
70
71
|
setInefficientRerender(function (prev) { return !prev; });
|
|
@@ -103,17 +104,17 @@ export var ReviewContextProvider = function (_a) {
|
|
|
103
104
|
else if (currentStepIndex === 2) {
|
|
104
105
|
setIsLoadingApp(true);
|
|
105
106
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
-
var generateRecords, fields, records, initialDataSet;
|
|
107
|
-
return __generator(this, function (
|
|
108
|
-
switch (
|
|
107
|
+
var generateRecords, fields, records, _a, isDatasetTransformed, initialDataSet;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
109
110
|
case 0:
|
|
110
111
|
if (!(uploadedData && uploadedData.length > 10000)) return [3 /*break*/, 2];
|
|
111
112
|
// wait for the first render to complete before blocking main thread with review step logic
|
|
112
113
|
return [4 /*yield*/, sleep(200)];
|
|
113
114
|
case 1:
|
|
114
115
|
// wait for the first render to complete before blocking main thread with review step logic
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
_b.sent();
|
|
117
|
+
_b.label = 2;
|
|
117
118
|
case 2:
|
|
118
119
|
generateRecords = function () {
|
|
119
120
|
return transformToRecords({
|
|
@@ -127,10 +128,12 @@ export var ReviewContextProvider = function (_a) {
|
|
|
127
128
|
};
|
|
128
129
|
fields = getTemplateFields({ templateHeaders: templateHeaders });
|
|
129
130
|
records = initialRecords !== null && initialRecords !== void 0 ? initialRecords : generateRecords();
|
|
130
|
-
|
|
131
|
+
_a = getReviewDataSet({
|
|
131
132
|
records: records,
|
|
132
133
|
fields: fields,
|
|
133
|
-
}).initialDataSet;
|
|
134
|
+
}), isDatasetTransformed = _a.isDatasetTransformed, initialDataSet = _a.initialDataSet;
|
|
135
|
+
if (isDatasetTransformed)
|
|
136
|
+
setIsTransformTooltipOpened(true);
|
|
134
137
|
setSelectedRows([]);
|
|
135
138
|
setReviewFields(fields);
|
|
136
139
|
setReviewInitialDataSetDeprecated(initialDataSet);
|
|
@@ -178,6 +181,8 @@ export var ReviewContextProvider = function (_a) {
|
|
|
178
181
|
onDataSetChanged: onDataSetChanged,
|
|
179
182
|
setReviewInitialDataSetDeprecated: setReviewInitialDataSetDeprecated,
|
|
180
183
|
setInitialDataSetUpdatedAt: setInitialDataSetUpdatedAt,
|
|
184
|
+
isTransformTooltipOpened: isTransformTooltipOpened,
|
|
185
|
+
setIsTransformTooltipOpened: setIsTransformTooltipOpened,
|
|
181
186
|
};
|
|
182
187
|
function renderLoading() {
|
|
183
188
|
return isSubmitting ? (loadingComponent ? (loadingComponent()) : (_jsx(AppLoading, {}))) : null;
|
|
@@ -28,6 +28,7 @@ import { ConfirmCloseModal } from "./ConfirmCloseModal";
|
|
|
28
28
|
import { Step } from "./Step";
|
|
29
29
|
import { StepperSubmitModal } from "./StepperSubmitModal";
|
|
30
30
|
import { UnmatchedHeadersModal } from "./UnmatchedHeadersModal";
|
|
31
|
+
import { useDataSetContext } from "../common/Spreadsheet/DataSetContextProvider";
|
|
31
32
|
var StepperWrapper = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n border-bottom: 1px solid ", ";\n user-select: none;\n"], ["\n background-color: ", ";\n border-bottom: 1px solid ", ";\n user-select: none;\n"])), function (p) { return p.theme.colors.white; }, function (p) { return p.theme.colors.gray300; });
|
|
32
33
|
var StepperContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n justify-content: space-between;\n padding-left: 32px;\n padding-right: 32px;\n width: 100%;\n"], ["\n align-items: center;\n display: flex;\n gap: 16px;\n justify-content: space-between;\n padding-left: 32px;\n padding-right: 32px;\n width: 100%;\n"])));
|
|
33
34
|
var Steps = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n @media (max-width: 630px) {\n display: none;\n }\n"], ["\n @media (max-width: 630px) {\n display: none;\n }\n"])));
|
|
@@ -44,24 +45,36 @@ export var Stepper = function (_a) {
|
|
|
44
45
|
var t = useTranslation("general").t;
|
|
45
46
|
var _c = useState(false), isSubmitModalOpen = _c[0], setIsSubmitModalOpen = _c[1];
|
|
46
47
|
var _d = useState(false), isConfirmCloseModalOpen = _d[0], setIsConfirmCloseModalOpen = _d[1];
|
|
47
|
-
var _e =
|
|
48
|
-
var _f =
|
|
49
|
-
var
|
|
50
|
-
var _g =
|
|
48
|
+
var _e = useDataSetContext(), dataSetLength = _e.dataSetLength, emptyRecordIds = _e.emptyRecordIds;
|
|
49
|
+
var _f = useState(true), isSubmitDisabled = _f[0], setIsSubmitDisabled = _f[1];
|
|
50
|
+
var headerMappingsLoaded = useImporterContext().headerMappingsLoaded;
|
|
51
|
+
var _g = useReviewContext(), appResponse = _g.appResponse, onSubmit = _g.onSubmit;
|
|
52
|
+
var _h = useValidationContext(), totalErrorCount = _h.totalErrorCount, spreadsheetInitialized = _h.spreadsheetInitialized;
|
|
53
|
+
var _j = useEventManagerContext(), on = _j.on, off = _j.off, EVENTS = _j.EVENTS;
|
|
54
|
+
var updateSpreadsheetDisabled = function () {
|
|
55
|
+
var isSpreadsheetEmpty = dataSetLength.current === emptyRecordIds.current.size;
|
|
56
|
+
var isDisabled = totalErrorCount.current > 0 ||
|
|
57
|
+
!spreadsheetInitialized ||
|
|
58
|
+
isSpreadsheetEmpty;
|
|
59
|
+
setIsSubmitDisabled(isDisabled);
|
|
60
|
+
};
|
|
51
61
|
useEffect(function () {
|
|
52
|
-
|
|
53
|
-
var isDisabled = totalErrorCount.current > 0;
|
|
54
|
-
setIsSubmitDisabled(isDisabled);
|
|
55
|
-
};
|
|
56
|
-
on(EVENTS.UPDATE_TOTAL_ERROR_COUNT, listener);
|
|
62
|
+
on(EVENTS.UPDATE_TOTAL_ERROR_COUNT, updateSpreadsheetDisabled);
|
|
57
63
|
return function () {
|
|
58
|
-
off(EVENTS.UPDATE_TOTAL_ERROR_COUNT,
|
|
64
|
+
off(EVENTS.UPDATE_TOTAL_ERROR_COUNT, updateSpreadsheetDisabled);
|
|
59
65
|
};
|
|
60
|
-
}, [appResponse]);
|
|
61
|
-
|
|
66
|
+
}, [appResponse, spreadsheetInitialized]);
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
updateSpreadsheetDisabled();
|
|
69
|
+
}, [spreadsheetInitialized]);
|
|
70
|
+
var _k = useImporterContext(), initialRecords = _k.initialRecords, currentStepIndex = _k.currentStepIndex, templateHeaderMatchings = _k.templateHeaderMatchings, matcherSubstep = _k.matcherSubstep, templateHeaders = _k.templateHeaders, enumFieldValueMatchings = _k.enumFieldValueMatchings, setMatcherSubstep = _k.setMatcherSubstep, setCurrentStepIndex = _k.setCurrentStepIndex, onClose = _k.onClose, isUsingManualImport = _k.isUsingManualImport, resetImporterWhenUsingManualImport = _k.resetImporterWhenUsingManualImport, uploadedData = _k.uploadedData;
|
|
71
|
+
var _l = useState(true), isContinueDisabled = _l[0], setIsContinueDisabled = _l[1];
|
|
62
72
|
var templateHeaderLabels = Object.keys(templateHeaderMatchings || []);
|
|
63
73
|
var unmatchedHeadersCount = templateHeaderLabels.filter(function (templateHeaderLabel) { return !templateHeaderMatchings[templateHeaderLabel]; }).length;
|
|
64
74
|
var isLastSubMatchStep = matcherSubstep === 1;
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
setIsContinueDisabled(currentStepIndex === 1 && !headerMappingsLoaded);
|
|
77
|
+
}, [currentStepIndex, headerMappingsLoaded]);
|
|
65
78
|
var setStep = function () {
|
|
66
79
|
var templateHasEnumFields = !!(templateHeaders === null || templateHeaders === void 0 ? void 0 : templateHeaders.find(function (header) { return header.column_type === ColumnType.enum; }));
|
|
67
80
|
if (templateHasEnumFields) {
|
|
@@ -120,7 +133,7 @@ export var Stepper = function (_a) {
|
|
|
120
133
|
return (_jsxs(Div, __assign({ centered: true }, { children: [_jsx(Step, { index: index, label: label, isCompleted: isCompleted, isSelected: index === currentStepIndex }), !isLast && (_jsx(Div, __assign({ ml: 18, mr: 18, dflex: true }, { children: _jsx(ChevronRightIcon, {}) })))] }), index));
|
|
121
134
|
}) })));
|
|
122
135
|
var leftButtonUI = (_jsx(Div, __assign({ style: { flex: 1 } }, { children: !initialRecords && (_jsxs(StepperButtonContainer, __assign({ align: "left" }, { children: [logoURL && (_jsx(Div, __assign({ forDesktop: true }, { children: _jsx(Logo, { src: logoURL, alt: "" }) }))), currentStepIndex > 0 && !appResponse && (_jsx(GoBackButtonWrapper, { children: _jsx(Button, __assign({ variant: "secondary", onClick: goBack }, { children: t("stepper.go_back") })) }))] }))) })));
|
|
123
|
-
var rightButtonUI = (_jsxs(StepperButtonContainer, __assign({ align: "right" }, { children: [(isMatchStep || isVerifyStep) && (_jsx(Button, __assign({ "data-cy": "continue-button", variant: "primary", onClick: continueToNextStep }, { children: t("stepper.continue") }))), isReviewStep && (_jsx(Button, __assign({ variant: "primary", isDisabled: isSubmitDisabled, "data-cy": "submit_disabled_" + isSubmitDisabled, onClick: function () { return setIsSubmitModalOpen(true); } }, { children: t("stepper.submit") }))), _jsx(CloseIcon, __assign({ "data-test-id": "close-importer", centered: true, clickable: true, onClick: handleOnClose }, { children: closeIconCondensed }))] })));
|
|
136
|
+
var rightButtonUI = (_jsxs(StepperButtonContainer, __assign({ align: "right" }, { children: [(isMatchStep || isVerifyStep) && (_jsx(Button, __assign({ "data-cy": "continue-button", isDisabled: isContinueDisabled, variant: "primary", onClick: continueToNextStep }, { children: t("stepper.continue") }))), isReviewStep && (_jsx(Button, __assign({ variant: "primary", isDisabled: isSubmitDisabled, "data-cy": "submit_disabled_" + isSubmitDisabled, onClick: function () { return setIsSubmitModalOpen(true); } }, { children: t("stepper.submit") }))), _jsx(CloseIcon, __assign({ "data-test-id": "close-importer", centered: true, clickable: true, onClick: handleOnClose }, { children: closeIconCondensed }))] })));
|
|
124
137
|
return (_jsxs(_Fragment, { children: [_jsx(StepperWrapper, __assign({ pRelative: true, alignCenter: true, w100: true, h: 72, centered: true }, { children: _jsxs(StepperContainer, { children: [leftButtonUI, _jsx(Steps, __assign({ alignCenter: true }, { children: stepsUI })), rightButtonUI] }) })), _jsx(UnmatchedHeadersModal, { isUnmatchedHeadersModalOpen: isUnmatchedHeadersModalOpen, unmatchedHeadersCount: unmatchedHeadersCount, onSetStep: function () { return setStep(); }, onCloseUnmatchedHeadersModal: function () {
|
|
125
138
|
return setIsUnmatchedHeadersModalOpen(false);
|
|
126
139
|
} }), _jsx(StepperSubmitModal, { isSubmitModalOpen: isSubmitModalOpen, onCloseModal: function () { return setIsSubmitModalOpen(false); }, onSubmit: onSubmit }), _jsx(ConfirmCloseModal, { isOpen: isConfirmCloseModalOpen, onClose: function () { return setIsConfirmCloseModalOpen(false); }, onCloseImporter: onClose })] }));
|
|
@@ -28,7 +28,7 @@ var HeadersList = function (_a) {
|
|
|
28
28
|
var title = _a.title, headers = _a.headers, props = __rest(_a, ["title", "headers"]);
|
|
29
29
|
return (_jsxs(_Fragment, { children: [_jsx(Div, __assign({ label3: true }, props, { children: title })), headers.map(function (header, index) {
|
|
30
30
|
var isLast = index === headers.length - 1;
|
|
31
|
-
return (_jsx(S.HeaderListItem, __assign({ body1: true, isLast: isLast, mt: 16 }, { children: header }), index));
|
|
31
|
+
return (_jsx(S.HeaderListItem, __assign({ body1: true, "data-cy": header, isLast: isLast, mt: 16 }, { children: header }), index));
|
|
32
32
|
})] }));
|
|
33
33
|
};
|
|
34
34
|
export var HeaderCard = function (_a) {
|
|
@@ -40,5 +40,5 @@ export var HeaderCard = function (_a) {
|
|
|
40
40
|
.filter(function (h) { return !h.required; })
|
|
41
41
|
.map(function (h) { return h.label; });
|
|
42
42
|
var t = useTranslation("upload").t;
|
|
43
|
-
return (_jsx(S.HeaderCardWrapper, { children: _jsxs(S.HeaderCardContainer, __assign({}, props, { children: [_jsx(Div, __assign({ body3: true, mb: 24 }, { children: t("header.title") })), requiredHeaders.length > 0 && (_jsx(HeadersList, { title: t("header.required_headers"), headers: requiredHeaders })), optionalHeaders.length > 0 && (_jsx(HeadersList, { title: t("header.optional_headers"), headers: optionalHeaders, mt: 30 }))] })) }));
|
|
43
|
+
return (_jsx(S.HeaderCardWrapper, { children: _jsxs(S.HeaderCardContainer, __assign({}, props, { children: [_jsx(Div, __assign({ "data-cy": "header_title", body3: true, mb: 24 }, { children: t("header.title") })), requiredHeaders.length > 0 && (_jsx(HeadersList, { "data-cy": "required_header", title: t("header.required_headers"), headers: requiredHeaders })), optionalHeaders.length > 0 && (_jsx(HeadersList, { "data-cy": "optional_header", title: t("header.optional_headers"), headers: optionalHeaders, mt: 30 }))] })) }));
|
|
44
44
|
};
|
|
@@ -12,8 +12,6 @@ type State = {
|
|
|
12
12
|
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
13
13
|
lastClickedIndexRef: React.MutableRefObject<number | null>;
|
|
14
14
|
checkboxColumnWidth: number;
|
|
15
|
-
setIsTransformTooltipOpened: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
-
isTransformTooltipOpened: boolean;
|
|
17
15
|
inefficientRerender: boolean;
|
|
18
16
|
setInefficientRerender: React.Dispatch<React.SetStateAction<boolean>>;
|
|
19
17
|
};
|
|
@@ -27,10 +27,9 @@ import { useValidationContext } from "../ValidationContextProvider";
|
|
|
27
27
|
var SpreadsheetContext = createContext({});
|
|
28
28
|
export var SpreadsheetContextProvider = function (_a) {
|
|
29
29
|
var fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly, children = _a.children, onValidateRecord = _a.onValidateRecord, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows;
|
|
30
|
-
var _b = useState(false),
|
|
31
|
-
var _c = useState(false), inefficientRerender = _c[0], setInefficientRerender = _c[1];
|
|
30
|
+
var _b = useState(false), inefficientRerender = _b[0], setInefficientRerender = _b[1];
|
|
32
31
|
var filteredDataIds = useFilteredDataContext().filteredDataIds;
|
|
33
|
-
var
|
|
32
|
+
var _c = useValidationContext(), calculateColumnErrorCounts = _c.calculateColumnErrorCounts, calculateColumnWarningCounts = _c.calculateColumnWarningCounts, warnings = _c.warnings, errors = _c.errors, validationState = __rest(_c, ["calculateColumnErrorCounts", "calculateColumnWarningCounts", "warnings", "errors"]);
|
|
34
33
|
var lastClickedIndexRef = useRef(null);
|
|
35
34
|
var checkboxColumnWidth = useMemo(function () {
|
|
36
35
|
var lastRowIndexLength = filteredDataIds.length.toString().length;
|
|
@@ -39,7 +38,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
39
38
|
var baseCheckboxColumnWidth = lastRowIndexLength * singleLetterWidth + horizontalSpacing;
|
|
40
39
|
return baseCheckboxColumnWidth < 40 ? 40 : baseCheckboxColumnWidth;
|
|
41
40
|
}, [filteredDataIds.length]);
|
|
42
|
-
var value = __assign(__assign({ filteredDataIds: filteredDataIds, fields: fields }, validationState), { isReadOnly: isReadOnly, options: options, onValidateRecord: onValidateRecord, selectedRows: selectedRows, setSelectedRows: setSelectedRows, lastClickedIndexRef: lastClickedIndexRef, checkboxColumnWidth: checkboxColumnWidth,
|
|
41
|
+
var value = __assign(__assign({ filteredDataIds: filteredDataIds, fields: fields }, validationState), { isReadOnly: isReadOnly, options: options, onValidateRecord: onValidateRecord, selectedRows: selectedRows, setSelectedRows: setSelectedRows, lastClickedIndexRef: lastClickedIndexRef, checkboxColumnWidth: checkboxColumnWidth, inefficientRerender: inefficientRerender, setInefficientRerender: setInefficientRerender });
|
|
43
42
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
44
43
|
};
|
|
45
44
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const useDataSetManipulation: () => {
|
|
2
2
|
appendNewRecordToSpreadsheet: () => void;
|
|
3
3
|
deleteRecordsFromSpreadsheet: (recordIds: string[]) => void;
|
|
4
|
+
findAndReplaceInSpreadsheet: (searchText: string, replaceText: string, matchCase: boolean, useRegex: boolean) => any[];
|
|
4
5
|
};
|
package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useDataSetManipulation.js
CHANGED
|
@@ -1,3 +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
|
+
};
|
|
1
12
|
import { useFilteredDataContext } from "../FilteredDataContextProvider";
|
|
2
13
|
import { useDataSetContext } from "../DataSetContextProvider";
|
|
3
14
|
import { hasValueInAnyField } from "./utils";
|
|
@@ -5,6 +16,8 @@ import { addMeta } from "../../../../Importer/data";
|
|
|
5
16
|
import { useEventManagerContext } from "../../../../common/EventManagerContextProvider";
|
|
6
17
|
import { useValidationContext } from "../ValidationContextProvider";
|
|
7
18
|
import { useDuplicateDataContext } from "../DuplicateDataContextProvider";
|
|
19
|
+
import { useBatchProcessing } from "./useBatchProcessing";
|
|
20
|
+
import useFindAndReplace from "../../../../common/Table/TableActions/useFindAndReplace";
|
|
8
21
|
export var useDataSetManipulation = function () {
|
|
9
22
|
var _a = useFilteredDataContext(), lastFilteredRecordId = _a.lastFilteredRecordId, setRecalculateFilters = _a.setRecalculateFilters;
|
|
10
23
|
var _b = useDataSetContext(), getRecord = _b.getRecord, setRecord = _b.setRecord, dataSet = _b.dataSet, deleteRecord = _b.deleteRecord, emptyRecordIds = _b.emptyRecordIds;
|
|
@@ -12,6 +25,8 @@ export var useDataSetManipulation = function () {
|
|
|
12
25
|
var _d = useValidationContext(), errors = _d.errors, warnings = _d.warnings, calculateColumnErrorCounts = _d.calculateColumnErrorCounts, calculateColumnWarningCounts = _d.calculateColumnWarningCounts;
|
|
13
26
|
var updateDuplicateValues = useDuplicateDataContext().updateDuplicateValues;
|
|
14
27
|
var updateRecordAndRevalidate = useValidationContext().updateRecordAndRevalidate;
|
|
28
|
+
var processInBatches = useBatchProcessing().processInBatches;
|
|
29
|
+
var replaceInRecord = useFindAndReplace().replaceInRecord;
|
|
15
30
|
var appendNewRecordToSpreadsheet = function () {
|
|
16
31
|
var _a, _b;
|
|
17
32
|
var _record = getRecord(lastFilteredRecordId.current);
|
|
@@ -39,8 +54,22 @@ export var useDataSetManipulation = function () {
|
|
|
39
54
|
emit(EVENTS.UPDATE_TOTAL_ERROR_COUNT);
|
|
40
55
|
emit(EVENTS.UPDATE_TOTAL_ROW_COUNT);
|
|
41
56
|
};
|
|
57
|
+
var findAndReplaceInSpreadsheet = function (searchText, replaceText, matchCase, useRegex) {
|
|
58
|
+
var cellsWithText = [];
|
|
59
|
+
processInBatches(dataSet.current, function (batch) {
|
|
60
|
+
for (var recordKey in batch) {
|
|
61
|
+
var record = __assign({}, dataSet.current[recordKey]);
|
|
62
|
+
if (replaceInRecord(record, searchText, replaceText, matchCase, useRegex)) {
|
|
63
|
+
cellsWithText.push(record);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
updateRecordAndRevalidate(cellsWithText);
|
|
68
|
+
return cellsWithText;
|
|
69
|
+
};
|
|
42
70
|
return {
|
|
43
71
|
appendNewRecordToSpreadsheet: appendNewRecordToSpreadsheet,
|
|
44
72
|
deleteRecordsFromSpreadsheet: deleteRecordsFromSpreadsheet,
|
|
73
|
+
findAndReplaceInSpreadsheet: findAndReplaceInSpreadsheet,
|
|
45
74
|
};
|
|
46
75
|
};
|
|
@@ -58,6 +58,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
58
58
|
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
59
59
|
import { useAppLoadingContext } from "../../../../common/AppLoadingContextProvider";
|
|
60
60
|
import { useEventManagerContext } from "../../../../common/EventManagerContextProvider";
|
|
61
|
+
import { useImporterContext } from "../../../contexts/ImporterContextProvider";
|
|
61
62
|
import { useDataSetContext } from "../DataSetContextProvider";
|
|
62
63
|
import { useDuplicateDataContext } from "../DuplicateDataContextProvider";
|
|
63
64
|
import { useBatchProcessing } from "../SpreadsheetContextProvider/useBatchProcessing";
|
|
@@ -101,16 +102,22 @@ export var ValidationContextProvider = function (_a) {
|
|
|
101
102
|
var columnsWithWarningCounts = useRef({});
|
|
102
103
|
var totalErrorCount = useRef(0);
|
|
103
104
|
var invalidRowsCountRef = useRef(0);
|
|
104
|
-
var _c =
|
|
105
|
-
var _d =
|
|
106
|
-
var _e =
|
|
107
|
-
var _f = useDuplicateDataContext(), duplicateValues = _f.duplicateValues, updateDuplicateValues = _f.updateDuplicateValues;
|
|
105
|
+
var _c = useEventManagerContext(), emit = _c.emit, EVENTS = _c.EVENTS;
|
|
106
|
+
var _d = useDataSetContext(), getRecord = _d.getRecord, setRecord = _d.setRecord, dataSet = _d.dataSet;
|
|
107
|
+
var _e = useDuplicateDataContext(), duplicateValues = _e.duplicateValues, updateDuplicateValues = _e.updateDuplicateValues;
|
|
108
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];
|
|
109
112
|
var reset = function () {
|
|
110
113
|
columnsWithErrorCounts.current = {};
|
|
111
114
|
columnsWithWarningCounts.current = {};
|
|
112
115
|
totalErrorCount.current = 0;
|
|
113
116
|
invalidRowsCountRef.current = 0;
|
|
117
|
+
errors.current = {};
|
|
118
|
+
warnings.current = {};
|
|
119
|
+
setSpreadsheetInitialized(false);
|
|
120
|
+
setDataSetChanged(function (prev) { return !prev; });
|
|
114
121
|
};
|
|
115
122
|
var calculateColumnErrorCounts = function (oldErrors, newErrors) {
|
|
116
123
|
if (oldErrors === void 0) { oldErrors = {}; }
|
|
@@ -177,7 +184,7 @@ export var ValidationContextProvider = function (_a) {
|
|
|
177
184
|
else {
|
|
178
185
|
delete warnings.current[recordId];
|
|
179
186
|
}
|
|
180
|
-
if (backendErrors) {
|
|
187
|
+
if (backendErrors && spreadsheetInitialized) {
|
|
181
188
|
record._meta.backendErrors = {};
|
|
182
189
|
}
|
|
183
190
|
emit(recordId, newRecord);
|
|
@@ -253,7 +260,9 @@ export var ValidationContextProvider = function (_a) {
|
|
|
253
260
|
// Initial data validation and update dataSet
|
|
254
261
|
useEffect(function () {
|
|
255
262
|
reset();
|
|
256
|
-
|
|
263
|
+
}, [dataSet.current]);
|
|
264
|
+
useEffect(function () {
|
|
265
|
+
if (!dataSet.current || isReadOnly || currentStepIndex !== 2)
|
|
257
266
|
return;
|
|
258
267
|
setIsLoadingApp(true);
|
|
259
268
|
var initialValidation = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -265,7 +274,6 @@ export var ValidationContextProvider = function (_a) {
|
|
|
265
274
|
return [4 /*yield*/, updateRecordAndRevalidate(initialData, true)];
|
|
266
275
|
case 1:
|
|
267
276
|
_a.sent();
|
|
268
|
-
setSpreadsheetInitialized(true);
|
|
269
277
|
return [2 /*return*/];
|
|
270
278
|
}
|
|
271
279
|
});
|
|
@@ -277,11 +285,12 @@ export var ValidationContextProvider = function (_a) {
|
|
|
277
285
|
case 1:
|
|
278
286
|
_a.sent();
|
|
279
287
|
setIsLoadingApp(false);
|
|
288
|
+
setSpreadsheetInitialized(true);
|
|
280
289
|
return [2 /*return*/];
|
|
281
290
|
}
|
|
282
291
|
});
|
|
283
292
|
}); })();
|
|
284
|
-
}, [
|
|
293
|
+
}, [spreadsheetInitialized, currentStepIndex, dataSetChanged]);
|
|
285
294
|
var isValidationCompleted = validationPercentage === 100;
|
|
286
295
|
var isValid = isValidationCompleted && totalErrorCount.current === 0;
|
|
287
296
|
var value = {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Div } from "../../../../../styled";
|
|
14
|
+
import { Button, Modal, addToast } from "../../../../../common";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { TextInput } from "../../../../../common/inputs/TextInput";
|
|
17
|
+
import { Checkbox } from "../../../../../common";
|
|
18
|
+
import { useState } from "react";
|
|
19
|
+
import { useDataSetManipulation } from "../../SpreadsheetContextProvider/useDataSetManipulation";
|
|
20
|
+
import { useFilteredDataContext } from "../../FilteredDataContextProvider";
|
|
21
|
+
export var FindAndReplaceModal = function (_a) {
|
|
22
|
+
var initialText = _a.initialText, onClose = _a.onClose;
|
|
23
|
+
var t = useTranslation("general").t;
|
|
24
|
+
var _b = useState(initialText), searchText = _b[0], setSearchText = _b[1];
|
|
25
|
+
var _c = useState(""), replaceText = _c[0], setReplaceText = _c[1];
|
|
26
|
+
var findAndReplaceInSpreadsheet = useDataSetManipulation().findAndReplaceInSpreadsheet;
|
|
27
|
+
var _d = useState(false), useRegex = _d[0], setUseRegex = _d[1];
|
|
28
|
+
var _e = useState(true), matchCase = _e[0], setMatchCase = _e[1];
|
|
29
|
+
var setFilteredInputValue = useFilteredDataContext().setFilteredInputValue;
|
|
30
|
+
var findAndReplace = function () {
|
|
31
|
+
var records = findAndReplaceInSpreadsheet(searchText, replaceText, matchCase, useRegex);
|
|
32
|
+
if (records.length > 0) {
|
|
33
|
+
addToast(t("find_and_replace_modal.records_replaced", {
|
|
34
|
+
length: records.length,
|
|
35
|
+
}), "success");
|
|
36
|
+
onClose();
|
|
37
|
+
setFilteredInputValue("");
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
addToast(t("find_and_replace_modal.no_records_found"), "error");
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
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") }))] }))] })) })));
|
|
44
|
+
};
|
|
@@ -35,15 +35,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
35
35
|
};
|
|
36
36
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
37
37
|
import { useMemo } from "react";
|
|
38
|
+
import ReactVirtualizedAutoSizer from "react-virtualized-auto-sizer";
|
|
38
39
|
import { FixedSizeGrid as Grid } from "react-window";
|
|
39
40
|
import styled, { css } from "styled-components";
|
|
41
|
+
import { Checkbox } from "../../../../common/inputs/Checkbox";
|
|
40
42
|
import { Div } from "../../../../styled/utils";
|
|
43
|
+
import { useImporterContext } from "../../../contexts/ImporterContextProvider";
|
|
44
|
+
import { useReviewContext } from "../../../Review/ReviewContextProvider";
|
|
41
45
|
import { spreadsheetRowHeightPx } from "../common";
|
|
42
46
|
import { spreadsheetHeaderHeightPx } from "../common/index";
|
|
43
47
|
import { useSpreadsheetContext } from "../SpreadsheetContextProvider";
|
|
44
|
-
import { Checkbox } from "../../../../common/inputs/Checkbox";
|
|
45
|
-
import { useImporterContext } from "../../../contexts/ImporterContextProvider";
|
|
46
|
-
import ReactVirtualizedAutoSizer from "react-virtualized-auto-sizer";
|
|
47
48
|
import { rowIsEmpty } from "../SpreadsheetContextProvider/utils";
|
|
48
49
|
import { useDataSetContext } from "../DataSetContextProvider";
|
|
49
50
|
var StyledGrid = styled(Grid)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n overflow-y: scroll;\n"], ["\n background: ", ";\n overflow-y: scroll;\n"])), function (_a) {
|
|
@@ -58,7 +59,8 @@ var gridStyles = {
|
|
|
58
59
|
};
|
|
59
60
|
export var SpreadsheetRowCheckboxes = function (_a) {
|
|
60
61
|
var height = _a.height, gridRef = _a.gridRef, isLoadingData = _a.isLoadingData, props = __rest(_a, ["height", "gridRef", "isLoadingData"]);
|
|
61
|
-
var _b = useSpreadsheetContext(), selectedRows = _b.selectedRows, options = _b.options, filteredDataIds = _b.filteredDataIds, lastClickedIndexRef = _b.lastClickedIndexRef, setSelectedRows = _b.setSelectedRows, checkboxColumnWidth = _b.checkboxColumnWidth
|
|
62
|
+
var _b = useSpreadsheetContext(), selectedRows = _b.selectedRows, options = _b.options, filteredDataIds = _b.filteredDataIds, lastClickedIndexRef = _b.lastClickedIndexRef, setSelectedRows = _b.setSelectedRows, checkboxColumnWidth = _b.checkboxColumnWidth;
|
|
63
|
+
var isTransformTooltipOpened = useReviewContext().isTransformTooltipOpened;
|
|
62
64
|
var getRecord = useDataSetContext().getRecord;
|
|
63
65
|
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
64
66
|
var nonEmptyRows = useMemo(function () { return filteredDataIds.filter(function (rowId) { return !rowIsEmpty(getRecord(rowId)); }); }, [filteredDataIds]);
|
|
@@ -19,8 +19,8 @@ import { SpreadsheetField, useSpreadsheetField } from ".";
|
|
|
19
19
|
import { Autocomplete as AutocompleteBase, } from "../../../../../common/inputs/Autocomplete";
|
|
20
20
|
import { SelectMenuDiv, SelectMenuScrollArea, } from "../../../../../common/inputs/SelectMenu";
|
|
21
21
|
import { HTMLInput, TextInputIcon, } from "../../../../../common/inputs/TextInput";
|
|
22
|
+
import { useReviewContext } from "../../../../Review/ReviewContextProvider";
|
|
22
23
|
import { spreadsheetRowHeightPx } from "../../common";
|
|
23
|
-
import { useSpreadsheetContext } from "../../SpreadsheetContextProvider";
|
|
24
24
|
var Autocomplete = styled(AutocompleteBase)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", " {\n border: none;\n border-radius: 0;\n margin: 0;\n background: transparent;\n height: ", "px;\n padding: 0 12px;\n\n ", "\n\n ::placeholder {\n ", "\n\n ", "\n\n ::placeholder {\n ", "\n }\n }\n\n :focus {\n border: none;\n box-shadow: none;\n }\n\n :hover {\n background: transparent;\n }\n }\n ", " {\n right: 6px;\n }\n ", " {\n border-radius: 7px;\n }\n ", " {\n padding: 4px;\n }\n"], ["\n ", " {\n border: none;\n border-radius: 0;\n margin: 0;\n background: transparent;\n height: ", "px;\n padding: 0 12px;\n\n ", "\n\n ::placeholder {\n ", "\n\n ", "\n\n ::placeholder {\n ", "\n }\n }\n\n :focus {\n border: none;\n box-shadow: none;\n }\n\n :hover {\n background: transparent;\n }\n }\n ", " {\n right: 6px;\n }\n ", " {\n border-radius: 7px;\n }\n ", " {\n padding: 4px;\n }\n"])), HTMLInput, spreadsheetRowHeightPx - 5, function (p) {
|
|
25
25
|
return p.hasWarning && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.orange1200; });
|
|
26
26
|
}, function (p) {
|
|
@@ -34,7 +34,7 @@ export var SpreadsheetAutocomplete = function (props) {
|
|
|
34
34
|
var _a, _b, _c;
|
|
35
35
|
var name = props.name, record = props.record, options = props.options, fieldType = props.fieldType, _d = props.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, id = props.id;
|
|
36
36
|
var _e = useSpreadsheetField(name, record, fieldType), value = _e.value, setValue = _e.setValue, validationError = _e.validationError, validationWarning = _e.validationWarning;
|
|
37
|
-
var isTransformTooltipOpened =
|
|
37
|
+
var isTransformTooltipOpened = useReviewContext().isTransformTooltipOpened;
|
|
38
38
|
var isHighlighted = isTransformTooltipOpened &&
|
|
39
39
|
((_c = (_b = (_a = record._meta) === null || _a === void 0 ? void 0 : _a.transformedRow) === null || _b === void 0 ? void 0 : _b[name]) === null || _c === void 0 ? void 0 : _c.transformed);
|
|
40
40
|
return (_jsx(SpreadsheetField, __assign({ validationError: validationError, validationWarning: validationWarning, isHighlighted: isHighlighted }, { children: _jsx(Autocomplete, { placement: "bottom", isInputDisabled: isInputDisabled, hasError: !!validationError, hasWarning: !!validationWarning, options: options, value: value, icon: chevronDownIcon, onChange: function (v) { return !isTransformTooltipOpened && setValue(v); }, disabledWhen: isTransformTooltipOpened, id: id }) })));
|
|
@@ -29,7 +29,7 @@ import { useMemo } from "react";
|
|
|
29
29
|
import styled, { css } from "styled-components";
|
|
30
30
|
import { SpreadsheetField, useSpreadsheetField } from ".";
|
|
31
31
|
import { Div } from "../../../../../styled/utils";
|
|
32
|
-
import {
|
|
32
|
+
import { useReviewContext } from "../../../../Review/ReviewContextProvider";
|
|
33
33
|
import { AVERAGE_CHAR_SIZE, getFieldContentWidth } from "./utils";
|
|
34
34
|
var parseValue = function (value) {
|
|
35
35
|
var isFalsyButNotZero = !value && value !== 0;
|
|
@@ -39,7 +39,7 @@ export var SpreadsheetInput = function (_a) {
|
|
|
39
39
|
var _b, _c, _d, _e, _f, _g;
|
|
40
40
|
var name = _a.name, record = _a.record, fieldType = _a.fieldType, columnWidth = _a.columnWidth, props = __rest(_a, ["name", "record", "fieldType", "columnWidth"]);
|
|
41
41
|
var _h = useSpreadsheetField(name, record, fieldType), value = _h.value, setValue = _h.setValue, validationError = _h.validationError, validationWarning = _h.validationWarning;
|
|
42
|
-
var isTransformTooltipOpened =
|
|
42
|
+
var isTransformTooltipOpened = useReviewContext().isTransformTooltipOpened;
|
|
43
43
|
var defaultWidthAsNumber = Number.parseInt(columnWidth.replace("px", ""));
|
|
44
44
|
var _fieldContentWidth = getFieldContentWidth({
|
|
45
45
|
record: record,
|
|
@@ -2,7 +2,6 @@ import { Field, Record, TransformedRecord } from "../../../../types";
|
|
|
2
2
|
type TransformRecordArgs = {
|
|
3
3
|
record: Record;
|
|
4
4
|
fields: Field[];
|
|
5
|
-
possibleDateFormats?: string[];
|
|
6
5
|
};
|
|
7
|
-
export declare const transformRecord: ({ record, fields
|
|
6
|
+
export declare const transformRecord: ({ record, fields }: TransformRecordArgs) => TransformedRecord;
|
|
8
7
|
export {};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var runTransformation = function (fieldValue, transformation, field
|
|
1
|
+
import { fieldTransformations } from "./transformators";
|
|
2
|
+
var runTransformation = function (fieldValue, transformation, field) {
|
|
3
3
|
var transformationType = transformation.transformation_type;
|
|
4
4
|
var transformerFunction = fieldTransformations[transformationType];
|
|
5
|
-
if (Object.keys(datesDateTimesAndTimesTransformations).includes(transformationType)) {
|
|
6
|
-
var dateTimeTransformFunction = transformerFunction;
|
|
7
|
-
return dateTimeTransformFunction(fieldValue, transformation, field, possibleDateFormats);
|
|
8
|
-
}
|
|
9
5
|
return transformerFunction(fieldValue, transformation, field);
|
|
10
6
|
};
|
|
11
7
|
export var transformRecord = function (_a) {
|
|
12
|
-
var record = _a.record, fields = _a.fields
|
|
8
|
+
var record = _a.record, fields = _a.fields;
|
|
13
9
|
var transformedRecords = {};
|
|
14
10
|
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
15
11
|
var currentField = fields_1[_i];
|
|
@@ -27,7 +23,7 @@ export var transformRecord = function (_a) {
|
|
|
27
23
|
var fieldWasTransformed = false;
|
|
28
24
|
for (var i = 0; i < fieldTransformations_1.length; i++) {
|
|
29
25
|
var currentTransformation = fieldTransformations_1[i];
|
|
30
|
-
var transformed = runTransformation(transformedField.transformed, currentTransformation, currentField
|
|
26
|
+
var transformed = runTransformation(transformedField.transformed, currentTransformation, currentField);
|
|
31
27
|
if (transformed.transformationWasNeeded) {
|
|
32
28
|
fieldWasTransformed = true;
|
|
33
29
|
transformedField = {
|
|
@@ -47,5 +43,5 @@ export var transformRecord = function (_a) {
|
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
45
|
var isTransformedRecordsEmpty = Object.keys(transformedRecords).length === 0;
|
|
50
|
-
return isTransformedRecordsEmpty ?
|
|
46
|
+
return isTransformedRecordsEmpty ? {} : transformedRecords;
|
|
51
47
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
export declare const parseDateFromUserInput: (userInput: string) => DateTime | null;
|
|
3
|
+
export declare const parseTimeFromUserInput: (input: any) => DateTime;
|
|
4
|
+
export declare const parseTimeFromDateTimeorTimeInput: (userInput: any) => DateTime;
|
|
5
|
+
export declare const parseDateTimeFromUserInput: (userInput: any) => DateTime;
|