fuse-importer 0.0.1-staging → 0.0.2-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.
Files changed (36) hide show
  1. package/lib/esm/Importer/ImporterWithContext.js +1 -1
  2. package/lib/esm/Importer/Review/ReviewContextProvider.js +4 -11
  3. package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +8 -11
  4. package/lib/esm/Importer/Uploader/HeadersPreview.js +16 -8
  5. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +9 -20
  6. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +1 -2
  7. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +7 -3
  8. package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -2
  9. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.d.ts +2 -1
  10. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +9 -4
  11. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
  12. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +18 -13
  13. package/lib/esm/Importer/common/Spreadsheet/index.js +1 -1
  14. package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
  15. package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +2 -0
  16. package/lib/esm/Importer/contexts/ImporterContextProvider.js +23 -20
  17. package/lib/esm/Importer/data/index.js +6 -11
  18. package/lib/esm/common/Table/TableActions/RowFilters.js +4 -1
  19. package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +2 -2
  20. package/lib/esm/common/Table/TableView/TableRows/TableRow.js +4 -4
  21. package/lib/esm/common/Table/TableView/TableRows/index.js +7 -4
  22. package/lib/esm/common/Table/TableView/index.d.ts +1 -1
  23. package/lib/esm/common/Table/TableView/index.js +1 -2
  24. package/lib/esm/common/Table/TableView/types.d.ts +0 -1
  25. package/lib/esm/common/inputs/Autocomplete.js +1 -1
  26. package/lib/esm/common/inputs/Checkbox.js +1 -1
  27. package/lib/esm/index.d.ts +1 -1
  28. package/lib/esm/index.js +15 -27
  29. package/lib/esm/locales/de.js +1 -1
  30. package/lib/esm/locales/en.js +1 -1
  31. package/lib/esm/locales/es.js +1 -1
  32. package/lib/esm/locales/fr.js +1 -1
  33. package/lib/esm/types.d.ts +5 -8
  34. package/package.json +3 -2
  35. package/lib/main.js +0 -172
  36. 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,
@@ -16,7 +16,6 @@ var __assign = (this && this.__assign) || function () {
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import { useDropzone } from "react-dropzone";
18
18
  import styled, { css } from "styled-components";
19
- import * as XLSX from "xlsx";
20
19
  import { useUploaderContext } from "../UploaderContextProvider";
21
20
  import { useImporterContext } from "../../contexts/ImporterContextProvider";
22
21
  import { Div } from "../../../styled/utils";
@@ -25,6 +24,7 @@ import { addToast } from "../../../common/Toast";
25
24
  import { Button } from "../../../common/buttons";
26
25
  import { DragAndDropSvg, UploadIndicatorSvg } from "./backgrounds";
27
26
  import { useTranslation } from "react-i18next";
27
+ import Papa from "papaparse";
28
28
  var DragAndDropCard = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: 8px;\n margin-right: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n background: ", ";\n border: 1px dashed ", ";\n\n @media (max-width: 1050px) {\n padding: 24px;\n width: auto;\n }\n\n ", "\n"], ["\n border-radius: 8px;\n margin-right: ", ";\n width: 100%;\n height: 100%;\n display: flex;\n background: ", ";\n border: 1px dashed ", ";\n\n @media (max-width: 1050px) {\n padding: 24px;\n width: auto;\n }\n\n ", "\n"])), function (props) { return (props.isDragActive ? "-10px" : "revert"); }, theme.colors.white, theme.colors.red50, function (props) {
29
29
  return props.isDragActive && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n border: 1px solid ", ";\n justify-content: center;\n "], ["\n background: ", ";\n border: 1px solid ", ";\n justify-content: center;\n "])), function (p) { return p.theme.colors.blue100; }, function (p) { return p.theme.colors.blue500; });
30
30
  });
@@ -63,14 +63,11 @@ var ImporterDropzone = function () {
63
63
  var _a;
64
64
  var results = event.target.result;
65
65
  var getDataFromFile = function (fileResults) {
66
- var workBook = XLSX.read(fileResults, {
67
- type: "array",
68
- codepage: 65001,
69
- raw: true,
70
- });
71
- var workBookName = workBook.SheetNames[0];
72
- var sheet = workBook.Sheets[workBookName];
73
- return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false });
66
+ var csvString = new TextDecoder().decode(fileResults instanceof ArrayBuffer
67
+ ? fileResults
68
+ : new TextEncoder().encode(fileResults));
69
+ var data = Papa.parse(csvString).data;
70
+ return data;
74
71
  };
75
72
  var fileData = getDataFromFile(results);
76
73
  var headersCount = (_a = fileData[0]) === null || _a === void 0 ? void 0 : _a.length;
@@ -85,7 +82,7 @@ var ImporterDropzone = function () {
85
82
  var onDropRejected = function (rejectedFiles) {
86
83
  var errorMessages = rejectedFiles.map(function (file) {
87
84
  if (file.errors[0].code === "file-too-large") {
88
- return "Maximum file size is 10MB";
85
+ return "Maximum file size is 40MB";
89
86
  }
90
87
  else {
91
88
  return file.errors[0].message;
@@ -103,7 +100,7 @@ var ImporterDropzone = function () {
103
100
  noKeyboard: true,
104
101
  accept: ".csv, .tsv, .xls, .xlsx",
105
102
  maxFiles: 1,
106
- maxSize: 10000000,
103
+ maxSize: 41943040, // 40MB
107
104
  }), getRootProps = _b.getRootProps, getInputProps = _b.getInputProps, open = _b.open, isDragActive = _b.isDragActive;
108
105
  return (_jsxs(DragAndDropCard, __assign({ isDragActive: isDragActive, centered: true, pRelative: true }, getRootProps(), { children: [_jsx("input", __assign({}, getInputProps())), isDragActive && dropzoneUploadingUI, _jsx(DragAndDropComponent, { openUploadFileDialog: open })] })));
109
106
  };
@@ -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 Spreadsheet from "../common/Spreadsheet";
21
+ import SpreadsheetBase from "../common/Spreadsheet";
22
22
  import { useImporterContext } from "../contexts/ImporterContextProvider";
23
23
  import { HeaderButtons } from "./HeaderButtons";
24
- var HeaderContainer = styled(Div)(templateObject_1 || (templateObject_1 = __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"])));
25
- var DescriptionAndButtons = styled(Div)(templateObject_2 || (templateObject_2 = __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"])));
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
- 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, highlightFirstRow: true, options: {
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
- firstRowIsHeader: true,
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 filteredKeys = Object.keys(obj).filter(function (key) {
49
- var _a, _b;
50
- return filterType === "all" ||
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
- return filteredKeys.reduce(function (acc, key) {
55
- var _a;
56
- return (__assign(__assign({}, acc), (_a = {}, _a[key] = obj[key], _a)));
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;
@@ -42,6 +41,6 @@ type State = {
42
41
  type Props = SpreadsheetProps & {
43
42
  children: JSX.Element;
44
43
  };
45
- export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, getSortCompareFn, }: Props) => JSX.Element;
44
+ export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, getSortCompareFn, }: Props) => JSX.Element;
46
45
  export declare const useSpreadsheetContext: () => State;
47
46
  export {};
@@ -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, highlightFirstRow = _a.highlightFirstRow, 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;
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];
@@ -66,7 +66,11 @@ export var SpreadsheetContextProvider = function (_a) {
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
68
  addRowTimeoutRef.current = setTimeout(function () {
69
- var highestRowIndex = Math.max.apply(Math, Object.values(dataSet).map(function (obj) { return obj._meta.rowIndex; }));
69
+ var _a, _b;
70
+ var highestRowIndex = -1;
71
+ for (var key in dataSet)
72
+ if (((_b = (_a = dataSet[key]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.rowIndex) > highestRowIndex)
73
+ highestRowIndex = dataSet[key]._meta.rowIndex;
70
74
  var newRow = addMeta({}, highestRowIndex + 1);
71
75
  setDataSet(function (oldValues) {
72
76
  var _a;
@@ -161,7 +165,7 @@ export var SpreadsheetContextProvider = function (_a) {
161
165
  return updatedData;
162
166
  });
163
167
  }, [dataSet, dataSnapshot]);
164
- var value = __assign(__assign({ data: updatedDataSnapshot, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, highlightFirstRow: highlightFirstRow, options: options, recordsWithValuesCount: recordsWithValuesCount, filteredDataCount: filteredDataCount, sortBy: sortBy, warnings: warnings, errors: errors, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: handleDeleteErrors, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef, addNewRowsToSpreadsheet: addNewRowsToSpreadsheet, spreadsheetFilter: spreadsheetFilter, resetSpreadsheetFilter: resetSpreadsheetFilter, filterRecordsByRowType: filterRecordsByRowType, filterRecordsByFieldErrors: filterRecordsByFieldErrors, checkboxColumnWidth: checkboxColumnWidth, setSortBy: setSortBy, isFiltering: isFiltering });
168
+ var value = __assign(__assign({ data: updatedDataSnapshot, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, options: options, recordsWithValuesCount: recordsWithValuesCount, filteredDataCount: filteredDataCount, sortBy: sortBy, warnings: warnings, errors: errors, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: handleDeleteErrors, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef, addNewRowsToSpreadsheet: addNewRowsToSpreadsheet, spreadsheetFilter: spreadsheetFilter, resetSpreadsheetFilter: resetSpreadsheetFilter, filterRecordsByRowType: filterRecordsByRowType, filterRecordsByFieldErrors: filterRecordsByFieldErrors, checkboxColumnWidth: checkboxColumnWidth, setSortBy: setSortBy, isFiltering: isFiltering });
165
169
  return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
166
170
  };
167
171
  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
- declare const _default: React.MemoExoticComponent<() => JSX.Element>;
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,17 @@ 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
44
  var canShowCheckboxOnCheckboxRowHover = currentStepIndex === 2;
45
45
  var rowNumbersGridRef = useRef();
46
46
  var rowCheckboxesGridRef = useRef();
47
+ useEffect(function () {
48
+ if (data.length > 0 && options.withSingleRowSelect)
49
+ setSelectedRows([data === null || data === void 0 ? void 0 : data[0]._meta.id]);
50
+ }, [options.withSingleRowSelect]);
47
51
  var rowWidthScalingFactor = (function () {
48
52
  // Spreadsheet will display 6 columns on the viewport and a small portion of the
49
53
  // 7th column in the right side to let the user know they can scroll horizontally
@@ -100,6 +104,7 @@ var SpreadsheetData = function () {
100
104
  }, [dataLength]);
101
105
  var showValidationProgress = !isReadOnly && validationPercentage < 100;
102
106
  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, dflex: true, h100: true }, { children: [(options === null || options === void 0 ? void 0 : options.showCheckboxColumn) && (_jsx(SpreadsheetRowCheckboxes, { gridRef: rowCheckboxesGridRef, height: spreadsheetHeight, firstRowIsHeader: options === null || options === void 0 ? void 0 : options.firstRowIsHeader, isLoadingData: showValidationProgress })), _jsx(S.TableView, { tableHeadersHeight: spreadsheetHeaderHeightPx, highlightFirstRow: isReadOnly, rowHeight: spreadsheetRowHeightPx, h: null, rowWidthScalingFactor: rowWidthScalingFactor, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey, checkboxColumnWidth: checkboxColumnWidth, isFiltering: isFiltering })] }))] }))] })));
107
+ 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) ||
108
+ 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, rowWidthScalingFactor: rowWidthScalingFactor, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey, checkboxColumnWidth: checkboxColumnWidth, isFiltering: isFiltering })] }))] }))] })));
104
109
  };
105
110
  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, firstRowIsHeader, isLoadingData, ...props }: Props) => JSX.Element;
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, _b = _a.firstRowIsHeader, firstRowIsHeader = _b === void 0 ? false : _b, isLoadingData = _a.isLoadingData, props = __rest(_a, ["height", "gridRef", "firstRowIsHeader", "isLoadingData"]);
66
- var _c = useSpreadsheetContext(), data = _c.data, selectedRows = _c.selectedRows, lastClickedIndexRef = _c.lastClickedIndexRef, setSelectedRows = _c.setSelectedRows, checkboxColumnWidth = _c.checkboxColumnWidth;
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
- // If the first row is a header, we need to adjust the rowIndex
79
- var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
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[adjustedRowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id], false); });
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[adjustedRowIndex]) === null || _a === void 0 ? void 0 : _a._meta) === null || _b === void 0 ? void 0 : _b.id); });
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, adjustedRowIndex = _a.adjustedRowIndex;
148
- var currentDataIndex = rowIndex === 0 ? 0 : adjustedRowIndex;
149
- var rowMetaId = (_c = (_b = data[currentDataIndex]) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.id;
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 () { return handleSelectMultipleRows(rowIndex); }, style: { cursor: "pointer" }, isDisabled: isLoadingData })) })));
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
- var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
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, highlightFirstRow, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: import("../../../common/Table/TableView/types").TableViewProps) => JSX.Element>, import("styled-components").DefaultTheme, {}, never>;
9
+ export declare const TableView: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, 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,27 @@ export var ImporterContextProvider = function (_a) {
99
100
  return acc;
100
101
  }, []);
101
102
  }
102
- return (_a = uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
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]);
106
107
  useEffect(function () {
107
- if (!templateHeaderMatchings)
108
+ var setHeadersFromDataset = function () {
109
+ var _templateHeaderMatchings = {};
110
+ var fuse = new Fuse(uploadedDataHeaders, fusejsOptions);
111
+ templateHeaders.forEach(function (templateHeader, _index) {
112
+ var _a;
113
+ var fuseResults = fuse.search(templateHeader.label);
114
+ _templateHeaderMatchings[templateHeader.label] = (_a = fuseResults[0]) === null || _a === void 0 ? void 0 : _a.item;
115
+ });
116
+ setTemplateHeaderMatchings(_templateHeaderMatchings);
117
+ };
118
+ if (uploadedDataHeaders) {
119
+ setHeadersFromDataset();
120
+ }
121
+ }, [uploadedDataHeaders]);
122
+ useEffect(function () {
123
+ if (!templateHeaderMatchings || !uploadedDataHeaders)
108
124
  return;
109
125
  var _uploadedDataEnumFieldValues = {};
110
126
  var templateLabels = Object.keys(templateHeaderMatchings);
@@ -117,7 +133,7 @@ export var ImporterContextProvider = function (_a) {
117
133
  var columnIndex = uploadedDataHeaders.indexOf(uploadedDataHeader);
118
134
  if (columnIndex === -1)
119
135
  return;
120
- uploadedData.slice(1).forEach(function (row) {
136
+ uploadedData === null || uploadedData === void 0 ? void 0 : uploadedData.slice(headerRowIndex + 1).forEach(function (row) {
121
137
  var uploadedValue = row[columnIndex];
122
138
  enumFieldValues.add(uploadedValue);
123
139
  });
@@ -126,12 +142,7 @@ export var ImporterContextProvider = function (_a) {
126
142
  });
127
143
  });
128
144
  setUploadedDataEnumFieldValues(_uploadedDataEnumFieldValues);
129
- }, [templateHeaderMatchings]);
130
- useEffect(function () {
131
- if (uploadedData) {
132
- setHeadersFromDataset();
133
- }
134
- }, [uploadedData]);
145
+ }, [templateHeaderMatchings, uploadedDataHeaders]);
135
146
  useEffect(function () {
136
147
  (function () { return __awaiter(void 0, void 0, void 0, function () {
137
148
  var _a, organization_1, columns_1, importer_style_preferences, integrations_1, preview_first_time, error_1, errorMsg;
@@ -191,16 +202,6 @@ export var ImporterContextProvider = function (_a) {
191
202
  setCurrentStepIndex(2);
192
203
  }
193
204
  };
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
205
  var inTrialMode = organization === null || organization === void 0 ? void 0 : organization.trial_mode;
205
206
  var value = {
206
207
  initialRecords: initialRecords,
@@ -222,6 +223,8 @@ export var ImporterContextProvider = function (_a) {
222
223
  logoURL: style.logoURL,
223
224
  integrations: integrations,
224
225
  previewFirstTime: previewFirstTime,
226
+ headerRowIndex: headerRowIndex,
227
+ setHeaderRowIndex: setHeaderRowIndex,
225
228
  setUploadedData: setUploadedData,
226
229
  formatRecord: formatRecord,
227
230
  setCurrentStepIndex: setCurrentStepIndex,
@@ -85,17 +85,14 @@ export var transformToRecords = function (_a) {
85
85
  });
86
86
  return formatRecord ? formatRecord(record) : record;
87
87
  };
88
- return uploadedData.slice(1).map(getRecord);
88
+ return uploadedData.map(getRecord);
89
89
  };
90
90
  export var getPreviewDataSet = function (_a) {
91
91
  var uploadedData = _a.uploadedData;
92
- var getFirstRowLen = function () {
93
- if (uploadedData.length > 0 && Array.isArray(uploadedData[0])) {
94
- return uploadedData[0].length;
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
- //Showing only the first 100 rows to improve performance
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
- return (_jsxs(Div, __assign({ dflex: true, clickable: true, onClick: onClick }, { 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 })) }))] })));
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;
@@ -7,7 +7,7 @@ type TableViewRowProps = {
7
7
  isLast: boolean;
8
8
  };
9
9
  export declare const TableViewRow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps & TableViewRowProps, never>;
10
- type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"> & {
10
+ type Props = Pick<TableViewProps, "columns" | "onRowClick"> & {
11
11
  row: any;
12
12
  rowWidth: number;
13
13
  indexI: number;
@@ -15,5 +15,5 @@ type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"
15
15
  getItemKey?: (row: any) => string;
16
16
  isRowSelected?: boolean;
17
17
  } & DivCSSProps;
18
- export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey, rowWidth, isRowSelected, ...props }: Props) => JSX.Element;
18
+ export declare const TableRow: ({ row, indexI, columns, isLast, onRowClick, getItemKey, rowWidth, isRowSelected, ...props }: Props) => JSX.Element;
19
19
  export {};
@@ -40,11 +40,11 @@ export var TableViewRow = styled(Div)(templateObject_3 || (templateObject_3 = __
40
40
  return p.isHighlighted && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "], ["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "])), p.theme.colors.blue100, p.theme.colors.blue500, p.theme.colors.gray1000);
41
41
  });
42
42
  export var TableRow = function (_a) {
43
- var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, highlightFirstRow = _a.highlightFirstRow, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, rowWidth = _a.rowWidth, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "highlightFirstRow", "onRowClick", "getItemKey", "rowWidth", "isRowSelected"]);
44
- var isHighlighted = (indexI === 0 && highlightFirstRow) || isRowSelected;
45
- return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
43
+ var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, rowWidth = _a.rowWidth, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "onRowClick", "getItemKey", "rowWidth", "isRowSelected"]);
44
+ var isHighlighted = isRowSelected;
45
+ var key = getItemKey ? getItemKey(row) : "".concat(indexI);
46
+ return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), id: "row-id-".concat(key), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
46
47
  var Content = column.Content;
47
- var key = getItemKey ? getItemKey(row) : "".concat(indexI);
48
48
  var resolvedKey = "column-".concat(indexJ, "-row-").concat(key);
49
49
  var columnWidthPercentages = getColumnWidthsPx(columns, rowWidth);
50
50
  var columnWidthPercentage = columnWidthPercentages[indexJ];