fuse-importer 0.0.1-staging → 0.0.1-testing
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/ImporterWithContext.js +1 -1
- package/lib/esm/Importer/Review/ReviewContextProvider.js +4 -11
- package/lib/esm/Importer/Uploader/HeadersPreview.js +16 -8
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +9 -20
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +44 -15
- package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +13 -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/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +2 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +24 -20
- package/lib/esm/Importer/data/index.d.ts +1 -0
- package/lib/esm/Importer/data/index.js +7 -12
- package/lib/esm/common/Table/TableActions/RowFilters.js +4 -1
- 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 +11 -4
- package/lib/esm/common/Table/TableView/types.d.ts +1 -1
- package/lib/esm/common/inputs/Autocomplete.js +1 -1
- package/lib/esm/common/inputs/Checkbox.js +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +38 -27
- package/lib/esm/locales/de.js +1 -1
- package/lib/esm/locales/en.js +1 -1
- package/lib/esm/locales/es.js +1 -1
- package/lib/esm/locales/fr.js +1 -1
- package/lib/esm/types.d.ts +5 -8
- package/package.json +3 -4
- package/lib/main.js +0 -172
- package/lib/main.js.LICENSE.txt +0 -61
|
@@ -41,7 +41,7 @@ var Content = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplate
|
|
|
41
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);
|
|
42
42
|
});
|
|
43
43
|
export var ImporterWithContext = function () {
|
|
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, initialRecords = _a.initialRecords, _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;
|
|
45
45
|
var layoutRef = useRef(null);
|
|
46
46
|
var t = useTranslation().t;
|
|
47
47
|
useEffect(function () {
|
|
@@ -125,7 +125,7 @@ function csvExport(data) {
|
|
|
125
125
|
}
|
|
126
126
|
export var ReviewContextProvider = function (_a) {
|
|
127
127
|
var initialRecords = _a.initialRecords, children = _a.children;
|
|
128
|
-
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;
|
|
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;
|
|
129
129
|
var _d = useState(false), isSubmitting = _d[0], setIsSubmitting = _d[1];
|
|
130
130
|
var _e = useState(false), isSubmitDisabled = _e[0], setIsSubmitDisabled = _e[1];
|
|
131
131
|
var _f = useState(false), importWasSuccessful = _f[0], setImportWasSuccessful = _f[1];
|
|
@@ -247,25 +247,18 @@ export var ReviewContextProvider = function (_a) {
|
|
|
247
247
|
enumFieldValueMatchings: enumFieldValueMatchings,
|
|
248
248
|
templateHeaders: templateHeaders,
|
|
249
249
|
uploadedDataHeaders: uploadedDataHeaders,
|
|
250
|
-
uploadedData: uploadedData,
|
|
250
|
+
uploadedData: uploadedData.slice(headerRowIndex + 1),
|
|
251
251
|
formatRecord: formatRecord,
|
|
252
252
|
});
|
|
253
253
|
var initialDataSet = getReviewDataSet({
|
|
254
254
|
records: _records,
|
|
255
255
|
fields: fields,
|
|
256
256
|
}).initialDataSet;
|
|
257
|
+
setSelectedRows([]);
|
|
257
258
|
setReviewFields(fields);
|
|
258
259
|
setReviewInitialDataSet(initialDataSet);
|
|
259
260
|
}
|
|
260
|
-
}, [
|
|
261
|
-
uploadedData,
|
|
262
|
-
currentStepIndex,
|
|
263
|
-
enumFieldValueMatchings,
|
|
264
|
-
templateHeaderMatchings,
|
|
265
|
-
templateHeaders,
|
|
266
|
-
uploadedDataHeaders,
|
|
267
|
-
uploadedData,
|
|
268
|
-
]);
|
|
261
|
+
}, [uploadedData, currentStepIndex, templateHeaders, uploadedData]);
|
|
269
262
|
var value = {
|
|
270
263
|
previewInitialDataSet: previewInitialDataSet,
|
|
271
264
|
previewFields: previewFields,
|
|
@@ -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;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
//Filter records by search value
|
|
13
2
|
export var filterRecordsBySearchValue = function (obj, value) {
|
|
14
3
|
var isObject = function (value) {
|
|
@@ -38,6 +27,7 @@ export var filterRecordsBySearchValue = function (obj, value) {
|
|
|
38
27
|
return filteredObj;
|
|
39
28
|
};
|
|
40
29
|
export var filterRecordsByType = function (obj, filterType) {
|
|
30
|
+
var _a, _b;
|
|
41
31
|
var rowIsEmpty = function (row) {
|
|
42
32
|
return Object.keys(row).every(function (key) {
|
|
43
33
|
if (key === "_meta")
|
|
@@ -45,16 +35,15 @@ export var filterRecordsByType = function (obj, filterType) {
|
|
|
45
35
|
return !row[key];
|
|
46
36
|
});
|
|
47
37
|
};
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
var filteredObj = {};
|
|
39
|
+
for (var key in obj) {
|
|
40
|
+
if (filterType === "all" ||
|
|
51
41
|
(((_b = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.isInvalid) !== (filterType === "valid") &&
|
|
52
|
-
!rowIsEmpty(obj[key]))
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, {});
|
|
42
|
+
!rowIsEmpty(obj[key]))) {
|
|
43
|
+
filteredObj[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return filteredObj;
|
|
58
47
|
};
|
|
59
48
|
//Filter records by selected column error
|
|
60
49
|
export var filterRecordsByError = function (obj, keyToFilter, errors) {
|
|
@@ -13,7 +13,6 @@ type State = {
|
|
|
13
13
|
isReadOnly?: boolean;
|
|
14
14
|
errors: BatchValidationErrors;
|
|
15
15
|
warnings: BatchValidationErrors;
|
|
16
|
-
highlightFirstRow: boolean;
|
|
17
16
|
options: SpreadsheetOptions;
|
|
18
17
|
sortByFieldErrors: string;
|
|
19
18
|
sortByFieldWarnings: string;
|
|
@@ -33,6 +32,7 @@ type State = {
|
|
|
33
32
|
filterRecordsByFieldErrors: (filterByColumn: string) => void;
|
|
34
33
|
resetSpreadsheetFilter: () => void;
|
|
35
34
|
recordsWithValuesCount: number;
|
|
35
|
+
loadNextPage: () => void;
|
|
36
36
|
filteredDataCount: number;
|
|
37
37
|
checkboxColumnWidth: number;
|
|
38
38
|
isFiltering: boolean;
|
|
@@ -42,6 +42,6 @@ type State = {
|
|
|
42
42
|
type Props = SpreadsheetProps & {
|
|
43
43
|
children: JSX.Element;
|
|
44
44
|
};
|
|
45
|
-
export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly,
|
|
45
|
+
export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, getSortCompareFn, }: Props) => JSX.Element;
|
|
46
46
|
export declare const useSpreadsheetContext: () => State;
|
|
47
47
|
export {};
|
|
@@ -23,7 +23,7 @@ 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 {
|
|
26
|
+
import { getRowId } from "../../../data";
|
|
27
27
|
import { useValidationState } from "../hooks";
|
|
28
28
|
import { useSpreadsheetFilter, } from "./useSpreadsheetFilter";
|
|
29
29
|
import { filterRecordsByType, filterRecordsByError, filterRecordsBySearchValue, } from "./filterMethods";
|
|
@@ -45,7 +45,7 @@ var getDefaultSortCompareFn = function (sortBy) {
|
|
|
45
45
|
};
|
|
46
46
|
var SpreadsheetContext = createContext({});
|
|
47
47
|
export var SpreadsheetContextProvider = function (_a) {
|
|
48
|
-
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;
|
|
49
49
|
var _c = useState(initialDataSet), dataSet = _c[0], setDataSet = _c[1];
|
|
50
50
|
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
51
51
|
var _e = useState(null), sortByFieldErrors = _e[0], setSortByFieldErrors = _e[1];
|
|
@@ -65,15 +65,18 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
65
65
|
onValidateRecord: onValidateRecord,
|
|
66
66
|
}), updateRecordAndRevalidate = _k.updateRecordAndRevalidate, deleteRecords = _k.deleteRecords, warnings = _k.warnings, errors = _k.errors, validationState = __rest(_k, ["updateRecordAndRevalidate", "deleteRecords", "warnings", "errors"]);
|
|
67
67
|
var addNewRowsToSpreadsheet = function () {
|
|
68
|
-
addRowTimeoutRef.current = setTimeout(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
// addRowTimeoutRef.current = setTimeout(() => {
|
|
69
|
+
// let highestRowIndex = -1;
|
|
70
|
+
// for (const key in dataSet)
|
|
71
|
+
// if (dataSet[key]?._meta?.rowIndex > highestRowIndex)
|
|
72
|
+
// highestRowIndex = dataSet[key]._meta.rowIndex;
|
|
73
|
+
// const newRow = addMeta({}, highestRowIndex + 1);
|
|
74
|
+
// setDataSet((oldValues) => ({
|
|
75
|
+
// ...oldValues,
|
|
76
|
+
// [newRow._meta.id]: newRow,
|
|
77
|
+
// }));
|
|
78
|
+
// addRowTimeoutRef.current = null;
|
|
79
|
+
// }, 300);
|
|
77
80
|
};
|
|
78
81
|
var handleDeleteErrors = function (selectedRows) {
|
|
79
82
|
deleteRecords(selectedRows, errors, warnings);
|
|
@@ -128,14 +131,40 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
128
131
|
return value !== null && value !== undefined && typeof value !== "object";
|
|
129
132
|
})
|
|
130
133
|
.some(function (value) { return value !== "null" && value !== "undefined"; });
|
|
131
|
-
if (hasValueInTheLastObject) {
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
+
// if (hasValueInTheLastObject) {
|
|
135
|
+
// addNewRowsToSpreadsheet();
|
|
136
|
+
// }
|
|
134
137
|
}, [dataSet]);
|
|
135
138
|
useEffect(function () {
|
|
136
139
|
onValidationStateChanged &&
|
|
137
140
|
onValidationStateChanged(__assign(__assign({}, validationState), { errors: errors, warnings: warnings }));
|
|
138
141
|
}, [validationState, onValidationStateChanged]);
|
|
142
|
+
var loadNextPage = function () {
|
|
143
|
+
var recordBase = {
|
|
144
|
+
date: "12/17/1992",
|
|
145
|
+
email: "pbonass0@jigsy2.com",
|
|
146
|
+
name: "testing Bonass",
|
|
147
|
+
};
|
|
148
|
+
// lastRowIndex in dataset values
|
|
149
|
+
var lastRowIndex = Object.values(dataSet).reduce(function (acc, curr) {
|
|
150
|
+
if (curr._meta.rowIndex > acc) {
|
|
151
|
+
return curr._meta.rowIndex;
|
|
152
|
+
}
|
|
153
|
+
return acc;
|
|
154
|
+
}, 0);
|
|
155
|
+
var newObject = {};
|
|
156
|
+
// add 10 records to dataSEt based on recordBase (missing _meta)
|
|
157
|
+
for (var i = 0; i < 500000; i++) {
|
|
158
|
+
var id = getRowId(lastRowIndex + i + 1);
|
|
159
|
+
newObject[id] = __assign(__assign({}, recordBase), { _meta: {
|
|
160
|
+
id: id,
|
|
161
|
+
rowIndex: i,
|
|
162
|
+
touched: false,
|
|
163
|
+
uploadedRow: ["12/17/1992", "pbonass0@jigsy2.com", "testing Bonass"],
|
|
164
|
+
} });
|
|
165
|
+
}
|
|
166
|
+
setDataSet(function (oldValues) { return (__assign(__assign({}, oldValues), newObject)); });
|
|
167
|
+
};
|
|
139
168
|
var handleSortByFieldErrors = useCallback(function (field) {
|
|
140
169
|
setSortByFieldErrors(field === sortByFieldErrors ? null : field);
|
|
141
170
|
setSortByFieldWarnings(null);
|
|
@@ -161,7 +190,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
161
190
|
return updatedData;
|
|
162
191
|
});
|
|
163
192
|
}, [dataSet, dataSnapshot]);
|
|
164
|
-
var value = __assign(__assign({ data: updatedDataSnapshot, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings,
|
|
193
|
+
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, loadNextPage: loadNextPage, 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 });
|
|
165
194
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
166
195
|
};
|
|
167
196
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import React, { useCallback, useMemo, useRef } from "react";
|
|
24
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
25
25
|
import { areEqual } from "react-window";
|
|
26
26
|
import { Div } from "../../../../styled/utils";
|
|
27
27
|
import { getTableHeight } from "../../../common";
|
|
@@ -37,13 +37,21 @@ import { TableActions } from "../../../../common/Table/TableActions";
|
|
|
37
37
|
import { useImporterContext } from "../../../../Importer/contexts/ImporterContextProvider";
|
|
38
38
|
import useWindowDimensions from "../../../../utils/hooks/useWindowSize";
|
|
39
39
|
var getItemKey = function (record) { return record._meta.id; };
|
|
40
|
-
var SpreadsheetData = function () {
|
|
41
|
-
var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options, setSortByFieldWarnings = _a.setSortByFieldWarnings, selectedRows = _a.selectedRows, checkboxColumnWidth = _a.checkboxColumnWidth, isFiltering = _a.isFiltering;
|
|
40
|
+
var SpreadsheetData = function (props) {
|
|
41
|
+
var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options, setSortByFieldWarnings = _a.setSortByFieldWarnings, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows, checkboxColumnWidth = _a.checkboxColumnWidth, isFiltering = _a.isFiltering;
|
|
42
42
|
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
43
43
|
var isOnSmallScreens = useWindowDimensions().isOnSmallScreens;
|
|
44
|
+
var loadNextPage = useSpreadsheetContext().loadNextPage;
|
|
44
45
|
var canShowCheckboxOnCheckboxRowHover = currentStepIndex === 2;
|
|
45
46
|
var rowNumbersGridRef = useRef();
|
|
46
47
|
var rowCheckboxesGridRef = useRef();
|
|
48
|
+
var onScrollToBottom = function () {
|
|
49
|
+
loadNextPage();
|
|
50
|
+
};
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
if (data.length > 0 && options.withSingleRowSelect)
|
|
53
|
+
setSelectedRows([data === null || data === void 0 ? void 0 : data[0]._meta.id]);
|
|
54
|
+
}, [options.withSingleRowSelect]);
|
|
47
55
|
var rowWidthScalingFactor = (function () {
|
|
48
56
|
// Spreadsheet will display 6 columns on the viewport and a small portion of the
|
|
49
57
|
// 7th column in the right side to let the user know they can scroll horizontally
|
|
@@ -100,6 +108,7 @@ var SpreadsheetData = function () {
|
|
|
100
108
|
}, [dataLength]);
|
|
101
109
|
var showValidationProgress = !isReadOnly && validationPercentage < 100;
|
|
102
110
|
var isReviewStep = currentStepIndex === 2;
|
|
103
|
-
return (_jsxs(S.SpreadSheetData, __assign({ h100: true, flexColumn: true }, { children: [_jsx(GlobalStyle, {}), showValidationProgress && (_jsx(Div, __assign({ h: 32 }, { children: _jsx(ValidationProgress, { totalErrors: totalErrors, validationPercentage: validationPercentage }) }))), _jsxs(S.SpreadSheetContainer, __assign({ flexColumn: true, w100: true, h100: true }, { children: [_jsx(Div, __assign({ w100: true, justifyCenter: true }, { children: isReviewStep && _jsx(TableActions, {}) })), _jsxs(S.SpreadSheetWrapper, __assign({ canShowCheckboxOnHover: !showValidationProgress && canShowCheckboxOnCheckboxRowHover, shouldShowOnlyCheckbox: !showValidationProgress && selectedRows.length > 0
|
|
111
|
+
return (_jsxs(S.SpreadSheetData, __assign({ h100: true, flexColumn: true, className: props.className }, { children: [_jsx(GlobalStyle, {}), showValidationProgress && (_jsx(Div, __assign({ h: 32 }, { children: _jsx(ValidationProgress, { totalErrors: totalErrors, validationPercentage: validationPercentage }) }))), _jsxs(S.SpreadSheetContainer, __assign({ flexColumn: true, w100: true, h100: true }, { children: [_jsx(Div, __assign({ w100: true, justifyCenter: true }, { children: isReviewStep && _jsx(TableActions, {}) })), _jsxs(S.SpreadSheetWrapper, __assign({ canShowCheckboxOnHover: !showValidationProgress && canShowCheckboxOnCheckboxRowHover, shouldShowOnlyCheckbox: (!showValidationProgress && selectedRows.length > 0) ||
|
|
112
|
+
currentStepIndex === 0, dflex: true, h100: true }, { children: [(options === null || options === void 0 ? void 0 : options.showCheckboxColumn) && (_jsx(SpreadsheetRowCheckboxes, { gridRef: rowCheckboxesGridRef, height: spreadsheetHeight, isLoadingData: showValidationProgress })), _jsx(S.TableView, { tableHeadersHeight: spreadsheetHeaderHeightPx, rowHeight: spreadsheetRowHeightPx, h: null, onScrollToBottom: onScrollToBottom, rowWidthScalingFactor: rowWidthScalingFactor, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey, checkboxColumnWidth: checkboxColumnWidth, isFiltering: isFiltering })] }))] }))] })));
|
|
104
113
|
};
|
|
105
114
|
export default React.memo(SpreadsheetData, areEqual);
|
|
@@ -3,8 +3,7 @@ import { DivCSSProps } from "../../../../styled/utils";
|
|
|
3
3
|
type Props = {
|
|
4
4
|
height?: number;
|
|
5
5
|
gridRef: React.MutableRefObject<any>;
|
|
6
|
-
firstRowIsHeader?: boolean;
|
|
7
6
|
isLoadingData?: boolean;
|
|
8
7
|
} & DivCSSProps;
|
|
9
|
-
export declare const SpreadsheetRowCheckboxes: ({ height, gridRef,
|
|
8
|
+
export declare const SpreadsheetRowCheckboxes: ({ height, gridRef, isLoadingData, ...props }: Props) => JSX.Element;
|
|
10
9
|
export {};
|
|
@@ -62,27 +62,31 @@ var rowIsEmpty = function (row) {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
export var SpreadsheetRowCheckboxes = function (_a) {
|
|
65
|
-
var height = _a.height, gridRef = _a.gridRef,
|
|
66
|
-
var
|
|
65
|
+
var height = _a.height, gridRef = _a.gridRef, isLoadingData = _a.isLoadingData, props = __rest(_a, ["height", "gridRef", "isLoadingData"]);
|
|
66
|
+
var _b = useSpreadsheetContext(), data = _b.data, selectedRows = _b.selectedRows, options = _b.options, lastClickedIndexRef = _b.lastClickedIndexRef, setSelectedRows = _b.setSelectedRows, checkboxColumnWidth = _b.checkboxColumnWidth;
|
|
67
67
|
var currentStepIndex = useImporterContext().currentStepIndex;
|
|
68
68
|
var nonEmptyRows = useMemo(function () { return data.filter(function (row) { return !rowIsEmpty(row); }); }, [
|
|
69
69
|
data,
|
|
70
70
|
]);
|
|
71
71
|
var isIndeterminate = selectedRows.length > 0 && selectedRows.length < nonEmptyRows.length;
|
|
72
72
|
var handleRowSelect = function (checked, rowIndex, rowMetaId) {
|
|
73
|
+
var _a, _b;
|
|
73
74
|
var lastRowMetaId = data[data.length - 1]._meta.id;
|
|
74
75
|
var isLastRow = rowMetaId === lastRowMetaId;
|
|
75
76
|
var isLastRowAndEmpty = isLastRow && rowIsEmpty(data[rowIndex]);
|
|
76
77
|
if (isLastRowAndEmpty)
|
|
77
78
|
return;
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (options.withSingleRowSelect) {
|
|
80
|
+
if (!rowIsEmpty(data[rowIndex]))
|
|
81
|
+
setSelectedRows([(_b = (_a = data[rowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id]);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
if (checked) {
|
|
81
|
-
setSelectedRows(function (prev) { var _a, _b; return __spreadArray(__spreadArray([], prev, true), [(_b = (_a = data[
|
|
85
|
+
setSelectedRows(function (prev) { var _a, _b; return __spreadArray(__spreadArray([], prev, true), [(_b = (_a = data[rowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id], false); });
|
|
82
86
|
}
|
|
83
87
|
else {
|
|
84
88
|
setSelectedRows(function (prev) {
|
|
85
|
-
return prev.filter(function (row) { var _a, _b; return row !== ((_b = (_a = data[
|
|
89
|
+
return prev.filter(function (row) { var _a, _b; return row !== ((_b = (_a = data[rowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id); });
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
lastClickedIndexRef.current = rowIndex;
|
|
@@ -144,12 +148,14 @@ export var SpreadsheetRowCheckboxes = function (_a) {
|
|
|
144
148
|
};
|
|
145
149
|
var CheckboxCell = function (_a) {
|
|
146
150
|
var _b, _c;
|
|
147
|
-
var rowIndex = _a.rowIndex
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
return (_jsx(Div, __assign({ className: "checkbox-cell" }, { children: firstRowIsHeader && rowIndex === 0 ? ("") : (_jsx(Checkbox, { isChecked: rowMetaId && selectedRows.includes(rowMetaId), onChange: function (checked) {
|
|
151
|
+
var rowIndex = _a.rowIndex;
|
|
152
|
+
var rowMetaId = (_c = (_b = data[rowIndex]) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.id;
|
|
153
|
+
return (_jsx(Div, __assign({ className: "checkbox-cell", "data-test-id": "checkbox-cell-".concat(rowIndex) }, { children: _jsx(Checkbox, { isChecked: rowMetaId && selectedRows.includes(rowMetaId), onChange: function (checked) {
|
|
151
154
|
return !isLoadingData && handleRowSelect(checked, rowIndex, rowMetaId);
|
|
152
|
-
}, onShiftKeyPressed: function () {
|
|
155
|
+
}, onShiftKeyPressed: function () {
|
|
156
|
+
if (!options.withSingleRowSelect)
|
|
157
|
+
handleSelectMultipleRows(rowIndex);
|
|
158
|
+
}, style: { cursor: "pointer" }, isDisabled: isLoadingData }) })));
|
|
153
159
|
};
|
|
154
160
|
var RowNumbersCell = function (_a) {
|
|
155
161
|
var rowIndex = _a.rowIndex;
|
|
@@ -157,8 +163,7 @@ export var SpreadsheetRowCheckboxes = function (_a) {
|
|
|
157
163
|
};
|
|
158
164
|
var Cell = function (_a) {
|
|
159
165
|
var rowIndex = _a.rowIndex, style = _a.style;
|
|
160
|
-
|
|
161
|
-
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));
|
|
166
|
+
return (_jsxs(RowCheckbox, __assign({ style: style, alignCenter: true, justifyCenter: true, isLast: rowIndex === data.length - 1 }, { children: [_jsx(CheckboxCell, { rowIndex: rowIndex }), _jsx(RowNumbersCell, { rowIndex: rowIndex })] }), rowIndex));
|
|
162
167
|
};
|
|
163
168
|
var isSelectAllRowsChekboxChecked = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) > 0 &&
|
|
164
169
|
(data === null || data === void 0 ? void 0 : data.length) > 0 &&
|
|
@@ -118,7 +118,7 @@ var SpreadsheetWrapper = function (_a) {
|
|
|
118
118
|
};
|
|
119
119
|
var Spreadsheet = function (props) {
|
|
120
120
|
var getDefaultSortCompareFn = useFieldSorting().getDefaultSortCompareFn;
|
|
121
|
-
return (_jsx(SpreadsheetContextProvider, __assign({}, props, { getSortCompareFn: getDefaultSortCompareFn }, { children: _jsx(SpreadsheetData, {}) })));
|
|
121
|
+
return (_jsx(SpreadsheetContextProvider, __assign({}, props, { getSortCompareFn: getDefaultSortCompareFn }, { children: _jsx(SpreadsheetData, { className: props.className }) })));
|
|
122
122
|
};
|
|
123
123
|
export default React.memo(SpreadsheetWrapper, areEqual);
|
|
124
124
|
export * from "./SpreadsheetContextProvider";
|
|
@@ -6,5 +6,5 @@ interface SpreadSheetWrapperProps {
|
|
|
6
6
|
export declare const SpreadSheetData: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
7
7
|
export declare const SpreadSheetWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & SpreadSheetWrapperProps, never>;
|
|
8
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,
|
|
9
|
+
export declare const TableView: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, onScrollToBottom, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: import("../../../common/Table/TableView/types").TableViewProps) => JSX.Element>, import("styled-components").DefaultTheme, {}, never>;
|
|
10
10
|
export {};
|
|
@@ -39,6 +39,8 @@ export type State = {
|
|
|
39
39
|
logoURL: string;
|
|
40
40
|
integrations: Integration[];
|
|
41
41
|
onSubmit: OnSubmit;
|
|
42
|
+
headerRowIndex: number;
|
|
43
|
+
setHeaderRowIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
42
44
|
resetImport: () => void;
|
|
43
45
|
onClose: () => void;
|
|
44
46
|
setCurrentStepIndex: React.Dispatch<number>;
|
|
@@ -85,6 +85,7 @@ export var ImporterContextProvider = function (_a) {
|
|
|
85
85
|
var _o = useState(null), uploadedDataEnumFieldValues = _o[0], setUploadedDataEnumFieldValues = _o[1];
|
|
86
86
|
var _p = useState([]), selectedRows = _p[0], setSelectedRows = _p[1];
|
|
87
87
|
var isUsingManualImport = useRef(false);
|
|
88
|
+
var _q = useState(0), headerRowIndex = _q[0], setHeaderRowIndex = _q[1];
|
|
88
89
|
var fuseApi = useMemo(function () { return new FuseApi(options.env, apiToken); }, [
|
|
89
90
|
options.env,
|
|
90
91
|
apiToken,
|
|
@@ -99,12 +100,28 @@ export var ImporterContextProvider = function (_a) {
|
|
|
99
100
|
return acc;
|
|
100
101
|
}, []);
|
|
101
102
|
}
|
|
102
|
-
return (_a = uploadedData[
|
|
103
|
+
return (_a = uploadedData[headerRowIndex]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
|
|
103
104
|
return typeof ud === "number" ? ud.toString() : ud;
|
|
104
105
|
});
|
|
105
|
-
}, [uploadedData]);
|
|
106
|
+
}, [uploadedData, headerRowIndex]);
|
|
107
|
+
useEffect(function () { }, []);
|
|
106
108
|
useEffect(function () {
|
|
107
|
-
|
|
109
|
+
var setHeadersFromDataset = function () {
|
|
110
|
+
var _templateHeaderMatchings = {};
|
|
111
|
+
var fuse = new Fuse(uploadedDataHeaders, fusejsOptions);
|
|
112
|
+
templateHeaders.forEach(function (templateHeader, _index) {
|
|
113
|
+
var _a;
|
|
114
|
+
var fuseResults = fuse.search(templateHeader.label);
|
|
115
|
+
_templateHeaderMatchings[templateHeader.label] = (_a = fuseResults[0]) === null || _a === void 0 ? void 0 : _a.item;
|
|
116
|
+
});
|
|
117
|
+
setTemplateHeaderMatchings(_templateHeaderMatchings);
|
|
118
|
+
};
|
|
119
|
+
if (uploadedDataHeaders) {
|
|
120
|
+
setHeadersFromDataset();
|
|
121
|
+
}
|
|
122
|
+
}, [uploadedDataHeaders]);
|
|
123
|
+
useEffect(function () {
|
|
124
|
+
if (!templateHeaderMatchings || !uploadedDataHeaders)
|
|
108
125
|
return;
|
|
109
126
|
var _uploadedDataEnumFieldValues = {};
|
|
110
127
|
var templateLabels = Object.keys(templateHeaderMatchings);
|
|
@@ -117,7 +134,7 @@ export var ImporterContextProvider = function (_a) {
|
|
|
117
134
|
var columnIndex = uploadedDataHeaders.indexOf(uploadedDataHeader);
|
|
118
135
|
if (columnIndex === -1)
|
|
119
136
|
return;
|
|
120
|
-
uploadedData.slice(1).forEach(function (row) {
|
|
137
|
+
uploadedData === null || uploadedData === void 0 ? void 0 : uploadedData.slice(headerRowIndex + 1).forEach(function (row) {
|
|
121
138
|
var uploadedValue = row[columnIndex];
|
|
122
139
|
enumFieldValues.add(uploadedValue);
|
|
123
140
|
});
|
|
@@ -126,12 +143,7 @@ export var ImporterContextProvider = function (_a) {
|
|
|
126
143
|
});
|
|
127
144
|
});
|
|
128
145
|
setUploadedDataEnumFieldValues(_uploadedDataEnumFieldValues);
|
|
129
|
-
}, [templateHeaderMatchings]);
|
|
130
|
-
useEffect(function () {
|
|
131
|
-
if (uploadedData) {
|
|
132
|
-
setHeadersFromDataset();
|
|
133
|
-
}
|
|
134
|
-
}, [uploadedData]);
|
|
146
|
+
}, [templateHeaderMatchings, uploadedDataHeaders]);
|
|
135
147
|
useEffect(function () {
|
|
136
148
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
149
|
var _a, organization_1, columns_1, importer_style_preferences, integrations_1, preview_first_time, error_1, errorMsg;
|
|
@@ -191,16 +203,6 @@ export var ImporterContextProvider = function (_a) {
|
|
|
191
203
|
setCurrentStepIndex(2);
|
|
192
204
|
}
|
|
193
205
|
};
|
|
194
|
-
var setHeadersFromDataset = function () {
|
|
195
|
-
var _templateHeaderMatchings = {};
|
|
196
|
-
var fuse = new Fuse(uploadedDataHeaders, fusejsOptions);
|
|
197
|
-
templateHeaders.forEach(function (templateHeader, _index) {
|
|
198
|
-
var _a;
|
|
199
|
-
var fuseResults = fuse.search(templateHeader.label);
|
|
200
|
-
_templateHeaderMatchings[templateHeader.label] = (_a = fuseResults[0]) === null || _a === void 0 ? void 0 : _a.item;
|
|
201
|
-
});
|
|
202
|
-
setTemplateHeaderMatchings(_templateHeaderMatchings);
|
|
203
|
-
};
|
|
204
206
|
var inTrialMode = organization === null || organization === void 0 ? void 0 : organization.trial_mode;
|
|
205
207
|
var value = {
|
|
206
208
|
initialRecords: initialRecords,
|
|
@@ -222,6 +224,8 @@ export var ImporterContextProvider = function (_a) {
|
|
|
222
224
|
logoURL: style.logoURL,
|
|
223
225
|
integrations: integrations,
|
|
224
226
|
previewFirstTime: previewFirstTime,
|
|
227
|
+
headerRowIndex: headerRowIndex,
|
|
228
|
+
setHeaderRowIndex: setHeaderRowIndex,
|
|
225
229
|
setUploadedData: setUploadedData,
|
|
226
230
|
formatRecord: formatRecord,
|
|
227
231
|
setCurrentStepIndex: setCurrentStepIndex,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader } from "../../types";
|
|
2
2
|
import { EnumFieldValueMatchings, HeaderMatchings } from "../contexts/ImporterContextProvider";
|
|
3
|
+
export declare const getRowId: (index: number) => string;
|
|
3
4
|
export declare const addEmptyRows: (data: Record[], fields: Field[]) => (Record | {
|
|
4
5
|
_meta: {
|
|
5
6
|
id: string;
|
|
@@ -22,7 +22,7 @@ import { transformRecord } from "../../Importer/common/Spreadsheet/transformatio
|
|
|
22
22
|
import { FieldTypes, } from "../../types";
|
|
23
23
|
import { parseValue } from "../common/Spreadsheet/common";
|
|
24
24
|
var MINIMUM_ROW_COUNT = 20;
|
|
25
|
-
var getRowId = function (index) {
|
|
25
|
+
export var getRowId = function (index) {
|
|
26
26
|
var uniqueTimestamp = new Date().getTime();
|
|
27
27
|
return "r".concat(index, "-").concat(uniqueTimestamp);
|
|
28
28
|
};
|
|
@@ -85,17 +85,14 @@ export var transformToRecords = function (_a) {
|
|
|
85
85
|
});
|
|
86
86
|
return formatRecord ? formatRecord(record) : record;
|
|
87
87
|
};
|
|
88
|
-
return uploadedData.
|
|
88
|
+
return uploadedData.map(getRecord);
|
|
89
89
|
};
|
|
90
90
|
export var getPreviewDataSet = function (_a) {
|
|
91
91
|
var uploadedData = _a.uploadedData;
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return 0;
|
|
97
|
-
};
|
|
98
|
-
var fields = new Array(getFirstRowLen()).fill(null).map(function (_, i) {
|
|
92
|
+
var rowLen = 0;
|
|
93
|
+
for (var i = 0; i < uploadedData.length; i++)
|
|
94
|
+
rowLen = Math.max(rowLen, uploadedData[i].length);
|
|
95
|
+
var fields = new Array(rowLen).fill(null).map(function (_, i) {
|
|
99
96
|
var key = String.fromCharCode(65 + i);
|
|
100
97
|
return {
|
|
101
98
|
label: key,
|
|
@@ -105,9 +102,7 @@ export var getPreviewDataSet = function (_a) {
|
|
|
105
102
|
};
|
|
106
103
|
});
|
|
107
104
|
var getInitialDataSet = function () {
|
|
108
|
-
|
|
109
|
-
//TODO: Check with Mike
|
|
110
|
-
var data = uploadedData.slice(0, 100).map(function (row, index) {
|
|
105
|
+
var data = uploadedData.map(function (row, index) {
|
|
111
106
|
var entry = addMeta({}, index);
|
|
112
107
|
fields.forEach(function (field, index) {
|
|
113
108
|
entry[field.name] = row[index];
|
|
@@ -26,7 +26,10 @@ var FilteredDataCount = styled(Div)(templateObject_4 || (templateObject_4 = __ma
|
|
|
26
26
|
var Filter = function (_a) {
|
|
27
27
|
var label = _a.label, count = _a.count, isSelected = _a.isSelected, onClick = _a.onClick;
|
|
28
28
|
var _b = useSpreadsheetContext(), filteredInputValue = _b.filteredInputValue, filteredDataCount = _b.filteredDataCount;
|
|
29
|
-
|
|
29
|
+
var labelToId = function (label) {
|
|
30
|
+
return label.toLowerCase().replace(/\s/g, "_") + "_filter";
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(Div, __assign({ dflex: true, clickable: true, onClick: onClick, "data-test-id": labelToId(label) }, { children: [_jsxs(FilterContainer, __assign({ isSelected: isSelected }, { children: [label, count >= 0 && _jsxs(_Fragment, { children: ["\u00A0(", count, ")"] })] })), isSelected && filteredInputValue !== "" && (_jsx(FilteredDataCount, { children: _jsx(Div, __assign({ minw: 14, centered: true }, { children: filteredDataCount })) }))] })));
|
|
30
33
|
};
|
|
31
34
|
export var RowFilters = function () {
|
|
32
35
|
var _a = useSpreadsheetContext(), spreadsheetFilter = _a.spreadsheetFilter, errors = _a.errors, filterRecordsByRowType = _a.filterRecordsByRowType, recordsWithValuesCount = _a.recordsWithValuesCount;
|