fuse-importer 0.26.7 → 0.26.9
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 +13 -11
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +3 -2
- package/lib/esm/Importer/Review/ReviewContextProvider.js +20 -20
- package/lib/esm/Importer/Stepper/index.js +14 -13
- package/lib/esm/Importer/Uploader/HeadersPreview.js +16 -8
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.d.ts +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +56 -0
- package/lib/esm/Importer/common/Spreadsheet/{SpreadsheetContextProvider.d.ts → SpreadsheetContextProvider/index.d.ts} +12 -8
- package/lib/esm/Importer/common/Spreadsheet/{SpreadsheetContextProvider.js → SpreadsheetContextProvider/index.js} +28 -18
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.d.ts +14 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.d.ts +2 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +5 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +9 -4
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +18 -13
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +1 -3
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +7 -4
- package/lib/esm/Importer/common/Spreadsheet/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +7 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +25 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.d.ts +8 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +106 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +6 -2
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +26 -22
- package/lib/esm/Importer/data/index.d.ts +19 -3
- package/lib/esm/Importer/data/index.js +29 -30
- package/lib/esm/Importer/index.js +1 -1
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +9 -5
- package/lib/esm/common/Table/TableActions/RowFilters.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +2 -1
- package/lib/esm/common/Table/TableActions/hooks.d.ts +0 -2
- package/lib/esm/common/Table/TableActions/hooks.js +0 -39
- package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +2 -2
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +4 -4
- package/lib/esm/common/Table/TableView/TableRows/index.js +7 -4
- package/lib/esm/common/Table/TableView/index.d.ts +1 -1
- package/lib/esm/common/Table/TableView/index.js +1 -2
- package/lib/esm/common/Table/TableView/types.d.ts +0 -1
- package/lib/esm/common/columnsTransformations.d.ts +15 -0
- package/lib/esm/common/columnsTransformations.js +92 -0
- package/lib/esm/common/columnsValidations.js +83 -3
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/inputs/Autocomplete.js +1 -1
- package/lib/esm/common/inputs/Checkbox.js +1 -1
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +15 -24
- package/lib/esm/locales/de.d.ts +5 -0
- package/lib/esm/locales/de.js +6 -1
- package/lib/esm/locales/en.d.ts +5 -0
- package/lib/esm/locales/en.js +6 -1
- package/lib/esm/locales/es.d.ts +5 -0
- package/lib/esm/locales/es.js +6 -1
- package/lib/esm/locales/fr.d.ts +5 -0
- package/lib/esm/locales/fr.js +6 -1
- package/lib/esm/types.d.ts +36 -8
- package/lib/esm/types.js +15 -0
- package/lib/main.js +24 -24
- package/package.json +1 -1
|
@@ -15,13 +15,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
17
|
import { useEffect, useRef } from "react";
|
|
18
|
-
import
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
19
|
+
import styled, { ThemeProvider, css } from "styled-components";
|
|
19
20
|
import { Toast } from "../common";
|
|
20
21
|
import { Div } from "../styled";
|
|
21
|
-
import { Footer } from "./common/Footer";
|
|
22
|
-
import { GlobalStyle } from "./common/GlobalStyle";
|
|
23
|
-
import { ImporterFonts } from "./common/ImporterFonts";
|
|
24
|
-
import { useImporterContext } from "./contexts/ImporterContextProvider";
|
|
25
22
|
import Matcher from "./Matcher";
|
|
26
23
|
import { PreviewFirstTime } from "./PreviewFirstTime";
|
|
27
24
|
import { PreviewModeBanner } from "./PreviewModeBanner";
|
|
@@ -30,7 +27,11 @@ import { ReviewContextProvider } from "./Review/ReviewContextProvider";
|
|
|
30
27
|
import { Stepper } from "./Stepper/index";
|
|
31
28
|
import { TrialModeBanner } from "./TrialModeBanner";
|
|
32
29
|
import Uploader from "./Uploader";
|
|
33
|
-
import {
|
|
30
|
+
import { AppLoading } from "./common/AppLoading";
|
|
31
|
+
import { Footer } from "./common/Footer";
|
|
32
|
+
import { GlobalStyle } from "./common/GlobalStyle";
|
|
33
|
+
import { ImporterFonts } from "./common/ImporterFonts";
|
|
34
|
+
import { useImporterContext } from "./contexts/ImporterContextProvider";
|
|
34
35
|
export var Layout = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n display: flex;\n flex-direction: column;\n height: 100vh;\n left: 0;\n overflow-y: auto;\n position: fixed;\n top: 0;\n width: 100vw;\n z-index: ", ";\n ", ";\n"], ["\n background: ", ";\n display: flex;\n flex-direction: column;\n height: 100vh;\n left: 0;\n overflow-y: auto;\n position: fixed;\n top: 0;\n width: 100vw;\n z-index: ", ";\n ", ";\n"])), function (_a) {
|
|
35
36
|
var theme = _a.theme;
|
|
36
37
|
return theme.colors.backgroundInterface;
|
|
@@ -40,21 +41,22 @@ var Content = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplate
|
|
|
40
41
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n flex: ", ";\n "], ["\n background-color: ", ";\n flex: ", ";\n "])), colors.backgroundInterface, inTrialMode ? "none" : 1);
|
|
41
42
|
});
|
|
42
43
|
export var ImporterWithContext = function () {
|
|
43
|
-
var _a = useImporterContext(), inTrialMode = _a.inTrialMode, currentStepIndex = _a.currentStepIndex, matcherSubstep = _a.matcherSubstep, theme = _a.theme, logoURL = _a.logoURL, previewFirstTime = _a.previewFirstTime, _b = _a.importerOptions, zIndex = _b.zIndex, previewMode = _b.previewMode;
|
|
44
|
+
var _a = useImporterContext(), inTrialMode = _a.inTrialMode, currentStepIndex = _a.currentStepIndex, matcherSubstep = _a.matcherSubstep, templateHeaders = _a.templateHeaders, theme = _a.theme, logoURL = _a.logoURL, previewFirstTime = _a.previewFirstTime, headerRowIndex = _a.headerRowIndex, initialRecords = _a.initialRecords, _b = _a.importerOptions, zIndex = _b.zIndex, previewMode = _b.previewMode;
|
|
44
45
|
var layoutRef = useRef(null);
|
|
45
46
|
var t = useTranslation().t;
|
|
46
47
|
useEffect(function () {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
var _a;
|
|
49
|
+
(_a = layoutRef === null || layoutRef === void 0 ? void 0 : layoutRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
50
|
+
}, [currentStepIndex, matcherSubstep, layoutRef.current]);
|
|
49
51
|
var stepLabels = [
|
|
50
52
|
t("general:steps.upload"),
|
|
51
53
|
t("general:steps.match"),
|
|
52
54
|
t("general:steps.review"),
|
|
53
55
|
];
|
|
54
56
|
function renderContent() {
|
|
55
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Div, { children: [previewMode && _jsx(PreviewModeBanner, {}), !previewMode && _jsx(TrialModeBanner, {}), _jsx(Stepper, { stepLabels: stepLabels, logoURL: logoURL })] }), _jsxs(Content, { children: [currentStepIndex === 0 && _jsx(Uploader, {}), currentStepIndex === 1 && _jsx(Matcher, {}), currentStepIndex === 2 && _jsx(Review, {})] }), inTrialMode && (_jsx(Content, __assign({ inTrialMode: inTrialMode }, { children: _jsx(Footer, {}) })))] }));
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Div, { children: [previewMode && _jsx(PreviewModeBanner, {}), !previewMode && _jsx(TrialModeBanner, {}), _jsx(Stepper, { stepLabels: stepLabels, logoURL: logoURL })] }), _jsxs(Content, { children: [currentStepIndex === 0 && _jsx(Uploader, {}), currentStepIndex === 1 && _jsx(Matcher, {}), currentStepIndex === 2 && templateHeaders && _jsx(Review, {})] }), inTrialMode && (_jsx(Content, __assign({ inTrialMode: inTrialMode }, { children: _jsx(Footer, {}) })))] }));
|
|
56
58
|
}
|
|
57
59
|
var shouldShowPreviewFirstTime = previewFirstTime && previewMode;
|
|
58
|
-
return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(Toast, {}), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), _jsx(ReviewContextProvider, { children: _jsx(Layout, __assign({ zIndex: zIndex, ref: layoutRef }, { children: shouldShowPreviewFirstTime ? _jsx(PreviewFirstTime, {}) : renderContent() })) })] })));
|
|
60
|
+
return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(Toast, {}), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), templateHeaders ? (_jsx(ReviewContextProvider, __assign({ initialRecords: initialRecords }, { children: _jsx(Layout, __assign({ zIndex: zIndex, ref: layoutRef }, { children: shouldShowPreviewFirstTime ? (_jsx(PreviewFirstTime, {})) : (renderContent()) })) }))) : (_jsx(AppLoading, {}))] })));
|
|
59
61
|
};
|
|
60
62
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppResponse, Field, OnValidateRecord, RecordDataSet } from "../../types";
|
|
1
|
+
import { AppResponse, Field, OnValidateRecord, Record, RecordDataSet } from "../../types";
|
|
2
2
|
import { OnDataSetChanged, OnValidationStateChanged } from "../common/Spreadsheet";
|
|
3
3
|
type State = {
|
|
4
4
|
previewInitialDataSet: RecordDataSet;
|
|
@@ -21,8 +21,9 @@ type State = {
|
|
|
21
21
|
};
|
|
22
22
|
type ExportDataType = "csv" | "excel";
|
|
23
23
|
type Props = {
|
|
24
|
+
initialRecords?: Record[];
|
|
24
25
|
children: JSX.Element;
|
|
25
26
|
};
|
|
26
|
-
export declare const ReviewContextProvider: ({ children }: Props) => JSX.Element;
|
|
27
|
+
export declare const ReviewContextProvider: ({ initialRecords, children }: Props) => JSX.Element;
|
|
27
28
|
export declare const useReviewContext: () => State;
|
|
28
29
|
export {};
|
|
@@ -72,7 +72,8 @@ import { AppLoading } from "../common/AppLoading";
|
|
|
72
72
|
import { isRecordEmpty } from "../common/Spreadsheet/common";
|
|
73
73
|
import { sendRecordsToIntegrations } from "../common/utils";
|
|
74
74
|
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
75
|
-
import {
|
|
75
|
+
import { transformToRecords } from "../data/index";
|
|
76
|
+
import { getPreviewDataSet, getReviewDataSet, getTemplateFields, recordListToDataSet, } from "../data";
|
|
76
77
|
var ReviewContext = createContext({});
|
|
77
78
|
var trackImportedRowsCount = function (fuseApi, templateSlug, rowCount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
79
|
var error_1, errorMessage;
|
|
@@ -123,8 +124,8 @@ function csvExport(data) {
|
|
|
123
124
|
writeFile(workbook, "export.csv");
|
|
124
125
|
}
|
|
125
126
|
export var ReviewContextProvider = function (_a) {
|
|
126
|
-
var children = _a.children;
|
|
127
|
-
var _b = useImporterContext(), templateHeaderMatchings = _b.templateHeaderMatchings, enumFieldValueMatchings = _b.enumFieldValueMatchings, templateHeaders = _b.templateHeaders, uploadedDataHeaders = _b.uploadedDataHeaders, uploadedData = _b.uploadedData, currentStepIndex = _b.currentStepIndex, integrations = _b.integrations, templateSlug = _b.templateSlug, fuseApi = _b.fuseApi, _c = _b.importerOptions, disableSubmitIfInvalid = _c.disableSubmitIfInvalid, batchValidationDelayMs = _c.batchValidationDelayMs, batchValidationSize = _c.batchValidationSize, previewMode = _c.previewMode, loadingComponent = _c.loadingComponent, onSubmit = _b.onSubmit, onValidateRecord = _b.onValidateRecord, formatRecord = _b.formatRecord, selectedRows = _b.selectedRows;
|
|
127
|
+
var initialRecords = _a.initialRecords, children = _a.children;
|
|
128
|
+
var _b = useImporterContext(), templateHeaderMatchings = _b.templateHeaderMatchings, enumFieldValueMatchings = _b.enumFieldValueMatchings, templateHeaders = _b.templateHeaders, uploadedDataHeaders = _b.uploadedDataHeaders, headerRowIndex = _b.headerRowIndex, uploadedData = _b.uploadedData, currentStepIndex = _b.currentStepIndex, integrations = _b.integrations, templateSlug = _b.templateSlug, fuseApi = _b.fuseApi, setSelectedRows = _b.setSelectedRows, _c = _b.importerOptions, disableSubmitIfInvalid = _c.disableSubmitIfInvalid, batchValidationDelayMs = _c.batchValidationDelayMs, batchValidationSize = _c.batchValidationSize, previewMode = _c.previewMode, loadingComponent = _c.loadingComponent, onSubmit = _b.onSubmit, onValidateRecord = _b.onValidateRecord, formatRecord = _b.formatRecord, selectedRows = _b.selectedRows;
|
|
128
129
|
var _d = useState(false), isSubmitting = _d[0], setIsSubmitting = _d[1];
|
|
129
130
|
var _e = useState(false), isSubmitDisabled = _e[0], setIsSubmitDisabled = _e[1];
|
|
130
131
|
var _f = useState(false), importWasSuccessful = _f[0], setImportWasSuccessful = _f[1];
|
|
@@ -238,27 +239,26 @@ export var ReviewContextProvider = function (_a) {
|
|
|
238
239
|
setPreviewInitialDataSet(initialDataSet);
|
|
239
240
|
}
|
|
240
241
|
else if (currentStepIndex === 2) {
|
|
242
|
+
var fields = getTemplateFields({ templateHeaders: templateHeaders });
|
|
241
243
|
//Review spreadsheet data
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
244
|
+
var _records = initialRecords ||
|
|
245
|
+
transformToRecords({
|
|
246
|
+
templateHeaderMatchings: templateHeaderMatchings,
|
|
247
|
+
enumFieldValueMatchings: enumFieldValueMatchings,
|
|
248
|
+
templateHeaders: templateHeaders,
|
|
249
|
+
uploadedDataHeaders: uploadedDataHeaders,
|
|
250
|
+
uploadedData: uploadedData.slice(headerRowIndex + 1),
|
|
251
|
+
formatRecord: formatRecord,
|
|
252
|
+
});
|
|
253
|
+
var initialDataSet = getReviewDataSet({
|
|
254
|
+
records: _records,
|
|
255
|
+
fields: fields,
|
|
256
|
+
}).initialDataSet;
|
|
257
|
+
setSelectedRows([]);
|
|
250
258
|
setReviewFields(fields);
|
|
251
259
|
setReviewInitialDataSet(initialDataSet);
|
|
252
260
|
}
|
|
253
|
-
}, [
|
|
254
|
-
uploadedData,
|
|
255
|
-
currentStepIndex,
|
|
256
|
-
enumFieldValueMatchings,
|
|
257
|
-
templateHeaderMatchings,
|
|
258
|
-
templateHeaders,
|
|
259
|
-
uploadedDataHeaders,
|
|
260
|
-
uploadedData,
|
|
261
|
-
]);
|
|
261
|
+
}, [uploadedData, currentStepIndex, templateHeaders, uploadedData]);
|
|
262
262
|
var value = {
|
|
263
263
|
previewInitialDataSet: previewInitialDataSet,
|
|
264
264
|
previewFields: previewFields,
|
|
@@ -15,18 +15,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
17
|
import { useState } from "react";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
18
19
|
import styled, { css } from "styled-components";
|
|
19
|
-
import { Button,
|
|
20
|
+
import { Button, ChevronRightIcon, closeIconCondensed } from "../../common";
|
|
20
21
|
import { Div } from "../../styled/utils";
|
|
21
|
-
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
22
|
-
import { useReviewContext } from "../Review/ReviewContextProvider";
|
|
23
22
|
import { ColumnType } from "../Matcher/common/types";
|
|
24
|
-
import {
|
|
23
|
+
import { useReviewContext } from "../Review/ReviewContextProvider";
|
|
24
|
+
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
25
|
+
import { ConfirmCloseModal } from "./ConfirmCloseModal";
|
|
25
26
|
import { Step } from "./Step";
|
|
26
27
|
import { StepperSubmitModal } from "./StepperSubmitModal";
|
|
27
28
|
import { UnmatchedHeadersModal } from "./UnmatchedHeadersModal";
|
|
28
|
-
import {
|
|
29
|
-
import { useTranslation } from "react-i18next";
|
|
29
|
+
import { getEnumFieldValueMatchingsInitialValue } from "./common/getEnumFieldValueMatchingsInitialValue";
|
|
30
30
|
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; });
|
|
31
31
|
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"])));
|
|
32
32
|
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,7 +44,7 @@ export var Stepper = function (_a) {
|
|
|
44
44
|
var _c = useState(false), isSubmitModalOpen = _c[0], setIsSubmitModalOpen = _c[1];
|
|
45
45
|
var _d = useState(false), isConfirmCloseModalOpen = _d[0], setIsConfirmCloseModalOpen = _d[1];
|
|
46
46
|
var _e = useReviewContext(), appResponse = _e.appResponse, isSubmitDisabled = _e.isSubmitDisabled, onSubmit = _e.onSubmit;
|
|
47
|
-
var _f = useImporterContext(), currentStepIndex = _f.currentStepIndex, templateHeaderMatchings = _f.templateHeaderMatchings, matcherSubstep = _f.matcherSubstep, templateHeaders = _f.templateHeaders, uploadedDataEnumFieldValues = _f.uploadedDataEnumFieldValues, setEnumFieldValueMatchings = _f.setEnumFieldValueMatchings, setMatcherSubstep = _f.setMatcherSubstep, setCurrentStepIndex = _f.setCurrentStepIndex, onClose = _f.onClose, isUsingManualImport = _f.isUsingManualImport, resetImporterWhenUsingManualImport = _f.resetImporterWhenUsingManualImport, uploadedData = _f.uploadedData;
|
|
47
|
+
var _f = useImporterContext(), initialRecords = _f.initialRecords, currentStepIndex = _f.currentStepIndex, templateHeaderMatchings = _f.templateHeaderMatchings, matcherSubstep = _f.matcherSubstep, templateHeaders = _f.templateHeaders, uploadedDataEnumFieldValues = _f.uploadedDataEnumFieldValues, setEnumFieldValueMatchings = _f.setEnumFieldValueMatchings, setMatcherSubstep = _f.setMatcherSubstep, setCurrentStepIndex = _f.setCurrentStepIndex, onClose = _f.onClose, isUsingManualImport = _f.isUsingManualImport, resetImporterWhenUsingManualImport = _f.resetImporterWhenUsingManualImport, uploadedData = _f.uploadedData;
|
|
48
48
|
var templateHeaderLabels = Object.keys(templateHeaderMatchings || []);
|
|
49
49
|
var unmatchedHeadersCount = templateHeaderLabels.filter(function (templateHeaderLabel) { return !templateHeaderMatchings[templateHeaderLabel]; }).length;
|
|
50
50
|
var isLastSubMatchStep = matcherSubstep === 1;
|
|
@@ -103,12 +103,13 @@ export var Stepper = function (_a) {
|
|
|
103
103
|
var isVerifyStep = currentStepIndex === 0 && !!uploadedData;
|
|
104
104
|
var isMatchStep = currentStepIndex === 1;
|
|
105
105
|
var isReviewStep = currentStepIndex === 2;
|
|
106
|
-
var stepsUI = (_jsx(Div, __assign({ dflex: true, centered: true }, { children:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
var stepsUI = (_jsx(Div, __assign({ dflex: true, centered: true }, { children: !initialRecords &&
|
|
107
|
+
stepLabels.map(function (label, index) {
|
|
108
|
+
var isLast = index === stepLabels.length - 1;
|
|
109
|
+
var isCompleted = index < currentStepIndex;
|
|
110
|
+
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));
|
|
111
|
+
}) })));
|
|
112
|
+
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") })) }))] }))) })));
|
|
112
113
|
var rightButtonUI = (_jsxs(StepperButtonContainer, __assign({ align: "right" }, { children: [(isMatchStep || isVerifyStep) && (_jsx(Button, __assign({ variant: "primary", onClick: continueToNextStep }, { children: t("stepper.continue") }))), isReviewStep && (_jsx(Button, __assign({ variant: "primary", isDisabled: 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 }))] })));
|
|
113
114
|
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 () {
|
|
114
115
|
return setIsUnmatchedHeadersModalOpen(false);
|
|
@@ -15,22 +15,30 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
import styled from "styled-components";
|
|
18
|
+
import styled, { css } from "styled-components";
|
|
19
19
|
import { Div } from "../../styled/utils";
|
|
20
20
|
import { useReviewContext } from "../Review/ReviewContextProvider";
|
|
21
|
-
import
|
|
21
|
+
import SpreadsheetBase from "../common/Spreadsheet";
|
|
22
22
|
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
23
23
|
import { HeaderButtons } from "./HeaderButtons";
|
|
24
|
-
|
|
25
|
-
var
|
|
24
|
+
import { useEffect } from "react";
|
|
25
|
+
var Spreadsheet = styled(SpreadsheetBase)(function () { return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n /* rows will be removed for match and review steps */\n .before-selected-row {\n opacity: 0.2;\n }\n "], ["\n /* rows will be removed for match and review steps */\n .before-selected-row {\n opacity: 0.2;\n }\n "]))); });
|
|
26
|
+
var HeaderContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: 32px;\n\n @media (max-width: 1050px) {\n margin-left: 0px;\n\n > div:first-of-type {\n text-align: center;\n }\n\n div:last-of-type {\n margin-left: 0px;\n }\n }\n"], ["\n margin-left: 32px;\n\n @media (max-width: 1050px) {\n margin-left: 0px;\n\n > div:first-of-type {\n text-align: center;\n }\n\n div:last-of-type {\n margin-left: 0px;\n }\n }\n"])));
|
|
27
|
+
var DescriptionAndButtons = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n @media (max-width: 1050px) {\n flex-direction: column;\n gap: 16px;\n }\n"], ["\n @media (max-width: 1050px) {\n flex-direction: column;\n gap: 16px;\n }\n"])));
|
|
26
28
|
var HeadersPreview = function () {
|
|
27
29
|
var _a = useReviewContext(), fields = _a.previewFields, initialDataSet = _a.previewInitialDataSet;
|
|
28
30
|
var t = useTranslation("upload").t;
|
|
29
|
-
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows;
|
|
30
|
-
|
|
31
|
+
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows, setHeaderRowIndex = _b.setHeaderRowIndex;
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (initialDataSet && selectedRows[0]) {
|
|
34
|
+
var headerRowIndex = Object.keys(initialDataSet).findIndex(function (key) { return key === selectedRows[0]; });
|
|
35
|
+
setHeaderRowIndex(headerRowIndex);
|
|
36
|
+
}
|
|
37
|
+
}, [initialDataSet, selectedRows]);
|
|
38
|
+
return (_jsxs(Div, __assign({ flexColumn: true, h100: true }, { children: [_jsxs(HeaderContainer, { children: [_jsx(Div, __assign({ h2: true, mt: 40, mb: 16 }, { children: t("headers_preview.title") })), _jsxs(DescriptionAndButtons, __assign({ body1: true, mb: 24, alignCenter: true }, { children: [t("headers_preview.description"), _jsx(HeaderButtons, {})] }))] }), _jsx(Div, __assign({ w100: true, h100: true, justifyCenter: true }, { children: initialDataSet && (_jsx(Spreadsheet, { isReadOnly: true, initialDataSet: initialDataSet, fields: fields, options: {
|
|
31
39
|
showCheckboxColumn: true,
|
|
32
|
-
|
|
40
|
+
withSingleRowSelect: true,
|
|
33
41
|
}, selectedRows: selectedRows, setSelectedRows: setSelectedRows })) }))] })));
|
|
34
42
|
};
|
|
35
43
|
export default HeadersPreview;
|
|
36
|
-
var templateObject_1, templateObject_2;
|
|
44
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BatchValidationErrors, RecordDataSet } from "../../../../types";
|
|
2
|
+
import { SpreadsheetFilter } from "./useSpreadsheetFilter";
|
|
3
|
+
export declare const filterRecordsBySearchValue: (obj: RecordDataSet, value: string) => RecordDataSet;
|
|
4
|
+
export declare const filterRecordsByType: (obj: RecordDataSet, filterType: SpreadsheetFilter["byRow"]) => RecordDataSet;
|
|
5
|
+
export declare const filterRecordsByError: (obj: RecordDataSet, keyToFilter: string, errors: BatchValidationErrors) => RecordDataSet;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//Filter records by search value
|
|
2
|
+
export var filterRecordsBySearchValue = function (obj, value) {
|
|
3
|
+
var isObject = function (value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
};
|
|
6
|
+
var includesSearchValue = function (value, searchValue) {
|
|
7
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
8
|
+
var stringValue = String(value).toLowerCase();
|
|
9
|
+
var searchValueLower = searchValue.toLowerCase();
|
|
10
|
+
return stringValue.includes(searchValueLower);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
var filteredObj = {};
|
|
15
|
+
for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
|
|
16
|
+
var _b = _a[_i], key = _b[0], currentObj = _b[1];
|
|
17
|
+
if (!isObject(currentObj)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
var matches = Object.values(currentObj).some(function (propertyValue) {
|
|
21
|
+
return includesSearchValue(propertyValue, value);
|
|
22
|
+
});
|
|
23
|
+
if (matches) {
|
|
24
|
+
filteredObj[key] = currentObj;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return filteredObj;
|
|
28
|
+
};
|
|
29
|
+
export var filterRecordsByType = function (obj, filterType) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
var rowIsEmpty = function (row) {
|
|
32
|
+
return Object.keys(row).every(function (key) {
|
|
33
|
+
if (key === "_meta")
|
|
34
|
+
return true;
|
|
35
|
+
return !row[key];
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var filteredObj = {};
|
|
39
|
+
for (var key in obj) {
|
|
40
|
+
if (filterType === "all" ||
|
|
41
|
+
(((_b = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.isInvalid) !== (filterType === "valid") &&
|
|
42
|
+
!rowIsEmpty(obj[key]))) {
|
|
43
|
+
filteredObj[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return filteredObj;
|
|
47
|
+
};
|
|
48
|
+
//Filter records by selected column error
|
|
49
|
+
export var filterRecordsByError = function (obj, keyToFilter, errors) {
|
|
50
|
+
var filteredObj = {};
|
|
51
|
+
var filteredKeys = Object.keys(errors).filter(function (key) { var _a, _b; return ((_b = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.isInvalid) && errors[key][keyToFilter]; });
|
|
52
|
+
for (var i = 0; i < filteredKeys.length; i++) {
|
|
53
|
+
filteredObj[filteredKeys[i]] = obj[filteredKeys[i]];
|
|
54
|
+
}
|
|
55
|
+
return filteredObj;
|
|
56
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SpreadsheetOptions } from "
|
|
3
|
-
import { BatchValidationErrors, Field, Record, RecordDataSet } from "
|
|
4
|
-
import { SortBy, SpreadsheetProps } from "
|
|
5
|
-
import { ValidationState } from "
|
|
2
|
+
import { SpreadsheetOptions } from "../../../..";
|
|
3
|
+
import { BatchValidationErrors, Field, Record, RecordDataSet } from "../../../../types";
|
|
4
|
+
import { SortBy, SpreadsheetProps } from "../common/types";
|
|
5
|
+
import { ValidationState } from "../hooks";
|
|
6
|
+
import { SpreadsheetFilter } from "./useSpreadsheetFilter";
|
|
6
7
|
export type OnDataSetChanged = (dataSet: RecordDataSet) => void;
|
|
7
8
|
export type OnValidationStateChanged = (state: ValidationState) => void;
|
|
8
9
|
type State = {
|
|
@@ -12,7 +13,6 @@ type State = {
|
|
|
12
13
|
isReadOnly?: boolean;
|
|
13
14
|
errors: BatchValidationErrors;
|
|
14
15
|
warnings: BatchValidationErrors;
|
|
15
|
-
highlightFirstRow: boolean;
|
|
16
16
|
options: SpreadsheetOptions;
|
|
17
17
|
sortByFieldErrors: string;
|
|
18
18
|
sortByFieldWarnings: string;
|
|
@@ -26,9 +26,13 @@ type State = {
|
|
|
26
26
|
lastClickedIndexRef: React.MutableRefObject<number | null>;
|
|
27
27
|
filteredInputValue: string;
|
|
28
28
|
setFilteredInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
29
|
-
selectedErrorToFilter: string;
|
|
30
|
-
setSelectedErrorToFilter: React.Dispatch<React.SetStateAction<string>>;
|
|
31
29
|
addNewRowsToSpreadsheet: () => void;
|
|
30
|
+
spreadsheetFilter: SpreadsheetFilter;
|
|
31
|
+
filterRecordsByRowType: (filterByRow: SpreadsheetFilter["byRow"]) => void;
|
|
32
|
+
filterRecordsByFieldErrors: (filterByColumn: string) => void;
|
|
33
|
+
resetSpreadsheetFilter: () => void;
|
|
34
|
+
recordsWithValuesCount: number;
|
|
35
|
+
filteredDataCount: number;
|
|
32
36
|
checkboxColumnWidth: number;
|
|
33
37
|
isFiltering: boolean;
|
|
34
38
|
sortBy: SortBy | null;
|
|
@@ -37,6 +41,6 @@ type State = {
|
|
|
37
41
|
type Props = SpreadsheetProps & {
|
|
38
42
|
children: JSX.Element;
|
|
39
43
|
};
|
|
40
|
-
export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly,
|
|
44
|
+
export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, getSortCompareFn, }: Props) => JSX.Element;
|
|
41
45
|
export declare const useSpreadsheetContext: () => State;
|
|
42
46
|
export {};
|
|
@@ -23,8 +23,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import { get } from "lodash";
|
|
25
25
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
26
|
-
import { addMeta } from "../../../
|
|
27
|
-
import { useValidationState } from "
|
|
26
|
+
import { addMeta } from "../../../data";
|
|
27
|
+
import { useValidationState } from "../hooks";
|
|
28
|
+
import { useSpreadsheetFilter, } from "./useSpreadsheetFilter";
|
|
29
|
+
import { filterRecordsByType, filterRecordsByError, filterRecordsBySearchValue, } from "./filterMethods";
|
|
30
|
+
import { hasValueInAnyField } from "./utils";
|
|
28
31
|
var getDefaultSortCompareFn = function (sortBy) {
|
|
29
32
|
return function (a, b) {
|
|
30
33
|
var aField = get(a, sortBy.field);
|
|
@@ -42,15 +45,15 @@ var getDefaultSortCompareFn = function (sortBy) {
|
|
|
42
45
|
};
|
|
43
46
|
var SpreadsheetContext = createContext({});
|
|
44
47
|
export var SpreadsheetContextProvider = function (_a) {
|
|
45
|
-
var initialDataSet = _a.initialDataSet, fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly,
|
|
48
|
+
var initialDataSet = _a.initialDataSet, fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly, children = _a.children, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows, _b = _a.getSortCompareFn, getSortCompareFn = _b === void 0 ? getDefaultSortCompareFn : _b;
|
|
46
49
|
var _c = useState(initialDataSet), dataSet = _c[0], setDataSet = _c[1];
|
|
47
50
|
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
48
51
|
var _e = useState(null), sortByFieldErrors = _e[0], setSortByFieldErrors = _e[1];
|
|
49
52
|
var _f = useState(null), sortByFieldWarnings = _f[0], setSortByFieldWarnings = _f[1];
|
|
50
53
|
var _g = useState(""), filteredInputValue = _g[0], setFilteredInputValue = _g[1];
|
|
51
|
-
var _h = useState(
|
|
52
|
-
var _j = useState(null), sortBy = _j[0], setSortBy = _j[1];
|
|
54
|
+
var _h = useState(null), sortBy = _h[0], setSortBy = _h[1];
|
|
53
55
|
var addRowTimeoutRef = useRef(null);
|
|
56
|
+
var _j = useSpreadsheetFilter(), spreadsheetFilter = _j.spreadsheetFilter, filterRecordsByRowType = _j.filterRecordsByRowType, filterRecordsByFieldErrors = _j.filterRecordsByFieldErrors, resetSpreadsheetFilter = _j.resetSpreadsheetFilter;
|
|
54
57
|
var _k = useValidationState({
|
|
55
58
|
dataSet: dataSet,
|
|
56
59
|
initialDataSet: initialDataSet,
|
|
@@ -60,10 +63,14 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
60
63
|
setDataSet: setDataSet,
|
|
61
64
|
setIsLoading: setIsLoading,
|
|
62
65
|
onValidateRecord: onValidateRecord,
|
|
63
|
-
}), updateRecordAndRevalidate = _k.updateRecordAndRevalidate, deleteRecords = _k.deleteRecords,
|
|
66
|
+
}), updateRecordAndRevalidate = _k.updateRecordAndRevalidate, deleteRecords = _k.deleteRecords, warnings = _k.warnings, errors = _k.errors, validationState = __rest(_k, ["updateRecordAndRevalidate", "deleteRecords", "warnings", "errors"]);
|
|
64
67
|
var addNewRowsToSpreadsheet = function () {
|
|
65
68
|
addRowTimeoutRef.current = setTimeout(function () {
|
|
66
|
-
var
|
|
69
|
+
var _a, _b;
|
|
70
|
+
var highestRowIndex = -1;
|
|
71
|
+
for (var key in dataSet)
|
|
72
|
+
if (((_b = (_a = dataSet[key]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.rowIndex) > highestRowIndex)
|
|
73
|
+
highestRowIndex = dataSet[key]._meta.rowIndex;
|
|
67
74
|
var newRow = addMeta({}, highestRowIndex + 1);
|
|
68
75
|
setDataSet(function (oldValues) {
|
|
69
76
|
var _a;
|
|
@@ -76,16 +83,13 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
76
83
|
deleteRecords(selectedRows, errors, warnings);
|
|
77
84
|
};
|
|
78
85
|
var dataSnapshot = useMemo(function () {
|
|
86
|
+
var filteredData = spreadsheetFilter.type === "rowBased"
|
|
87
|
+
? filterRecordsByType(dataSet, spreadsheetFilter.byRow)
|
|
88
|
+
: filterRecordsByError(dataSet, spreadsheetFilter.byColumn.field, errors);
|
|
79
89
|
var filteredDatasetByString = filteredInputValue
|
|
80
|
-
? filterRecordsBySearchValue(
|
|
81
|
-
:
|
|
82
|
-
var
|
|
83
|
-
? filterRecordsByError(filteredDatasetByString, selectedErrorToFilter, errors, fields)
|
|
84
|
-
: filteredDatasetByString;
|
|
85
|
-
var dataSetValues = Object.values(filteredDatasetByError);
|
|
86
|
-
if (dataSetValues.length === 0) {
|
|
87
|
-
setSelectedErrorToFilter("");
|
|
88
|
-
}
|
|
90
|
+
? filterRecordsBySearchValue(filteredData, filteredInputValue)
|
|
91
|
+
: filteredData;
|
|
92
|
+
var dataSetValues = Object.values(filteredDatasetByString);
|
|
89
93
|
if (sortBy) {
|
|
90
94
|
return dataSetValues.sort(getSortCompareFn(sortBy));
|
|
91
95
|
}
|
|
@@ -101,12 +105,18 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
101
105
|
return dataSetValues;
|
|
102
106
|
}, [
|
|
103
107
|
filteredInputValue,
|
|
104
|
-
|
|
108
|
+
spreadsheetFilter,
|
|
105
109
|
sortBy,
|
|
106
110
|
Object.keys(dataSet).length,
|
|
107
111
|
sortByFieldErrors,
|
|
108
112
|
sortByFieldWarnings,
|
|
109
113
|
]);
|
|
114
|
+
var recordsWithValuesCount = useMemo(function () {
|
|
115
|
+
return Object.values(dataSet).filter(hasValueInAnyField).length;
|
|
116
|
+
}, [dataSet]);
|
|
117
|
+
var filteredDataCount = useMemo(function () {
|
|
118
|
+
return Object.values(dataSnapshot).filter(hasValueInAnyField).length;
|
|
119
|
+
}, [dataSnapshot]);
|
|
110
120
|
var isFiltering = useMemo(function () { return !!filteredInputValue; }, [filteredInputValue]);
|
|
111
121
|
useEffect(function () {
|
|
112
122
|
onDataSetChanged && onDataSetChanged(dataSet);
|
|
@@ -155,7 +165,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
155
165
|
return updatedData;
|
|
156
166
|
});
|
|
157
167
|
}, [dataSet, dataSnapshot]);
|
|
158
|
-
var value = __assign(__assign({ data: updatedDataSnapshot, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings,
|
|
168
|
+
var value = __assign(__assign({ data: updatedDataSnapshot, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, options: options, recordsWithValuesCount: recordsWithValuesCount, filteredDataCount: filteredDataCount, sortBy: sortBy, warnings: warnings, errors: errors, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: handleDeleteErrors, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef, addNewRowsToSpreadsheet: addNewRowsToSpreadsheet, spreadsheetFilter: spreadsheetFilter, resetSpreadsheetFilter: resetSpreadsheetFilter, filterRecordsByRowType: filterRecordsByRowType, filterRecordsByFieldErrors: filterRecordsByFieldErrors, checkboxColumnWidth: checkboxColumnWidth, setSortBy: setSortBy, isFiltering: isFiltering });
|
|
159
169
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
160
170
|
};
|
|
161
171
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type SpreadsheetFilter = {
|
|
2
|
+
type: "rowBased" | "columnBased";
|
|
3
|
+
byRow?: "all" | "invalid" | "valid";
|
|
4
|
+
byColumn?: {
|
|
5
|
+
type: "fieldWithErrors";
|
|
6
|
+
field: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const useSpreadsheetFilter: () => {
|
|
10
|
+
spreadsheetFilter: SpreadsheetFilter;
|
|
11
|
+
filterRecordsByRowType: (filterByRow: SpreadsheetFilter["byRow"]) => void;
|
|
12
|
+
filterRecordsByFieldErrors: (filterByColumn: string) => void;
|
|
13
|
+
resetSpreadsheetFilter: () => void;
|
|
14
|
+
};
|
package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useReducer } from "react";
|
|
2
|
+
export var useSpreadsheetFilter = function () {
|
|
3
|
+
var filtersInitialState = {
|
|
4
|
+
type: "rowBased",
|
|
5
|
+
byRow: "all",
|
|
6
|
+
};
|
|
7
|
+
function reducer(state, action) {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case "FILTER_BY_ROW_TYPE":
|
|
10
|
+
return { type: "rowBased", byRow: action.payload, byColumn: null };
|
|
11
|
+
case "FILTER_BY_FIELD_ERRORS":
|
|
12
|
+
return {
|
|
13
|
+
type: "columnBased",
|
|
14
|
+
byColumn: {
|
|
15
|
+
type: "fieldWithErrors",
|
|
16
|
+
field: action.payload,
|
|
17
|
+
},
|
|
18
|
+
byRow: null,
|
|
19
|
+
};
|
|
20
|
+
case "RESTORE_FILTERS":
|
|
21
|
+
return filtersInitialState;
|
|
22
|
+
default:
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
var _a = useReducer(reducer, filtersInitialState), spreadsheetFilter = _a[0], filtersDispatch = _a[1];
|
|
27
|
+
var resetSpreadsheetFilter = function () {
|
|
28
|
+
filtersDispatch({ type: "RESTORE_FILTERS" });
|
|
29
|
+
};
|
|
30
|
+
var filterRecordsByRowType = function (filterByRow) {
|
|
31
|
+
filtersDispatch({ type: "FILTER_BY_ROW_TYPE", payload: filterByRow });
|
|
32
|
+
};
|
|
33
|
+
var filterRecordsByFieldErrors = function (filterByColumn) {
|
|
34
|
+
filtersDispatch({
|
|
35
|
+
type: "FILTER_BY_FIELD_ERRORS",
|
|
36
|
+
payload: filterByColumn,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
spreadsheetFilter: spreadsheetFilter,
|
|
41
|
+
filterRecordsByRowType: filterRecordsByRowType,
|
|
42
|
+
filterRecordsByFieldErrors: filterRecordsByFieldErrors,
|
|
43
|
+
resetSpreadsheetFilter: resetSpreadsheetFilter,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var hasValueInAnyField = function (record) {
|
|
2
|
+
return Object.entries(record)
|
|
3
|
+
.filter(function (_a) {
|
|
4
|
+
var key = _a[0];
|
|
5
|
+
return key !== "_meta";
|
|
6
|
+
})
|
|
7
|
+
.some(function (_a) {
|
|
8
|
+
var key = _a[0], value = _a[1];
|
|
9
|
+
if (typeof value === "string") {
|
|
10
|
+
return value.trim() !== "";
|
|
11
|
+
}
|
|
12
|
+
return value !== null && value !== undefined;
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DivCSSProps } from "../../../../styled";
|
|
2
3
|
import { RecordDataSet, Field, SpreadsheetOptions, OnValidateRecord, Record } from "../../../../types";
|
|
3
4
|
import { OnDataSetChanged, OnValidationStateChanged } from "../SpreadsheetContextProvider";
|
|
4
5
|
export declare enum SortOrder {
|
|
@@ -13,7 +14,6 @@ export type SpreadsheetProps = {
|
|
|
13
14
|
initialDataSet: RecordDataSet;
|
|
14
15
|
isReadOnly?: boolean;
|
|
15
16
|
fields?: Field[];
|
|
16
|
-
highlightFirstRow?: boolean;
|
|
17
17
|
options?: SpreadsheetOptions;
|
|
18
18
|
onValidateRecord?: OnValidateRecord;
|
|
19
19
|
onDataSetChanged?: OnDataSetChanged;
|
|
@@ -21,4 +21,4 @@ export type SpreadsheetProps = {
|
|
|
21
21
|
selectedRows?: string[];
|
|
22
22
|
setSelectedRows?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
23
23
|
getSortCompareFn?: (sortBy: SortBy) => (a: Record, b: Record) => number;
|
|
24
|
-
};
|
|
24
|
+
} & DivCSSProps;
|
|
@@ -29,10 +29,13 @@ export var SortIndicator = styled(Div)(templateObject_3 || (templateObject_3 = _
|
|
|
29
29
|
}, function (p) { return p.theme.colors.gray300; });
|
|
30
30
|
export var FieldHeader = function (_a) {
|
|
31
31
|
var field = _a.field, sortByFieldErrors = _a.sortByFieldErrors, sortByFieldWarnings = _a.sortByFieldWarnings;
|
|
32
|
-
var _b = useSpreadsheetContext(), columnErrorCounts = _b.columnErrorCounts, columnWarningCounts = _b.columnWarningCounts, sortBy = _b.sortBy, filteredInputValue = _b.filteredInputValue, setSortBy = _b.setSortBy;
|
|
32
|
+
var _b = useSpreadsheetContext(), columnErrorCounts = _b.columnErrorCounts, columnWarningCounts = _b.columnWarningCounts, sortBy = _b.sortBy, spreadsheetFilter = _b.spreadsheetFilter, filteredInputValue = _b.filteredInputValue, setSortBy = _b.setSortBy;
|
|
33
33
|
var fieldErrorCount = columnErrorCounts[field.name];
|
|
34
34
|
var fieldWarningCount = columnWarningCounts[field.name];
|
|
35
|
-
var shouldRenderErrorCount = fieldErrorCount &&
|
|
35
|
+
var shouldRenderErrorCount = fieldErrorCount &&
|
|
36
|
+
filteredInputValue === "" &&
|
|
37
|
+
spreadsheetFilter.type === "rowBased" &&
|
|
38
|
+
spreadsheetFilter.byRow === "all";
|
|
36
39
|
var onHeaderClick = function () {
|
|
37
40
|
if ((sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === field.name && (sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction) === SortOrder.ASC) {
|
|
38
41
|
setSortBy({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { DivCSSProps } from "../../../../styled/utils";
|
|
3
|
+
declare const _default: React.MemoExoticComponent<(props: DivCSSProps) => JSX.Element>;
|
|
3
4
|
export default _default;
|