fuse-importer 0.25.4 → 0.25.5
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 +2 -2
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +2 -4
- package/lib/esm/Importer/Review/ReviewContextProvider.js +4 -14
- package/lib/esm/Importer/Review/ReviewWithContext.js +1 -1
- package/lib/esm/Importer/Uploader/HeadersPreview.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +8 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +10 -5
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +6 -3
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +79 -13
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +2 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +61 -0
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +8 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.js +10 -5
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +6 -2
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +0 -4
- package/lib/esm/Importer/data/index.d.ts +1 -0
- package/lib/esm/Importer/data/index.js +1 -1
- package/lib/esm/common/ConfirmationModal.d.ts +10 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +63 -0
- package/lib/esm/common/Table/TableActions/SearchRows.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +70 -0
- package/lib/esm/common/Table/TableActions/TableActions.d.ts +10 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +45 -0
- package/lib/esm/common/Table/TableActions/common.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/icons.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/icons.js +15 -0
- package/lib/esm/common/Table/TableActions/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableView/TableCells.js +5 -1
- package/lib/esm/common/Table/TableView/TableRow.d.ts +2 -1
- package/lib/esm/common/Table/TableView/TableRow.js +3 -3
- package/lib/esm/common/Table/TableView/index.d.ts +2 -1
- package/lib/esm/common/Table/TableView/index.js +5 -4
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/inputs/Checkbox.d.ts +3 -1
- package/lib/esm/common/inputs/Checkbox.js +15 -12
- package/lib/main.js +11 -11
- package/package.json +1 -1
|
@@ -47,8 +47,8 @@ var steps = [
|
|
|
47
47
|
];
|
|
48
48
|
export var Layout = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-rows: auto 1fr auto;\n height: 100vh;\n width: 100vw;\n overflow-y: scroll;\n position: fixed;\n top: 0;\n left: 0;\n z-index: ", ";\n ", ";\n"], ["\n display: grid;\n grid-template-rows: auto 1fr auto;\n height: 100vh;\n width: 100vw;\n overflow-y: scroll;\n position: fixed;\n top: 0;\n left: 0;\n z-index: ", ";\n ", ";\n"])), function (p) { return p.zIndex; }, function (p) { return p.theme.css.scrollbarDark; });
|
|
49
49
|
var Content = styled(Div)(function (_a) {
|
|
50
|
-
var
|
|
51
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n
|
|
50
|
+
var colors = _a.theme.colors;
|
|
51
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n "], ["\n background-color: ", ";\n "])), colors.backgroundInterface);
|
|
52
52
|
});
|
|
53
53
|
export var ImporterWithContext = function () {
|
|
54
54
|
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;
|
|
@@ -40,12 +40,10 @@ var HeaderMatcher = function () {
|
|
|
40
40
|
: MatcherStatus.unmatched,
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
var dataSortingOrderRef = useRef(templateHeaderLabels
|
|
44
|
-
.map(function (templateHeaderLabel, index) { return ({
|
|
43
|
+
var dataSortingOrderRef = useRef(templateHeaderLabels.map(function (templateHeaderLabel, index) { return ({
|
|
45
44
|
index: index,
|
|
46
45
|
isMatched: !!templateHeaderMatchings[templateHeaderLabel],
|
|
47
|
-
}); })
|
|
48
|
-
.sort(function (a, b) { return (b.isMatched ? 1 : -1); }));
|
|
46
|
+
}); }));
|
|
49
47
|
var sortedData = dataSortingOrderRef.current.map(function (sorting) { return data[sorting.index]; });
|
|
50
48
|
var tableRowHeight = 100;
|
|
51
49
|
var tableHeight = getTableHeight({
|
|
@@ -113,7 +113,6 @@ export var ReviewContextProvider = function (_a) {
|
|
|
113
113
|
var _d = useState(false), isSubmitting = _d[0], setIsSubmitting = _d[1];
|
|
114
114
|
var _e = useState(false), isSubmitDisabled = _e[0], setIsSubmitDisabled = _e[1];
|
|
115
115
|
var _f = useState(false), importWasSuccessful = _f[0], setImportWasSuccessful = _f[1];
|
|
116
|
-
var isDataInitialized = useRef(false);
|
|
117
116
|
var _g = useState(null), appResponse = _g[0], setAppResponse = _g[1];
|
|
118
117
|
var _h = useState([]), previewFields = _h[0], setPreviewFields = _h[1];
|
|
119
118
|
var _j = useState(null), previewInitialDataSet = _j[0], setPreviewInitialDataSet = _j[1];
|
|
@@ -129,10 +128,7 @@ export var ReviewContextProvider = function (_a) {
|
|
|
129
128
|
return;
|
|
130
129
|
var dataSet = reviewDataSetRef.current;
|
|
131
130
|
var dataSetValues = Object.values(dataSet);
|
|
132
|
-
var
|
|
133
|
-
return selectedRows.includes(index);
|
|
134
|
-
});
|
|
135
|
-
var csv = convertToCSV(selectedDataSetValues);
|
|
131
|
+
var csv = convertToCSV(dataSetValues);
|
|
136
132
|
var blob = new Blob([csv], { type: "text/csv" });
|
|
137
133
|
var url = URL.createObjectURL(blob);
|
|
138
134
|
var link = document.createElement("a");
|
|
@@ -141,7 +137,7 @@ export var ReviewContextProvider = function (_a) {
|
|
|
141
137
|
link.click();
|
|
142
138
|
}, [reviewFields, selectedRows]);
|
|
143
139
|
var onSubmitData = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
-
var dataSet, dataSetValues,
|
|
140
|
+
var dataSet, dataSetValues, validDataSetValues, validDataSetLength, invalidRecords, applicationResponse, isAppResponseSuccessful, _a, errors, isDataValid, invalidDataSet, error_2;
|
|
145
141
|
return __generator(this, function (_b) {
|
|
146
142
|
switch (_b.label) {
|
|
147
143
|
case 0:
|
|
@@ -151,10 +147,7 @@ export var ReviewContextProvider = function (_a) {
|
|
|
151
147
|
setIsSubmitting(true);
|
|
152
148
|
dataSet = reviewDataSetRef.current;
|
|
153
149
|
dataSetValues = Object.values(dataSet);
|
|
154
|
-
|
|
155
|
-
return selectedRows.includes(index);
|
|
156
|
-
});
|
|
157
|
-
validDataSetValues = selectedDataSetValues.filter(function (record) {
|
|
150
|
+
validDataSetValues = dataSetValues.filter(function (record) {
|
|
158
151
|
return !record._meta.isInvalid && !isRecordEmpty(record, reviewFields);
|
|
159
152
|
});
|
|
160
153
|
validDataSetLength = validDataSetValues.length;
|
|
@@ -210,7 +203,6 @@ export var ReviewContextProvider = function (_a) {
|
|
|
210
203
|
setReviewFields([]);
|
|
211
204
|
setReviewInitialDataSet(null);
|
|
212
205
|
reviewDataSetRef.current = null;
|
|
213
|
-
isDataInitialized.current = false;
|
|
214
206
|
return;
|
|
215
207
|
}
|
|
216
208
|
if (currentStepIndex === 0) {
|
|
@@ -218,9 +210,8 @@ export var ReviewContextProvider = function (_a) {
|
|
|
218
210
|
var _a = getPreviewDataSet({ uploadedData: uploadedData }), fields = _a.fields, initialDataSet = _a.initialDataSet;
|
|
219
211
|
setPreviewFields(fields);
|
|
220
212
|
setPreviewInitialDataSet(initialDataSet);
|
|
221
|
-
isDataInitialized.current = false;
|
|
222
213
|
}
|
|
223
|
-
else if (currentStepIndex === 2
|
|
214
|
+
else if (currentStepIndex === 2) {
|
|
224
215
|
//Review spreadsheet data
|
|
225
216
|
var _b = getReviewDataSet({
|
|
226
217
|
enumFieldValueMatchings: enumFieldValueMatchings,
|
|
@@ -232,7 +223,6 @@ export var ReviewContextProvider = function (_a) {
|
|
|
232
223
|
}), fields = _b.fields, initialDataSet = _b.initialDataSet;
|
|
233
224
|
setReviewFields(fields);
|
|
234
225
|
setReviewInitialDataSet(initialDataSet);
|
|
235
|
-
isDataInitialized.current = true;
|
|
236
226
|
}
|
|
237
227
|
}, [
|
|
238
228
|
uploadedData,
|
|
@@ -32,7 +32,7 @@ var ReviewWithContext = function () {
|
|
|
32
32
|
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows;
|
|
33
33
|
var t = useTranslation("review").t;
|
|
34
34
|
var spreadsheetUI = initialDataSet && (_jsx(Spreadsheet, { options: __assign(__assign({}, options), { showCheckboxColumn: true }), selectedRows: selectedRows, setSelectedRows: setSelectedRows, initialDataSet: initialDataSet, fields: fields, rowWidth: getSpreadsheetRowWidth(fields, 6), onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged }));
|
|
35
|
-
return (_jsxs(Div, __assign({ centered: true, flexColumn: true }, { children: [_jsx(AppResponseModal, {}), _jsxs(Div, __assign({
|
|
35
|
+
return (_jsxs(Div, __assign({ centered: true, flexColumn: true, h100: true }, { children: [_jsx(AppResponseModal, {}), _jsxs(Div, __assign({ w100: true, h100: true }, { children: [_jsxs(TitleContainer, __assign({ centered: true, textAlignCenter: true, flexColumn: true }, { children: [_jsx(Div, __assign({ h2: true, mt: 40 }, { children: t("title") })), _jsx(ExportButtonContainer, __assign({ mb: 16, mt: 64 }, { children: _jsxs(Button, __assign({ w: 120, br: 8, variant: "secondary", svgNormalFillColorOverride: "transparent", svgActiveFillColorOverride: "transparent", svgActiveStrokeColorOverride: "white", onClick: onExport }, { children: [downloadIcon, " ", _jsxs(Span, __assign({ ml: 6 }, { children: [" ", t("export")] }))] })) }))] })), _jsx(Div, __assign({ centered: true, textAlignCenter: true, flexColumn: true }, { children: _jsx(Div, __assign({ body1: true, mt: 20, w: 540, mb: 15 }, { children: t("description") })) })), spreadsheetUI] }))] })));
|
|
36
36
|
};
|
|
37
37
|
export default ReviewWithContext;
|
|
38
38
|
var templateObject_1, templateObject_2;
|
|
@@ -21,7 +21,7 @@ var HeadersPreview = function () {
|
|
|
21
21
|
var _a = useReviewContext(), fields = _a.previewFields, initialDataSet = _a.previewInitialDataSet;
|
|
22
22
|
var t = useTranslation("upload").t;
|
|
23
23
|
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows;
|
|
24
|
-
return (_jsxs(Div, __assign({ flexColumn: true, centered: true, pt: 40 }, { children: [_jsx(Div, __assign({ h2: true, mb: 16 }, { children: t("headers_preview.title") })), _jsx(Div, __assign({ body1: true, mb: 24, textAlignCenter: true }, { children: t("headers_preview.description") })), _jsx(HeaderButtons, {}), _jsx(Div, __assign({ w100: true,
|
|
24
|
+
return (_jsxs(Div, __assign({ flexColumn: true, centered: true, pt: 40, h100: true }, { children: [_jsx(Div, __assign({ h2: true, mb: 16 }, { children: t("headers_preview.title") })), _jsx(Div, __assign({ body1: true, mb: 24, textAlignCenter: true }, { children: t("headers_preview.description") })), _jsx(HeaderButtons, {}), _jsx(Div, __assign({ w100: true, h100: true }, { children: initialDataSet && (_jsx(Spreadsheet, { rowWidth: getSpreadsheetRowWidth(fields, 6), isReadOnly: true, initialDataSet: initialDataSet, fields: fields, highlightFirstRow: true, options: {
|
|
25
25
|
showCheckboxColumn: true,
|
|
26
26
|
firstRowIsHeader: true,
|
|
27
27
|
}, selectedRows: selectedRows, setSelectedRows: setSelectedRows })) }))] })));
|
|
@@ -17,9 +17,13 @@ type State = {
|
|
|
17
17
|
updateRecord: (record: Record) => void;
|
|
18
18
|
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
19
19
|
setSortByFieldErrors: React.Dispatch<React.SetStateAction<string>>;
|
|
20
|
-
selectedRows:
|
|
21
|
-
setSelectedRows: React.Dispatch<React.SetStateAction<
|
|
20
|
+
selectedRows: string[];
|
|
21
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
22
22
|
setSortByFieldWarnings: React.Dispatch<React.SetStateAction<string>>;
|
|
23
|
+
deleteRecords: (selectedRecords: string[]) => void;
|
|
24
|
+
lastClickedIndexRef: React.MutableRefObject<number | null>;
|
|
25
|
+
filteredInputValue: string;
|
|
26
|
+
setFilteredInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
23
27
|
} & ValidationState;
|
|
24
28
|
type Props = {
|
|
25
29
|
initialDataSet: RecordDataSet;
|
|
@@ -32,8 +36,8 @@ type Props = {
|
|
|
32
36
|
onValidationStateChanged?: OnValidationStateChanged;
|
|
33
37
|
onValidateRecord?: OnValidateRecord;
|
|
34
38
|
onDataSetChanged?: OnDataSetChanged;
|
|
35
|
-
selectedRows:
|
|
36
|
-
setSelectedRows: React.Dispatch<React.SetStateAction<
|
|
39
|
+
selectedRows: string[];
|
|
40
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
37
41
|
};
|
|
38
42
|
export declare const SpreadsheetContextProvider: ({ initialDataSet, rowWidth, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: Props) => JSX.Element;
|
|
39
43
|
export declare const useSpreadsheetContext: () => State;
|
|
@@ -24,6 +24,7 @@ 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
26
|
import { useValidationState } from "./hooks";
|
|
27
|
+
import { addEmptyRows } from "../../../Importer/data";
|
|
27
28
|
var SpreadsheetContext = createContext({});
|
|
28
29
|
export var SpreadsheetContextProvider = function (_a) {
|
|
29
30
|
var initialDataSet = _a.initialDataSet, _b = _a.rowWidth, rowWidth = _b === void 0 ? 1 : _b, fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly, highlightFirstRow = _a.highlightFirstRow, children = _a.children, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows;
|
|
@@ -31,9 +32,10 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
31
32
|
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
32
33
|
var _e = useState(null), sortByFieldErrors = _e[0], setSortByFieldErrors = _e[1];
|
|
33
34
|
var _f = useState(null), sortByFieldWarnings = _f[0], setSortByFieldWarnings = _f[1];
|
|
35
|
+
var _g = useState(""), filteredInputValue = _g[0], setFilteredInputValue = _g[1];
|
|
34
36
|
var sortByCurrentErrorsRef = useRef({});
|
|
35
37
|
var sortByCurrentWarningsRef = useRef({});
|
|
36
|
-
var
|
|
38
|
+
var _h = useValidationState({
|
|
37
39
|
dataSet: dataSet,
|
|
38
40
|
initialDataSet: initialDataSet,
|
|
39
41
|
fields: fields,
|
|
@@ -42,12 +44,13 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
42
44
|
setDataSet: setDataSet,
|
|
43
45
|
setIsLoading: setIsLoading,
|
|
44
46
|
onValidateRecord: onValidateRecord,
|
|
45
|
-
}), errorsRef =
|
|
47
|
+
}), errorsRef = _h.errorsRef, warningsRef = _h.warningsRef, updateRecordAndRevalidate = _h.updateRecordAndRevalidate, deleteRecords = _h.deleteRecords, filterRecordsBySearchValue = _h.filterRecordsBySearchValue, validationState = __rest(_h, ["errorsRef", "warningsRef", "updateRecordAndRevalidate", "deleteRecords", "filterRecordsBySearchValue"]);
|
|
46
48
|
// sort data based on errors (errors group on top and not errors group at bottom)
|
|
47
49
|
var data = useMemo(function () {
|
|
50
|
+
var filteredObj = filterRecordsBySearchValue(dataSet, filteredInputValue);
|
|
51
|
+
var dataSetValues = Object.values(filteredInputValue ? filteredObj : dataSet);
|
|
48
52
|
var errors = sortByCurrentErrorsRef.current; //Sort errors snapshot
|
|
49
53
|
var warnings = sortByCurrentWarningsRef.current; //Sort warnings snapshot
|
|
50
|
-
var dataSetValues = Object.values(dataSet);
|
|
51
54
|
if (!sortByFieldErrors && !sortByFieldWarnings)
|
|
52
55
|
return dataSetValues;
|
|
53
56
|
return dataSetValues.sort(function (a, b) {
|
|
@@ -58,7 +61,8 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
58
61
|
}
|
|
59
62
|
return bHasErrors ? 1 : -1;
|
|
60
63
|
});
|
|
61
|
-
}, [dataSet, sortByFieldErrors, sortByFieldWarnings]);
|
|
64
|
+
}, [dataSet, filteredInputValue, sortByFieldErrors, sortByFieldWarnings]);
|
|
65
|
+
addEmptyRows(data, fields);
|
|
62
66
|
useEffect(function () {
|
|
63
67
|
onDataSetChanged && onDataSetChanged(dataSet);
|
|
64
68
|
}, [dataSet]);
|
|
@@ -80,7 +84,8 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
80
84
|
setSortByFieldWarnings(value);
|
|
81
85
|
setSortByFieldErrors(null);
|
|
82
86
|
}, []);
|
|
83
|
-
var
|
|
87
|
+
var lastClickedIndexRef = useRef(null);
|
|
88
|
+
var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, rowWidth: rowWidth, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, highlightFirstRow: highlightFirstRow, options: options, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: deleteRecords, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef });
|
|
84
89
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
85
90
|
};
|
|
86
91
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
|
@@ -31,12 +31,15 @@ import * as S from "../styles";
|
|
|
31
31
|
import { FieldHeader } from "./FieldHeader";
|
|
32
32
|
import GlobalStyle from "./GlobalStyle";
|
|
33
33
|
import { inputTypes } from "./inputs";
|
|
34
|
-
import { SpreadsheetRowNumbers } from "./SpreadsheetRowNumbers";
|
|
35
34
|
import { SpreadsheetRowCheckboxes } from "./SpreadsheetRowCheckboxes";
|
|
36
35
|
import ValidationProgress from "./ValidationProgress";
|
|
36
|
+
import { TableActions } from "../../../../common/Table/TableActions";
|
|
37
|
+
import { useImporterContext } from "../../../../Importer/contexts/ImporterContextProvider";
|
|
37
38
|
var getItemKey = function (record) { return record._meta.id; };
|
|
38
39
|
var SpreadsheetData = function () {
|
|
39
|
-
var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, rowWidth = _a.rowWidth, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options, setSortByFieldWarnings = _a.setSortByFieldWarnings;
|
|
40
|
+
var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, rowWidth = _a.rowWidth, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options, setSortByFieldWarnings = _a.setSortByFieldWarnings, selectedRows = _a.selectedRows;
|
|
41
|
+
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
42
|
+
var canShowCheckboxOnCheckboxRowHover = currentStepIndex === 2;
|
|
40
43
|
var rowNumbersGridRef = useRef();
|
|
41
44
|
var rowCheckboxesGridRef = useRef();
|
|
42
45
|
var sortByErrors = useCallback(function (field) {
|
|
@@ -80,6 +83,6 @@ var SpreadsheetData = function () {
|
|
|
80
83
|
});
|
|
81
84
|
}, [dataLength]);
|
|
82
85
|
var showValidationProgress = !isReadOnly && validationPercentage < 100;
|
|
83
|
-
return (_jsxs(S.SpreadSheetData, { children: [_jsx(GlobalStyle, {}), _jsx(Div, __assign({ h: 32 }, { children: showValidationProgress && (_jsx(ValidationProgress, { totalErrors: totalErrors, validationPercentage: validationPercentage })) })), _jsxs(S.
|
|
86
|
+
return (_jsxs(S.SpreadSheetData, __assign({ h100: true, flexColumn: true }, { children: [_jsx(GlobalStyle, {}), _jsx(Div, __assign({ h: 32 }, { children: showValidationProgress && (_jsx(ValidationProgress, { totalErrors: totalErrors, validationPercentage: validationPercentage })) })), _jsxs(S.SpreadSheetContainer, __assign({ flexColumn: true, w100: true, h100: true }, { children: [currentStepIndex === 2 && _jsx(TableActions, {}), _jsxs(S.SpreadSheetWrapper, __assign({ canShowCheckboxOnHover: !showValidationProgress && canShowCheckboxOnCheckboxRowHover, shouldShowOnlyCheckbox: !showValidationProgress && selectedRows.length > 0, dflex: true, h100: true }, { children: [(options === null || options === void 0 ? void 0 : options.showCheckboxColumn) && (_jsx(SpreadsheetRowCheckboxes, { gridRef: rowCheckboxesGridRef, spreadsheetHasXScroll: rowWidth > 1, height: spreadsheetHeight, firstRowIsHeader: options === null || options === void 0 ? void 0 : options.firstRowIsHeader, isLoadingData: showValidationProgress })), _jsx(S.TableView, { tableHeadersHeight: spreadsheetHeaderHeightPx, highlightFirstRow: isReadOnly, rowHeight: spreadsheetRowHeightPx, h: spreadsheetHeight, rowWidth: rowWidth, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey, isInsideImporter: true })] }))] }))] })));
|
|
84
87
|
};
|
|
85
88
|
export default React.memo(SpreadsheetData, areEqual);
|
|
@@ -5,6 +5,7 @@ type Props = {
|
|
|
5
5
|
spreadsheetHasXScroll?: boolean;
|
|
6
6
|
gridRef: React.MutableRefObject<any>;
|
|
7
7
|
firstRowIsHeader?: boolean;
|
|
8
|
+
isLoadingData?: boolean;
|
|
8
9
|
} & DivCSSProps;
|
|
9
|
-
export declare const SpreadsheetRowCheckboxes: ({ height, spreadsheetHasXScroll, gridRef, firstRowIsHeader, ...props }: Props) => JSX.Element;
|
|
10
|
+
export declare const SpreadsheetRowCheckboxes: ({ height, spreadsheetHasXScroll, gridRef, firstRowIsHeader, isLoadingData, ...props }: Props) => JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -42,7 +42,9 @@ import { spreadsheetRowHeightPx } from "../common";
|
|
|
42
42
|
import { spreadsheetHeaderHeightPx } from "../common/index";
|
|
43
43
|
import { useSpreadsheetContext } from "../SpreadsheetContextProvider";
|
|
44
44
|
import { Checkbox } from "../../../../common/inputs/Checkbox";
|
|
45
|
-
|
|
45
|
+
import { useImporterContext } from "../../../contexts/ImporterContextProvider";
|
|
46
|
+
import ReactVirtualizedAutoSizer from "react-virtualized-auto-sizer";
|
|
47
|
+
var StyledGrid = styled(Grid)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n\n -ms-overflow-style: none;\n overflow: -moz-scrollbars-none;\n scrollbar-width: none;\n"], ["\n ::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n\n -ms-overflow-style: none;\n overflow: -moz-scrollbars-none;\n scrollbar-width: none;\n"])));
|
|
46
48
|
var gridStyles = {
|
|
47
49
|
outline: "none",
|
|
48
50
|
willChange: "unset",
|
|
@@ -57,12 +59,19 @@ var rowIsEmpty = function (row) {
|
|
|
57
59
|
});
|
|
58
60
|
};
|
|
59
61
|
export var SpreadsheetRowCheckboxes = function (_a) {
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
+
var _b, _c, _d, _e;
|
|
63
|
+
var height = _a.height, spreadsheetHasXScroll = _a.spreadsheetHasXScroll, gridRef = _a.gridRef, _f = _a.firstRowIsHeader, firstRowIsHeader = _f === void 0 ? false : _f, isLoadingData = _a.isLoadingData, props = __rest(_a, ["height", "spreadsheetHasXScroll", "gridRef", "firstRowIsHeader", "isLoadingData"]);
|
|
64
|
+
var _g = useSpreadsheetContext(), data = _g.data, selectedRows = _g.selectedRows, lastClickedIndexRef = _g.lastClickedIndexRef, setSelectedRows = _g.setSelectedRows;
|
|
65
|
+
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
62
66
|
var nonEmptyRows = useMemo(function () { return data.filter(function (row) { return !rowIsEmpty(row); }); }, [
|
|
63
67
|
data,
|
|
64
68
|
]);
|
|
65
69
|
var isIndeterminate = selectedRows.length > 0 && selectedRows.length < nonEmptyRows.length;
|
|
70
|
+
var lastRowIndexLength = (_e = (_d = (_c = (_b = data[data.length - 1]) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.rowIndex) === null || _d === void 0 ? void 0 : _d.toString()) === null || _e === void 0 ? void 0 : _e.length;
|
|
71
|
+
var singleLetterWidth = 15;
|
|
72
|
+
var horizontalSpacing = 8;
|
|
73
|
+
var baseColumnWidth = lastRowIndexLength * singleLetterWidth + horizontalSpacing;
|
|
74
|
+
var columnWidth = baseColumnWidth < 40 ? 40 : baseColumnWidth;
|
|
66
75
|
var handleRowSelect = function (checked, rowIndex) {
|
|
67
76
|
if (checked && rowIsEmpty(data[rowIndex])) {
|
|
68
77
|
return;
|
|
@@ -74,33 +83,90 @@ export var SpreadsheetRowCheckboxes = function (_a) {
|
|
|
74
83
|
// If the first row is a header, we need to adjust the rowIndex
|
|
75
84
|
var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
|
|
76
85
|
if (checked) {
|
|
77
|
-
setSelectedRows(function (prev) { return __spreadArray(__spreadArray([], prev, true), [adjustedRowIndex], false); });
|
|
86
|
+
setSelectedRows(function (prev) { var _a, _b; return __spreadArray(__spreadArray([], prev, true), [(_b = (_a = data[adjustedRowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id], false); });
|
|
78
87
|
}
|
|
79
88
|
else {
|
|
80
|
-
setSelectedRows(function (prev) {
|
|
89
|
+
setSelectedRows(function (prev) {
|
|
90
|
+
return prev.filter(function (row) { var _a, _b; return row !== ((_b = (_a = data[adjustedRowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id); });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
lastClickedIndexRef.current = rowIndex;
|
|
94
|
+
};
|
|
95
|
+
var handleSelectMultipleRows = function (rowIndex) {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
var clickedRowId = (_b = (_a = data[rowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id;
|
|
98
|
+
if (selectedRows.includes(clickedRowId)) {
|
|
99
|
+
// The clicked row is already selected, so we have to remove it
|
|
100
|
+
var clickedRowIndex = selectedRows.indexOf(clickedRowId);
|
|
101
|
+
var lastClickedIndex = lastClickedIndexRef.current;
|
|
102
|
+
var rangeStartIndex_1 = Math.min(clickedRowIndex, lastClickedIndex);
|
|
103
|
+
var rangeEndIndex_1 = Math.max(clickedRowIndex, lastClickedIndex);
|
|
104
|
+
var updatedSelectedRows = selectedRows.filter(function (_, index) { return index < rangeStartIndex_1 || index > rangeEndIndex_1; });
|
|
105
|
+
setSelectedRows(updatedSelectedRows);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// The clicked row is not selected, so we have to add it
|
|
109
|
+
var lastSelectedRowIndex = selectedRows.length - 1;
|
|
110
|
+
var lastSelectedRowId_1 = selectedRows[lastSelectedRowIndex];
|
|
111
|
+
var lastSelectedRow = data.find(function (row) { var _a; return ((_a = row === null || row === void 0 ? void 0 : row._meta) === null || _a === void 0 ? void 0 : _a.id) === lastSelectedRowId_1; });
|
|
112
|
+
var clickedRow = data[rowIndex];
|
|
113
|
+
var rangeStartIndex = data.indexOf(lastSelectedRow);
|
|
114
|
+
var rangeEndIndex = data.indexOf(clickedRow);
|
|
115
|
+
var range = data.slice(Math.min(rangeStartIndex, rangeEndIndex), Math.max(rangeStartIndex, rangeEndIndex) + 1);
|
|
116
|
+
var rangeIds = range.map(function (row) { return row === null || row === void 0 ? void 0 : row._meta.id; });
|
|
117
|
+
var updatedSelectedRows = __spreadArray(__spreadArray([], selectedRows, true), rangeIds, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
|
|
118
|
+
setSelectedRows(updatedSelectedRows);
|
|
119
|
+
lastClickedIndexRef.current = rowIndex;
|
|
81
120
|
}
|
|
82
121
|
};
|
|
83
122
|
var handleSelectAllRows = function (checked) {
|
|
84
123
|
if (checked) {
|
|
85
124
|
var allRows = data
|
|
86
125
|
.filter(function (row) { return !rowIsEmpty(row); })
|
|
87
|
-
.map(function (
|
|
126
|
+
.map(function (row) {
|
|
127
|
+
return row === null || row === void 0 ? void 0 : row._meta.id;
|
|
128
|
+
});
|
|
88
129
|
setSelectedRows(allRows);
|
|
89
130
|
}
|
|
90
131
|
else {
|
|
91
132
|
setSelectedRows([]);
|
|
92
133
|
}
|
|
134
|
+
lastClickedIndexRef.current = null;
|
|
135
|
+
};
|
|
136
|
+
var CheckboxCell = function (_a) {
|
|
137
|
+
var _b, _c;
|
|
138
|
+
var rowIndex = _a.rowIndex, adjustedRowIndex = _a.adjustedRowIndex;
|
|
139
|
+
var currentDataIndex = rowIndex === 0 ? 0 : adjustedRowIndex;
|
|
140
|
+
var rowMetaId = (_c = (_b = data[currentDataIndex]) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.id;
|
|
141
|
+
return (_jsx(Div, __assign({ className: "checkbox-cell" }, { children: firstRowIsHeader && rowIndex === 0 ? ("") : (_jsx(Checkbox, { isChecked: rowMetaId && selectedRows.includes(rowMetaId), onChange: function (checked) {
|
|
142
|
+
return !isLoadingData && handleRowSelect(checked, rowIndex);
|
|
143
|
+
}, onShiftKeyPressed: function () { return handleSelectMultipleRows(rowIndex); }, style: { cursor: "pointer" }, isDisabled: isLoadingData })) })));
|
|
144
|
+
};
|
|
145
|
+
var RowNumbersCell = function (_a) {
|
|
146
|
+
var rowIndex = _a.rowIndex;
|
|
147
|
+
return (_jsx(Div, __assign({ className: "row-numbers-cell", textAlignCenter: true, body2: true }, { children: rowIndex + 1 })));
|
|
93
148
|
};
|
|
94
149
|
var Cell = function (_a) {
|
|
95
150
|
var rowIndex = _a.rowIndex, style = _a.style;
|
|
96
151
|
var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
|
|
97
|
-
return (
|
|
152
|
+
return (_jsxs(RowCheckbox, __assign({ style: style, alignCenter: true, justifyCenter: true, isLast: adjustedRowIndex === data.length - 1 }, { children: [_jsx(CheckboxCell, { rowIndex: rowIndex, adjustedRowIndex: adjustedRowIndex }), _jsx(RowNumbersCell, { rowIndex: rowIndex })] }), adjustedRowIndex));
|
|
98
153
|
};
|
|
99
|
-
|
|
154
|
+
var isSelectAllRowsChekboxChecked = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) > 0 &&
|
|
155
|
+
(data === null || data === void 0 ? void 0 : data.length) > 0 &&
|
|
156
|
+
(selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) >= (nonEmptyRows === null || nonEmptyRows === void 0 ? void 0 : nonEmptyRows.length);
|
|
157
|
+
return (_jsxs(SpreadsheetRowCheckboxesContainer, __assign({ className: "spreadsheet-row-container", columnWidth: columnWidth }, props, { h100: true }, { children: [_jsx(SpreadsheetRowCheckboxesHeader, { children: currentStepIndex === 2 && (_jsx(Checkbox, { isChecked: isSelectAllRowsChekboxChecked, onChange: function (checked) {
|
|
158
|
+
return !isLoadingData && handleSelectAllRows(checked);
|
|
159
|
+
}, isIndeterminate: isIndeterminate, isDisabled: isLoadingData })) }), _jsx(ReactVirtualizedAutoSizer, { children: function (_a) {
|
|
160
|
+
var height = _a.height;
|
|
161
|
+
return (_jsx(StyledGrid, __assign({ ref: gridRef, style: gridStyles, width: columnWidth, columnCount: 1, columnWidth: columnWidth, rowHeight: 40, rowCount: data.length, height: height - spreadsheetHeaderHeightPx }, { children: Cell })));
|
|
162
|
+
} })] })));
|
|
100
163
|
};
|
|
101
|
-
var RowCheckbox = styled(Div)(
|
|
102
|
-
return !p.isLast && css(
|
|
164
|
+
var RowCheckbox = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n ", ";\n ", "\n display: flex;\n justify-content: center;\n position: relative;\n user-select: none;\n\n .checkbox-cell {\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n visibility: hidden;\n z-index: 1;\n }\n\n .row-numbers-cell {\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n"], ["\n background-color: ", ";\n ", ";\n ", "\n display: flex;\n justify-content: center;\n position: relative;\n user-select: none;\n\n .checkbox-cell {\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n visibility: hidden;\n z-index: 1;\n }\n\n .row-numbers-cell {\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n"])), function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.css.label3; }, function (p) {
|
|
165
|
+
return !p.isLast && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: inset 0 -1px 0 ", ";\n "], ["\n box-shadow: inset 0 -1px 0 ", ";\n "])), function (p) { return p.theme.colors.gray300; });
|
|
103
166
|
});
|
|
104
|
-
var SpreadsheetRowCheckboxesHeader = styled(Div)(
|
|
105
|
-
var SpreadsheetRowCheckboxesContainer = styled(Div)(
|
|
106
|
-
var
|
|
167
|
+
var SpreadsheetRowCheckboxesHeader = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n height: ", "px;\n border-top-left-radius: 8px;\n background-color: ", ";\n box-shadow: inset 0 -1px 0 ", ";\n display: flex;\n justify-content: center;\n"], ["\n align-items: center;\n height: ", "px;\n border-top-left-radius: 8px;\n background-color: ", ";\n box-shadow: inset 0 -1px 0 ", ";\n display: flex;\n justify-content: center;\n"])), spreadsheetRowHeightPx, function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.colors.gray300; });
|
|
168
|
+
var SpreadsheetRowCheckboxesContainer = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-right: solid 1px ", ";\n border-top-left-radius: 8px;\n width: ", "px;\n\n .ReactVirtualized__Grid {\n /* Scrollbar */\n ::-webkit-scrollbar {\n width: 8px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background-color: ", " !important;\n }\n }\n"], ["\n border-right: solid 1px ", ";\n border-top-left-radius: 8px;\n width: ", "px;\n\n .ReactVirtualized__Grid {\n /* Scrollbar */\n ::-webkit-scrollbar {\n width: 8px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background-color: ", " !important;\n }\n }\n"])), function (p) { return p.theme.colors.gray300; }, function (_a) {
|
|
169
|
+
var columnWidth = _a.columnWidth;
|
|
170
|
+
return columnWidth || 40;
|
|
171
|
+
}, function (p) { return p.theme.colors.tableHeader; });
|
|
172
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -31,7 +31,7 @@ import { Div } from "../../../../styled/utils";
|
|
|
31
31
|
import { spreadsheetRowHeightPx } from "../common";
|
|
32
32
|
import { spreadsheetHeaderHeightPx } from "../common/index";
|
|
33
33
|
import { useSpreadsheetContext } from "../SpreadsheetContextProvider";
|
|
34
|
-
var SPREADSHEET_ROW_NUMBERS_WIDTH =
|
|
34
|
+
var SPREADSHEET_ROW_NUMBERS_WIDTH = 36;
|
|
35
35
|
var gridStyles = {
|
|
36
36
|
outline: "none",
|
|
37
37
|
willChange: "unset",
|
|
@@ -43,7 +43,7 @@ export var SpreadsheetRowNumbers = function (_a) {
|
|
|
43
43
|
var data = useSpreadsheetContext().data;
|
|
44
44
|
var Cell = function (_a) {
|
|
45
45
|
var rowIndex = _a.rowIndex, style = _a.style;
|
|
46
|
-
return (_jsx(RowNumber, __assign({ style: style, alignCenter: true,
|
|
46
|
+
return (_jsx(RowNumber, __assign({ style: style, alignCenter: true, justifyCenter: true, isLast: rowIndex === data.length - 1 }, { children: _jsx(Div, __assign({ truncateText: true, textAlignCenter: true, body2: true }, { children: rowIndex + 1 })) }), rowIndex));
|
|
47
47
|
};
|
|
48
48
|
return (_jsxs(SpreadsheetRowNumbersContainer, __assign({}, props, { h: height }, { children: [_jsx(SpreadsheetRowNumbersHeader, {}), _jsx(Grid, __assign({ ref: gridRef, style: gridStyles, width: SPREADSHEET_ROW_NUMBERS_WIDTH, columnCount: 1, columnWidth: SPREADSHEET_ROW_NUMBERS_WIDTH, height: height - spreadsheetHeaderHeightPx, rowHeight: 40, rowCount: data.length }, { children: Cell }))] })));
|
|
49
49
|
};
|
|
@@ -91,6 +91,6 @@ var Wrapper = styled(Div)(function (_a) {
|
|
|
91
91
|
export var SpreadsheetField = function (_a) {
|
|
92
92
|
var validationError = _a.validationError, validationWarning = _a.validationWarning, children = _a.children;
|
|
93
93
|
var _b = useSpreadsheetContext(), isReadOnly = _b.isReadOnly, isLoading = _b.isLoading;
|
|
94
|
-
return (_jsx(Wrapper, __assign({ dim: "100%", isLoading: isLoading }, { children: _jsx(TooltipProvider, __assign({ tooltip: validationError || validationWarning }, { children: _jsx(Div, __assign({ dim: "100%" }, { children: _jsx(ContentContainer, __assign({ hasError: !!validationError, hasWarning: !!validationWarning, isReadOnly: isReadOnly }, { children: children })) })) })) })));
|
|
94
|
+
return (_jsx(Wrapper, __assign({ dim: "100%", isLoading: isLoading }, { children: _jsx(TooltipProvider, __assign({ tooltip: validationError || validationWarning }, { children: _jsx(Div, __assign({ dim: "100%" }, { children: _jsx(ContentContainer, __assign({ hasError: !!validationError, hasWarning: !!validationWarning, isReadOnly: isReadOnly, className: "input-content" }, { children: children })) })) })) })));
|
|
95
95
|
};
|
|
96
96
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -26,6 +26,8 @@ export type ValidationState = {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
type UseValidationStateReturnValue = ValidationState & {
|
|
29
|
+
deleteRecords: (selectedRecords: string[]) => void;
|
|
30
|
+
filterRecordsBySearchValue: (obj: RecordDataSet, value: string) => RecordDataSet;
|
|
29
31
|
updateRecordAndRevalidate: (record: Record) => Promise<void>;
|
|
30
32
|
errorsRef: React.MutableRefObject<BatchValidationErrors>;
|
|
31
33
|
warningsRef: React.MutableRefObject<BatchValidationErrors>;
|
|
@@ -52,6 +52,40 @@ import { selectValidatorsFor, validateRecord } from "./validation";
|
|
|
52
52
|
var checkIfHasErrors = function (errors) {
|
|
53
53
|
return errors && Object.keys(errors).length > 0;
|
|
54
54
|
};
|
|
55
|
+
var removeItemsFromObject = function (obj, idsToRemove) {
|
|
56
|
+
var _a;
|
|
57
|
+
var idSet = new Set(idsToRemove);
|
|
58
|
+
var newObj = {};
|
|
59
|
+
for (var key in obj) {
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
+
var meta = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta;
|
|
62
|
+
if (meta && (meta === null || meta === void 0 ? void 0 : meta.id) && !(idSet === null || idSet === void 0 ? void 0 : idSet.has(meta === null || meta === void 0 ? void 0 : meta.id))) {
|
|
63
|
+
newObj[key] = obj[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return newObj;
|
|
68
|
+
};
|
|
69
|
+
var removeErrorsOrWarningsFromObject = function (obj, keysToRemove) {
|
|
70
|
+
var keysSet = new Set(keysToRemove);
|
|
71
|
+
var newObj = {};
|
|
72
|
+
for (var key in obj) {
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(obj, key) && !(keysSet === null || keysSet === void 0 ? void 0 : keysSet.has(key))) {
|
|
74
|
+
newObj[key] = obj[key];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return newObj;
|
|
78
|
+
};
|
|
79
|
+
var isObject = function (value) {
|
|
80
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
81
|
+
};
|
|
82
|
+
var includesSearchValue = function (value, searchValue) {
|
|
83
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
84
|
+
var stringValue = String(value);
|
|
85
|
+
return stringValue.includes(searchValue);
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
55
89
|
export var useValidationState = function (_a) {
|
|
56
90
|
var initialDataSet = _a.initialDataSet, //Initial Data Set, used to run the initial validation
|
|
57
91
|
dataSet = _a.dataSet, //Current Updated Data Set
|
|
@@ -62,6 +96,31 @@ export var useValidationState = function (_a) {
|
|
|
62
96
|
var validatorsCache = useMemo(function () { return selectValidatorsFor(fields); }, [fields]);
|
|
63
97
|
var errorsRef = useRef(errors);
|
|
64
98
|
var warningsRef = useRef(warnings);
|
|
99
|
+
//Delete record from dataSet and from validations
|
|
100
|
+
var deleteRecords = function (selectedRecords) {
|
|
101
|
+
var newDataSet = removeItemsFromObject(dataSet, selectedRecords);
|
|
102
|
+
var newErrors = removeErrorsOrWarningsFromObject(errors, selectedRecords);
|
|
103
|
+
var newWarnings = removeErrorsOrWarningsFromObject(warnings, selectedRecords);
|
|
104
|
+
setDataSet(newDataSet);
|
|
105
|
+
setErrors(newErrors);
|
|
106
|
+
setWarnings(newWarnings);
|
|
107
|
+
};
|
|
108
|
+
//Filter records by search value
|
|
109
|
+
var filterRecordsBySearchValue = function (obj, value) {
|
|
110
|
+
var filteredObj = {};
|
|
111
|
+
for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
|
|
112
|
+
var _b = _a[_i], key = _b[0], currentObj = _b[1];
|
|
113
|
+
if (isObject(currentObj)) {
|
|
114
|
+
var matches = Object.values(currentObj).some(function (propertyValue) {
|
|
115
|
+
return includesSearchValue(propertyValue, value);
|
|
116
|
+
});
|
|
117
|
+
if (matches) {
|
|
118
|
+
filteredObj[key] = currentObj;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return filteredObj;
|
|
123
|
+
};
|
|
65
124
|
//Validate record and update dataSet
|
|
66
125
|
var updateRecordAndRevalidate = useCallback(function (record) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
126
|
var recordId, newDataSet, data, _a, recordErrors, recordWarnings, hasError, hasWarning;
|
|
@@ -230,5 +289,7 @@ export var useValidationState = function (_a) {
|
|
|
230
289
|
errorsRef: errorsRef,
|
|
231
290
|
warningsRef: warningsRef,
|
|
232
291
|
updateRecordAndRevalidate: updateRecordAndRevalidate,
|
|
292
|
+
deleteRecords: deleteRecords,
|
|
293
|
+
filterRecordsBySearchValue: filterRecordsBySearchValue,
|
|
233
294
|
};
|
|
234
295
|
};
|
|
@@ -12,8 +12,8 @@ export type SpreadsheetProps = {
|
|
|
12
12
|
onValidateRecord?: OnValidateRecord;
|
|
13
13
|
onDataSetChanged?: OnDataSetChanged;
|
|
14
14
|
onValidationStateChanged?: OnValidationStateChanged;
|
|
15
|
-
selectedRows?:
|
|
16
|
-
setSelectedRows?: React.Dispatch<React.SetStateAction<
|
|
15
|
+
selectedRows?: string[];
|
|
16
|
+
setSelectedRows?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
17
17
|
};
|
|
18
18
|
declare const _default: React.MemoExoticComponent<({ isReadOnly, initialDataSet, rowWidth, fields, options, highlightFirstRow, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: SpreadsheetProps) => JSX.Element>;
|
|
19
19
|
export default _default;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
interface SpreadSheetWrapperProps {
|
|
3
|
+
canShowCheckboxOnHover?: boolean;
|
|
4
|
+
shouldShowOnlyCheckbox?: boolean;
|
|
5
|
+
}
|
|
2
6
|
export declare const SpreadSheetData: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
3
|
-
export declare const SpreadSheetWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
4
|
-
export declare const
|
|
7
|
+
export declare const SpreadSheetWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & SpreadSheetWrapperProps, never>;
|
|
8
|
+
export declare const SpreadSheetContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
9
|
+
export declare const TableView: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, isInsideImporter, ...props }: import("../../../common/Table/TableView").TableViewProps) => JSX.Element>, import("styled-components").DefaultTheme, {}, never>;
|
|
10
|
+
export {};
|
|
@@ -2,10 +2,15 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
import styled from "styled-components";
|
|
5
|
+
import styled, { css } from "styled-components";
|
|
6
6
|
import { TableView as TableViewBase, TableViewCellContainer, TableViewRow, } from "../../../common/Table/TableView";
|
|
7
7
|
import { Div } from "../../../styled/utils";
|
|
8
|
-
export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n width: 100%;\n"])));
|
|
9
|
-
export var SpreadSheetWrapper = styled(Div)(
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n max-height: 675px;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n max-height: 675px;\n width: 100%;\n"])));
|
|
9
|
+
export var SpreadSheetWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"], ["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; }, function (_a) {
|
|
10
|
+
var canShowCheckboxOnHover = _a.canShowCheckboxOnHover, shouldShowOnlyCheckbox = _a.shouldShowOnlyCheckbox;
|
|
11
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "], ["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "])), shouldShowOnlyCheckbox && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "], ["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "]))), !shouldShowOnlyCheckbox &&
|
|
12
|
+
canShowCheckboxOnHover && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "], ["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "]))));
|
|
13
|
+
});
|
|
14
|
+
export var SpreadSheetContainer = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
|
|
15
|
+
export var TableView = styled(TableViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"], ["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"])), function (p) { return p.theme.colors.gray50; }, TableViewRow, TableViewCellContainer, function (p) { return p.theme.colors.gray300; });
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -14,6 +14,10 @@ export type EnumFieldValueMatchings = {
|
|
|
14
14
|
export type UploadedDataEnumFieldValues = {
|
|
15
15
|
[templateHeaderLabel: string]: string[];
|
|
16
16
|
};
|
|
17
|
+
export type SelectedRow = {
|
|
18
|
+
tableRow: number;
|
|
19
|
+
dataRowIndex: number;
|
|
20
|
+
};
|
|
17
21
|
export type State = {
|
|
18
22
|
currentStepIndex: number;
|
|
19
23
|
templateError: string | null;
|
|
@@ -44,8 +48,8 @@ export type State = {
|
|
|
44
48
|
formatRecord: FormatRecord;
|
|
45
49
|
onValidateRecord?: OnValidateRecord;
|
|
46
50
|
setMatcherSubstep: React.Dispatch<number>;
|
|
47
|
-
selectedRows:
|
|
48
|
-
setSelectedRows: React.Dispatch<React.SetStateAction<
|
|
51
|
+
selectedRows: string[];
|
|
52
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
49
53
|
};
|
|
50
54
|
export type Props = {
|
|
51
55
|
templateSlug: string;
|
|
@@ -113,12 +113,8 @@ export var ImporterContextProvider = function (_a) {
|
|
|
113
113
|
useEffect(function () {
|
|
114
114
|
if (uploadedData) {
|
|
115
115
|
setHeadersFromDataset();
|
|
116
|
-
selectAllRows();
|
|
117
116
|
}
|
|
118
117
|
}, [uploadedData]);
|
|
119
|
-
var selectAllRows = function () {
|
|
120
|
-
setSelectedRows(uploadedData.map(function (_, index) { return index; }));
|
|
121
|
-
};
|
|
122
118
|
useEffect(function () {
|
|
123
119
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
124
120
|
var _a, organization_1, columns, importer_style_preferences, integrations_1, preview_first_time, columnsOrderedByPosition, error_1, errorMsg;
|