fuse-importer 0.25.9 → 0.26.1

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 (80) hide show
  1. package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +11 -1
  2. package/lib/esm/Importer/Review/ReviewWithContext.js +4 -8
  3. package/lib/esm/Importer/Uploader/HeadersPreview.js +5 -9
  4. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +3 -3
  5. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +35 -12
  6. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +28 -2
  7. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
  8. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +21 -10
  9. package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +4 -2
  10. package/lib/esm/Importer/common/Spreadsheet/hooks.js +5 -68
  11. package/lib/esm/Importer/common/Spreadsheet/index.d.ts +1 -2
  12. package/lib/esm/Importer/common/Spreadsheet/index.js +2 -2
  13. package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
  14. package/lib/esm/Importer/common/Spreadsheet/styles.js +2 -2
  15. package/lib/esm/Importer/common/index.js +1 -1
  16. package/lib/esm/Importer/common/utils.d.ts +4 -1
  17. package/lib/esm/Importer/common/utils.js +15 -4
  18. package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +2 -1
  19. package/lib/esm/Importer/contexts/ImporterContextProvider.js +27 -7
  20. package/lib/esm/Importer/data/index.d.ts +7 -2
  21. package/lib/esm/Importer/data/index.js +18 -10
  22. package/lib/esm/Importer/index.d.ts +3 -2
  23. package/lib/esm/Importer/index.js +2 -4
  24. package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +10 -25
  25. package/lib/esm/common/Table/TableActions/ExportData.js +3 -1
  26. package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.d.ts +1 -0
  27. package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +37 -0
  28. package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.d.ts +6 -0
  29. package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
  30. package/lib/esm/common/Table/TableActions/FilterByErrors/functions.d.ts +11 -0
  31. package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
  32. package/lib/esm/common/Table/TableActions/FilterByErrors/index.d.ts +1 -0
  33. package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
  34. package/lib/esm/common/Table/TableActions/SearchRows.js +3 -1
  35. package/lib/esm/common/Table/TableActions/TableActions.js +2 -1
  36. package/lib/esm/common/Table/TableActions/TableActions.styles.js +1 -1
  37. package/lib/esm/common/Table/TableActions/hooks.d.ts +20 -0
  38. package/lib/esm/common/Table/TableActions/hooks.js +96 -0
  39. package/lib/esm/common/Table/TableView/TableHeaders.d.ts +6 -8
  40. package/lib/esm/common/Table/TableView/TableHeaders.js +15 -14
  41. package/lib/esm/common/Table/TableView/{TableRow.d.ts → TableRows/TableRow.d.ts} +5 -5
  42. package/lib/esm/common/Table/TableView/{TableRow.js → TableRows/TableRow.js} +9 -6
  43. package/lib/esm/common/Table/TableView/TableRows/index.d.ts +4 -0
  44. package/lib/esm/common/Table/TableView/{TableCells.js → TableRows/index.js} +13 -11
  45. package/lib/esm/common/Table/TableView/common/index.d.ts +5 -0
  46. package/lib/esm/common/Table/TableView/{common.js → common/index.js} +18 -5
  47. package/lib/esm/common/Table/TableView/index.d.ts +4 -39
  48. package/lib/esm/common/Table/TableView/index.js +48 -65
  49. package/lib/esm/common/Table/TableView/types.d.ts +37 -0
  50. package/lib/esm/common/Table/TableView/types.js +1 -0
  51. package/lib/esm/common/Table/index.d.ts +2 -2
  52. package/lib/esm/common/Table/index.js +20 -16
  53. package/lib/esm/common/columnsValidations.d.ts +45 -0
  54. package/lib/esm/common/columnsValidations.js +351 -0
  55. package/lib/esm/common/index.d.ts +1 -0
  56. package/lib/esm/common/index.js +1 -0
  57. package/lib/esm/common/inputs/Autocomplete.d.ts +2 -1
  58. package/lib/esm/common/inputs/Autocomplete.js +2 -2
  59. package/lib/esm/common/inputs/SelectMenu.d.ts +1 -1
  60. package/lib/esm/common/inputs/SelectMenu.js +17 -9
  61. package/lib/esm/index.d.ts +4 -1
  62. package/lib/esm/index.js +56 -10
  63. package/lib/esm/locales/de.d.ts +20 -0
  64. package/lib/esm/locales/de.js +20 -0
  65. package/lib/esm/locales/en.d.ts +20 -0
  66. package/lib/esm/locales/en.js +20 -0
  67. package/lib/esm/locales/es.d.ts +20 -0
  68. package/lib/esm/locales/es.js +20 -0
  69. package/lib/esm/locales/fr.d.ts +20 -0
  70. package/lib/esm/locales/fr.js +20 -0
  71. package/lib/esm/types.d.ts +53 -1
  72. package/lib/esm/types.js +31 -0
  73. package/lib/esm/utils/index.d.ts +10 -0
  74. package/lib/esm/utils/index.js +31 -0
  75. package/lib/main.js +23 -23
  76. package/package.json +3 -2
  77. package/lib/esm/Importer/useFullscreenOverlay.d.ts +0 -1
  78. package/lib/esm/Importer/useFullscreenOverlay.js +0 -14
  79. package/lib/esm/common/Table/TableView/TableCells.d.ts +0 -4
  80. package/lib/esm/common/Table/TableView/common.d.ts +0 -9
@@ -42,7 +42,17 @@ export var EnumFieldMatcher = function (_a) {
42
42
  index: index,
43
43
  isMatched: !!enumFieldValueMatching[uploadedDataValue],
44
44
  }); })
45
- .sort(function (a, b) { return (b.isMatched ? 1 : -1); }));
45
+ .sort(function (a, b) {
46
+ if (a.isMatched === b.isMatched) {
47
+ return a.index - b.index;
48
+ }
49
+ else if (a.isMatched) {
50
+ return -1;
51
+ }
52
+ else {
53
+ return 1;
54
+ }
55
+ }));
46
56
  //sort data based on automatched items
47
57
  var sortedData = dataSortingOrderRef.current.map(function (sorting) { return data[sorting.index]; });
48
58
  var tableRowHeight = 100;
@@ -14,23 +14,19 @@ var __assign = (this && this.__assign) || function () {
14
14
  return __assign.apply(this, arguments);
15
15
  };
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
- import { useImporterContext } from "../contexts/ImporterContextProvider";
17
+ import { useTranslation } from "react-i18next";
18
+ import styled from "styled-components";
18
19
  import { Div } from "../../styled/utils";
19
20
  import Spreadsheet from "../common/Spreadsheet";
20
- import { getSpreadsheetRowWidth } from "../common/utils";
21
+ import { useImporterContext } from "../contexts/ImporterContextProvider";
21
22
  import { AppResponseModal } from "./AppResponseModal";
22
23
  import { useReviewContext } from "./ReviewContextProvider";
23
- import styled from "styled-components";
24
- import { useTranslation } from "react-i18next";
25
- import useWindowDimensions from "../../utils/hooks/useWindowSize";
26
24
  var TitleContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
27
25
  var ReviewWithContext = function () {
28
26
  var _a = useReviewContext(), fields = _a.reviewFields, initialDataSet = _a.reviewInitialDataSet, options = _a.options, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged;
29
- var isOnSmallScreens = useWindowDimensions().isOnSmallScreens;
30
27
  var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows, isUsingManualImport = _b.isUsingManualImport;
31
28
  var t = useTranslation("review").t;
32
- var rowWidth = getSpreadsheetRowWidth(fields, isOnSmallScreens ? 3 : 6);
33
- var spreadsheetUI = initialDataSet && (_jsx(Spreadsheet, { options: __assign(__assign({}, options), { showCheckboxColumn: true }), selectedRows: selectedRows, setSelectedRows: setSelectedRows, initialDataSet: initialDataSet, fields: fields, rowWidth: rowWidth, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged }));
29
+ var spreadsheetUI = initialDataSet && (_jsx(Spreadsheet, { options: __assign(__assign({}, options), { showCheckboxColumn: true }), selectedRows: selectedRows, setSelectedRows: setSelectedRows, initialDataSet: initialDataSet, fields: fields, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged }));
34
30
  return (_jsxs(Div, __assign({ centered: true, flexColumn: true, h100: true }, { children: [_jsx(AppResponseModal, {}), _jsxs(Div, __assign({ w100: true, h100: true, flexColumn: true }, { children: [_jsx(TitleContainer, __assign({ flexColumn: true, ml: 32 }, { children: _jsx(Div, __assign({ h2: true, mt: 40, mb: 40 }, { children: t(isUsingManualImport.current ? "manual_importer_title" : "title") })) })), _jsx(Div, __assign({ h100: true, w100: true, justifyCenter: true }, { children: spreadsheetUI }))] }))] })));
35
31
  };
36
32
  export default ReviewWithContext;
@@ -14,24 +14,20 @@ var __assign = (this && this.__assign) || function () {
14
14
  return __assign.apply(this, arguments);
15
15
  };
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { useTranslation } from "react-i18next";
18
+ import styled from "styled-components";
17
19
  import { Div } from "../../styled/utils";
18
- import Spreadsheet from "../common/Spreadsheet";
19
- import { getSpreadsheetRowWidth } from "../common/utils";
20
20
  import { useReviewContext } from "../Review/ReviewContextProvider";
21
- import { HeaderButtons } from "./HeaderButtons";
21
+ import Spreadsheet from "../common/Spreadsheet";
22
22
  import { useImporterContext } from "../contexts/ImporterContextProvider";
23
- import { useTranslation } from "react-i18next";
24
- import styled from "styled-components";
25
- import useWindowDimensions from "../../utils/hooks/useWindowSize";
23
+ import { HeaderButtons } from "./HeaderButtons";
26
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"])));
27
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"])));
28
26
  var HeadersPreview = function () {
29
27
  var _a = useReviewContext(), fields = _a.previewFields, initialDataSet = _a.previewInitialDataSet;
30
- var isOnSmallScreens = useWindowDimensions().isOnSmallScreens;
31
28
  var t = useTranslation("upload").t;
32
29
  var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows;
33
- var rowWidth = getSpreadsheetRowWidth(fields, isOnSmallScreens ? 3 : 6);
34
- 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, { rowWidth: rowWidth, isReadOnly: true, initialDataSet: initialDataSet, fields: fields, highlightFirstRow: true, options: {
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: {
35
31
  showCheckboxColumn: true,
36
32
  firstRowIsHeader: true,
37
33
  }, selectedRows: selectedRows, setSelectedRows: setSelectedRows })) }))] })));
@@ -5,7 +5,6 @@ import { ValidationState } from "./hooks";
5
5
  export type OnDataSetChanged = (dataSet: RecordDataSet) => void;
6
6
  export type OnValidationStateChanged = (state: ValidationState) => void;
7
7
  type State = {
8
- rowWidth?: number;
9
8
  data: Record[];
10
9
  fields: Field[];
11
10
  isLoading: boolean;
@@ -24,13 +23,14 @@ type State = {
24
23
  lastClickedIndexRef: React.MutableRefObject<number | null>;
25
24
  filteredInputValue: string;
26
25
  setFilteredInputValue: React.Dispatch<React.SetStateAction<string>>;
26
+ selectedErrorToFilter: string;
27
+ setSelectedErrorToFilter: React.Dispatch<React.SetStateAction<string>>;
27
28
  addNewRowsToSpreadsheet: () => void;
28
29
  checkboxColumnWidth: number;
29
30
  isFiltering: boolean;
30
31
  } & ValidationState;
31
32
  type Props = {
32
33
  initialDataSet: RecordDataSet;
33
- rowWidth?: number;
34
34
  isReadOnly?: boolean;
35
35
  children: JSX.Element;
36
36
  fields: Field[];
@@ -42,6 +42,6 @@ type Props = {
42
42
  selectedRows: string[];
43
43
  setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
44
44
  };
45
- export declare const SpreadsheetContextProvider: ({ initialDataSet, rowWidth, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: Props) => JSX.Element;
45
+ export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: Props) => JSX.Element;
46
46
  export declare const useSpreadsheetContext: () => State;
47
47
  export {};
@@ -23,16 +23,17 @@ 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 { useValidationState } from "./hooks";
27
26
  import { addMeta } from "../../../Importer/data";
27
+ import { useValidationState } from "./hooks";
28
28
  var SpreadsheetContext = createContext({});
29
29
  export var SpreadsheetContextProvider = function (_a) {
30
- var initialDataSet = _a.initialDataSet, _b = _a.rowWidth, rowWidth = _b === void 0 ? 1 : _b, fields = _a.fields, options = _a.options, isReadOnly = _a.isReadOnly, highlightFirstRow = _a.highlightFirstRow, children = _a.children, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows;
31
- var _c = useState(initialDataSet), dataSet = _c[0], setDataSet = _c[1];
32
- var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
33
- var _e = useState(null), sortByFieldErrors = _e[0], setSortByFieldErrors = _e[1];
34
- var _f = useState(null), sortByFieldWarnings = _f[0], setSortByFieldWarnings = _f[1];
35
- var _g = useState(""), filteredInputValue = _g[0], setFilteredInputValue = _g[1];
30
+ 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;
31
+ var _b = useState(initialDataSet), dataSet = _b[0], setDataSet = _b[1];
32
+ var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
33
+ var _d = useState(null), sortByFieldErrors = _d[0], setSortByFieldErrors = _d[1];
34
+ var _e = useState(null), sortByFieldWarnings = _e[0], setSortByFieldWarnings = _e[1];
35
+ var _f = useState(""), filteredInputValue = _f[0], setFilteredInputValue = _f[1];
36
+ var _g = useState(""), selectedErrorToFilter = _g[0], setSelectedErrorToFilter = _g[1];
36
37
  var sortByCurrentErrorsRef = useRef({});
37
38
  var sortByCurrentWarningsRef = useRef({});
38
39
  var _h = useValidationState({
@@ -44,7 +45,7 @@ export var SpreadsheetContextProvider = function (_a) {
44
45
  setDataSet: setDataSet,
45
46
  setIsLoading: setIsLoading,
46
47
  onValidateRecord: onValidateRecord,
47
- }), errorsRef = _h.errorsRef, warningsRef = _h.warningsRef, updateRecordAndRevalidate = _h.updateRecordAndRevalidate, deleteRecords = _h.deleteRecords, filterRecordsBySearchValue = _h.filterRecordsBySearchValue, validationState = __rest(_h, ["errorsRef", "warningsRef", "updateRecordAndRevalidate", "deleteRecords", "filterRecordsBySearchValue"]);
48
+ }), errorsRef = _h.errorsRef, warningsRef = _h.warningsRef, updateRecordAndRevalidate = _h.updateRecordAndRevalidate, deleteRecords = _h.deleteRecords, filterRecordsBySearchValue = _h.filterRecordsBySearchValue, filterRecordsByError = _h.filterRecordsByError, validationState = __rest(_h, ["errorsRef", "warningsRef", "updateRecordAndRevalidate", "deleteRecords", "filterRecordsBySearchValue", "filterRecordsByError"]);
48
49
  var addNewRowsToSpreadsheet = useCallback(function () {
49
50
  var highestRowIndex = Math.max.apply(Math, Object.values(dataSet).map(function (obj) { return obj._meta.rowIndex; }));
50
51
  var newRow = addMeta({}, highestRowIndex + 1);
@@ -53,10 +54,26 @@ export var SpreadsheetContextProvider = function (_a) {
53
54
  return (__assign(__assign({}, oldValues), (_a = {}, _a[newRow._meta.id] = newRow, _a)));
54
55
  });
55
56
  }, [dataSet]);
57
+ var handleDeleteErrors = useCallback(function (selectedRows) {
58
+ var errors = errorsRef.current;
59
+ var warnings = errorsRef.current;
60
+ var selectedRecordsLength = selectedRows.length;
61
+ var dataSetLength = Object.keys(dataSet).length - 1;
62
+ var isDeletingAllRows = selectedRecordsLength === dataSetLength;
63
+ deleteRecords(setDataSet, selectedRows, errors, warnings, isDeletingAllRows);
64
+ }, [dataSet, errorsRef.current, errorsRef.current]);
56
65
  // sort data based on errors (errors group on top and not errors group at bottom)
57
66
  var data = useMemo(function () {
58
- var filteredObj = filterRecordsBySearchValue(dataSet, filteredInputValue);
59
- var dataSetValues = Object.values(filteredInputValue ? filteredObj : dataSet);
67
+ var filteredDatasetByString = filteredInputValue
68
+ ? filterRecordsBySearchValue(dataSet, filteredInputValue, fields)
69
+ : dataSet;
70
+ var filteredDatasetByError = selectedErrorToFilter
71
+ ? filterRecordsByError(filteredDatasetByString, selectedErrorToFilter, errorsRef.current, fields)
72
+ : filteredDatasetByString;
73
+ var dataSetValues = Object.values(filteredDatasetByError);
74
+ if (dataSetValues.length === 0) {
75
+ setSelectedErrorToFilter("");
76
+ }
60
77
  var errors = sortByCurrentErrorsRef.current; //Sort errors snapshot
61
78
  var warnings = sortByCurrentWarningsRef.current; //Sort warnings snapshot
62
79
  if (!sortByFieldErrors && !sortByFieldWarnings)
@@ -69,7 +86,13 @@ export var SpreadsheetContextProvider = function (_a) {
69
86
  }
70
87
  return bHasErrors ? 1 : -1;
71
88
  });
72
- }, [dataSet, filteredInputValue, sortByFieldErrors, sortByFieldWarnings]);
89
+ }, [
90
+ dataSet,
91
+ filteredInputValue,
92
+ selectedErrorToFilter,
93
+ sortByFieldErrors,
94
+ sortByFieldWarnings,
95
+ ]);
73
96
  var isFiltering = useMemo(function () { return !!filteredInputValue; }, [filteredInputValue]);
74
97
  useEffect(function () {
75
98
  onDataSetChanged && onDataSetChanged(dataSet);
@@ -112,7 +135,7 @@ export var SpreadsheetContextProvider = function (_a) {
112
135
  var baseCheckboxColumnWidth = lastRowIndexLength * singleLetterWidth + horizontalSpacing;
113
136
  return baseCheckboxColumnWidth < 40 ? 40 : baseCheckboxColumnWidth;
114
137
  }, [data]);
115
- var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, rowWidth: rowWidth, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, highlightFirstRow: highlightFirstRow, options: options, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: deleteRecords, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef, addNewRowsToSpreadsheet: addNewRowsToSpreadsheet, checkboxColumnWidth: checkboxColumnWidth, isFiltering: isFiltering });
138
+ var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, sortByFieldErrors: sortByFieldErrors, sortByFieldWarnings: sortByFieldWarnings, highlightFirstRow: highlightFirstRow, options: options, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, setSortByFieldWarnings: handleSortByFieldWarnings, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows, deleteRecords: handleDeleteErrors, filteredInputValue: filteredInputValue, setFilteredInputValue: setFilteredInputValue, lastClickedIndexRef: lastClickedIndexRef, addNewRowsToSpreadsheet: addNewRowsToSpreadsheet, checkboxColumnWidth: checkboxColumnWidth, selectedErrorToFilter: selectedErrorToFilter, setSelectedErrorToFilter: setSelectedErrorToFilter, isFiltering: isFiltering });
116
139
  return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
117
140
  };
118
141
  export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
@@ -35,13 +35,39 @@ import { SpreadsheetRowCheckboxes } from "./SpreadsheetRowCheckboxes";
35
35
  import ValidationProgress from "./ValidationProgress";
36
36
  import { TableActions } from "../../../../common/Table/TableActions";
37
37
  import { useImporterContext } from "../../../../Importer/contexts/ImporterContextProvider";
38
+ import useWindowDimensions from "../../../../utils/hooks/useWindowSize";
38
39
  var getItemKey = function (record) { return record._meta.id; };
39
40
  var SpreadsheetData = function () {
40
- var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, rowWidth = _a.rowWidth, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options, setSortByFieldWarnings = _a.setSortByFieldWarnings, selectedRows = _a.selectedRows, checkboxColumnWidth = _a.checkboxColumnWidth, isFiltering = _a.isFiltering;
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;
41
42
  var currentStepIndex = useImporterContext().currentStepIndex;
43
+ var isOnSmallScreens = useWindowDimensions().isOnSmallScreens;
42
44
  var canShowCheckboxOnCheckboxRowHover = currentStepIndex === 2;
43
45
  var rowNumbersGridRef = useRef();
44
46
  var rowCheckboxesGridRef = useRef();
47
+ var rowWidthScalingFactor = (function () {
48
+ // Spreadsheet will display 6 columns on the viewport and a small portion of the
49
+ // 7th column in the right side to let the user know they can scroll horizontally
50
+ var visibleColumnsOnTableViewport = 6;
51
+ // by multiplying by horizontalScrollVisibilityRatio the final rowWidth for the spreadsheet
52
+ // will be reduced in order to partially display the last column on the right side
53
+ // 0.95 was chosen because it's the ratio that looks better on the UI on desktop
54
+ // 0.9 was chosen because it's the ratio that looks better on the UI on mobile
55
+ var horizontalScrollVisibilityRatio = 0.95;
56
+ if (isOnSmallScreens) {
57
+ // When the screen is too small the Spreadsheet will display 3 columns on the viewport
58
+ // and a small portion of the 4th column in the right side to let the user know they can scroll horizontally
59
+ visibleColumnsOnTableViewport = 3;
60
+ horizontalScrollVisibilityRatio = 0.9;
61
+ }
62
+ var res = fields.length / visibleColumnsOnTableViewport;
63
+ if (res <= 1)
64
+ return 1;
65
+ /*
66
+ multiply the rowWidthScalingFactor by 0.95/0.9 to let the user know they can scroll
67
+ horizontally (will display partial column on the right)
68
+ */
69
+ return res * horizontalScrollVisibilityRatio;
70
+ })();
45
71
  var sortByErrors = useCallback(function (field) {
46
72
  return setSortByFieldErrors(function (sortByFieldErrors) {
47
73
  return sortByFieldErrors === field ? null : field;
@@ -84,6 +110,6 @@ var SpreadsheetData = function () {
84
110
  }, [dataLength]);
85
111
  var showValidationProgress = !isReadOnly && validationPercentage < 100;
86
112
  var isReviewStep = currentStepIndex === 2;
87
- 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, spreadsheetHasXScroll: rowWidth > 1, height: spreadsheetHeight, firstRowIsHeader: options === null || options === void 0 ? void 0 : options.firstRowIsHeader, isLoadingData: showValidationProgress })), _jsx(S.TableView, { tableHeadersHeight: spreadsheetHeaderHeightPx, highlightFirstRow: isReadOnly, rowHeight: spreadsheetRowHeightPx, h: spreadsheetHeight, rowWidth: rowWidth, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey, shouldHaveCustomScrollbar: true, checkboxColumnWidth: checkboxColumnWidth, isFiltering: isFiltering })] }))] }))] })));
113
+ 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 })] }))] }))] })));
88
114
  };
89
115
  export default React.memo(SpreadsheetData, areEqual);
@@ -2,10 +2,9 @@ import React from "react";
2
2
  import { DivCSSProps } from "../../../../styled/utils";
3
3
  type Props = {
4
4
  height?: number;
5
- spreadsheetHasXScroll?: boolean;
6
5
  gridRef: React.MutableRefObject<any>;
7
6
  firstRowIsHeader?: boolean;
8
7
  isLoadingData?: boolean;
9
8
  } & DivCSSProps;
10
- export declare const SpreadsheetRowCheckboxes: ({ height, spreadsheetHasXScroll, gridRef, firstRowIsHeader, isLoadingData, ...props }: Props) => JSX.Element;
9
+ export declare const SpreadsheetRowCheckboxes: ({ height, gridRef, firstRowIsHeader, isLoadingData, ...props }: Props) => JSX.Element;
11
10
  export {};
@@ -62,19 +62,20 @@ var rowIsEmpty = function (row) {
62
62
  });
63
63
  };
64
64
  export var SpreadsheetRowCheckboxes = function (_a) {
65
- var height = _a.height, spreadsheetHasXScroll = _a.spreadsheetHasXScroll, gridRef = _a.gridRef, _b = _a.firstRowIsHeader, firstRowIsHeader = _b === void 0 ? false : _b, isLoadingData = _a.isLoadingData, props = __rest(_a, ["height", "spreadsheetHasXScroll", "gridRef", "firstRowIsHeader", "isLoadingData"]);
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
66
  var _c = useSpreadsheetContext(), data = _c.data, selectedRows = _c.selectedRows, lastClickedIndexRef = _c.lastClickedIndexRef, setSelectedRows = _c.setSelectedRows, checkboxColumnWidth = _c.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
- var handleRowSelect = function (checked, rowIndex) {
73
- if (checked && rowIsEmpty(data[rowIndex])) {
74
- return;
75
- }
72
+ var handleRowSelect = function (checked, rowIndex, rowMetaId) {
73
+ var lastRowMetaId = data[data.length - 1]._meta.id;
74
+ var isLastRow = rowMetaId === lastRowMetaId;
75
+ var isSelectingRowHeader = firstRowIsHeader && rowIndex === 0;
76
+ // Prevent user from deleting the last row and
76
77
  // If the first row is a header, we don't want to select it
77
- if (firstRowIsHeader && rowIndex === 0) {
78
+ if (isSelectingRowHeader || isLastRow) {
78
79
  return;
79
80
  }
80
81
  // If the first row is a header, we need to adjust the rowIndex
@@ -98,7 +99,11 @@ export var SpreadsheetRowCheckboxes = function (_a) {
98
99
  var lastClickedIndex = lastClickedIndexRef.current;
99
100
  var rangeStartIndex_1 = Math.min(clickedRowIndex, lastClickedIndex);
100
101
  var rangeEndIndex_1 = Math.max(clickedRowIndex, lastClickedIndex);
101
- var updatedSelectedRows = selectedRows.filter(function (_, index) { return index < rangeStartIndex_1 || index > rangeEndIndex_1; });
102
+ var lastRowId_1 = data[data.length - 1]._meta.id;
103
+ var updatedSelectedRows = selectedRows.filter(function (value, index) {
104
+ return (index < rangeStartIndex_1 && value !== lastRowId_1) ||
105
+ (index > rangeEndIndex_1 && value !== lastRowId_1);
106
+ });
102
107
  setSelectedRows(updatedSelectedRows);
103
108
  }
104
109
  else {
@@ -111,7 +116,10 @@ export var SpreadsheetRowCheckboxes = function (_a) {
111
116
  var rangeEndIndex = data.indexOf(clickedRow);
112
117
  var range = data.slice(Math.min(rangeStartIndex, rangeEndIndex), Math.max(rangeStartIndex, rangeEndIndex) + 1);
113
118
  var rangeIds = range.map(function (row) { return row === null || row === void 0 ? void 0 : row._meta.id; });
114
- var updatedSelectedRows = __spreadArray(__spreadArray([], selectedRows, true), rangeIds, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
119
+ var lastRowId_2 = data[data.length - 1]._meta.id;
120
+ var updatedSelectedRows = __spreadArray(__spreadArray([], selectedRows, true), rangeIds, true).filter(function (value, index, array) {
121
+ return array.indexOf(value) === index && value !== lastRowId_2;
122
+ });
115
123
  setSelectedRows(updatedSelectedRows);
116
124
  lastClickedIndexRef.current = rowIndex;
117
125
  }
@@ -119,7 +127,10 @@ export var SpreadsheetRowCheckboxes = function (_a) {
119
127
  var handleSelectAllRows = function (checked) {
120
128
  if (checked) {
121
129
  var allRows = data
122
- .filter(function (row) { return !rowIsEmpty(row); })
130
+ .filter(function (row) {
131
+ var lastRowIndex = data[data.length - 1]._meta.id;
132
+ return row._meta.id !== lastRowIndex;
133
+ })
123
134
  .map(function (row) {
124
135
  return row === null || row === void 0 ? void 0 : row._meta.id;
125
136
  });
@@ -136,7 +147,7 @@ export var SpreadsheetRowCheckboxes = function (_a) {
136
147
  var currentDataIndex = rowIndex === 0 ? 0 : adjustedRowIndex;
137
148
  var rowMetaId = (_c = (_b = data[currentDataIndex]) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.id;
138
149
  return (_jsx(Div, __assign({ className: "checkbox-cell" }, { children: firstRowIsHeader && rowIndex === 0 ? ("") : (_jsx(Checkbox, { isChecked: rowMetaId && selectedRows.includes(rowMetaId), onChange: function (checked) {
139
- return !isLoadingData && handleRowSelect(checked, rowIndex);
150
+ return !isLoadingData && handleRowSelect(checked, rowIndex, rowMetaId);
140
151
  }, onShiftKeyPressed: function () { return handleSelectMultipleRows(rowIndex); }, style: { cursor: "pointer" }, isDisabled: isLoadingData })) })));
141
152
  };
142
153
  var RowNumbersCell = function (_a) {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { SpreadsheetOptions } from "../../..";
3
3
  import { BatchValidationErrors, Field, OnValidateRecord, Record, RecordDataSet } from "../../../types";
4
+ import { DeleteRecords, FilterRecordsByError, FilterRecordsBySearchValue } from "../../../common/Table/TableActions/hooks";
4
5
  type UseValidationStateArgs = {
5
6
  onValidateRecord?: OnValidateRecord;
6
7
  setDataSet: React.Dispatch<React.SetStateAction<RecordDataSet>>;
@@ -26,8 +27,9 @@ export type ValidationState = {
26
27
  };
27
28
  };
28
29
  type UseValidationStateReturnValue = ValidationState & {
29
- deleteRecords: (selectedRecords: string[]) => void;
30
- filterRecordsBySearchValue: (obj: RecordDataSet, value: string) => RecordDataSet;
30
+ deleteRecords: DeleteRecords;
31
+ filterRecordsBySearchValue: FilterRecordsBySearchValue;
32
+ filterRecordsByError: FilterRecordsByError;
31
33
  updateRecordAndRevalidate: (record: Record) => Promise<void>;
32
34
  errorsRef: React.MutableRefObject<BatchValidationErrors>;
33
35
  warningsRef: React.MutableRefObject<BatchValidationErrors>;
@@ -49,45 +49,10 @@ import { omit, set } from "lodash";
49
49
  import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
50
50
  import { sleep } from "../../..";
51
51
  import { selectValidatorsFor, validateRecord } from "./validation";
52
- import { addEmptyRows, recordListToDataSet } from "../../../Importer/data";
52
+ import { useTableActions, } from "../../../common/Table/TableActions/hooks";
53
53
  var checkIfHasErrors = function (errors) {
54
54
  return errors && Object.keys(errors).length > 0;
55
55
  };
56
- var removeItemsFromObject = function (obj, idsToRemove) {
57
- var _a;
58
- var idSet = new Set(idsToRemove);
59
- var newObj = {};
60
- for (var key in obj) {
61
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
62
- var meta = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta;
63
- if (meta && (meta === null || meta === void 0 ? void 0 : meta.id) && !(idSet === null || idSet === void 0 ? void 0 : idSet.has(meta === null || meta === void 0 ? void 0 : meta.id))) {
64
- newObj[key] = obj[key];
65
- }
66
- }
67
- }
68
- return newObj;
69
- };
70
- var removeErrorsOrWarningsFromObject = function (obj, keysToRemove) {
71
- var keysSet = new Set(keysToRemove);
72
- var newObj = {};
73
- for (var key in obj) {
74
- if (Object.prototype.hasOwnProperty.call(obj, key) && !(keysSet === null || keysSet === void 0 ? void 0 : keysSet.has(key))) {
75
- newObj[key] = obj[key];
76
- }
77
- }
78
- return newObj;
79
- };
80
- var isObject = function (value) {
81
- return typeof value === "object" && value !== null && !Array.isArray(value);
82
- };
83
- var includesSearchValue = function (value, searchValue) {
84
- if (typeof value === "string" || typeof value === "number") {
85
- var stringValue = String(value).toLowerCase();
86
- var searchValueLower = searchValue.toLowerCase();
87
- return stringValue.includes(searchValueLower);
88
- }
89
- return false;
90
- };
91
56
  export var useValidationState = function (_a) {
92
57
  var initialDataSet = _a.initialDataSet, //Initial Data Set, used to run the initial validation
93
58
  dataSet = _a.dataSet, //Current Updated Data Set
@@ -98,37 +63,8 @@ export var useValidationState = function (_a) {
98
63
  var validatorsCache = useMemo(function () { return selectValidatorsFor(fields); }, [fields]);
99
64
  var errorsRef = useRef(errors);
100
65
  var warningsRef = useRef(warnings);
101
- //Delete record from dataSet and from validations
102
- var deleteRecords = function (selectedRecords) {
103
- var newDataSet = removeItemsFromObject(dataSet, selectedRecords);
104
- var newErrors = removeErrorsOrWarningsFromObject(errors, selectedRecords);
105
- var newWarnings = removeErrorsOrWarningsFromObject(warnings, selectedRecords);
106
- setDataSet(newDataSet);
107
- setErrors(newErrors);
108
- setWarnings(newWarnings);
109
- };
110
- //Filter records by search value
111
- var filterRecordsBySearchValue = function (obj, value) {
112
- var filteredObj = {};
113
- for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
114
- var _b = _a[_i], key = _b[0], currentObj = _b[1];
115
- if (isObject(currentObj)) {
116
- var matches = Object.values(currentObj).some(function (propertyValue) {
117
- return includesSearchValue(propertyValue, value);
118
- });
119
- if (matches) {
120
- filteredObj[key] = currentObj;
121
- }
122
- }
123
- }
124
- // To ensure that rows are always displayed, even when the search query is empty,
125
- // we return an empty record list when the search yields no results.
126
- if (Object.keys(filteredObj).length === 0) {
127
- return recordListToDataSet(addEmptyRows([], fields), fields);
128
- }
129
- return filteredObj;
130
- };
131
- //Validate record and update dataSet
66
+ var _e = useTableActions({ setErrors: setErrors, setWarnings: setWarnings, fields: fields }), deleteRecords = _e.deleteRecords, filterRecordsByError = _e.filterRecordsByError, filterRecordsBySearchValue = _e.filterRecordsBySearchValue;
67
+ // Validate record and update dataSet
132
68
  var updateRecordAndRevalidate = useCallback(function (record) { return __awaiter(void 0, void 0, void 0, function () {
133
69
  var recordId, newDataSet, data, _a, recordErrors, recordWarnings, hasError, hasWarning;
134
70
  var _b;
@@ -173,7 +109,7 @@ export var useValidationState = function (_a) {
173
109
  }
174
110
  });
175
111
  }); }, [dataSet, validatorsCache]);
176
- //Initial data validation and update dataSet
112
+ // Initial data validation and update dataSet
177
113
  useEffect(function () {
178
114
  if (isReadOnly)
179
115
  return;
@@ -298,5 +234,6 @@ export var useValidationState = function (_a) {
298
234
  updateRecordAndRevalidate: updateRecordAndRevalidate,
299
235
  deleteRecords: deleteRecords,
300
236
  filterRecordsBySearchValue: filterRecordsBySearchValue,
237
+ filterRecordsByError: filterRecordsByError,
301
238
  };
302
239
  };
@@ -3,7 +3,6 @@ import { Field, OnValidateRecord, Record, RecordDataSet, SpreadsheetOptions } fr
3
3
  import { OnDataSetChanged, OnValidationStateChanged } from "./SpreadsheetContextProvider";
4
4
  export type SpreadsheetProps = {
5
5
  initialDataSet: RecordDataSet;
6
- rowWidth?: number;
7
6
  isReadOnly?: boolean;
8
7
  fields?: Field[];
9
8
  submittedData?: Record[];
@@ -15,7 +14,7 @@ export type SpreadsheetProps = {
15
14
  selectedRows?: string[];
16
15
  setSelectedRows?: React.Dispatch<React.SetStateAction<string[]>>;
17
16
  };
18
- declare const _default: React.MemoExoticComponent<({ isReadOnly, initialDataSet, rowWidth, fields, options, highlightFirstRow, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: SpreadsheetProps) => JSX.Element>;
17
+ declare const _default: React.MemoExoticComponent<({ isReadOnly, initialDataSet, fields, options, highlightFirstRow, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: SpreadsheetProps) => JSX.Element>;
19
18
  export default _default;
20
19
  export * from "./hooks";
21
20
  export * from "./SpreadsheetContextProvider";
@@ -15,8 +15,8 @@ import { areEqual } from "react-window";
15
15
  import SpreadsheetData from "./components/SpreadsheetData";
16
16
  import { SpreadsheetContextProvider, } from "./SpreadsheetContextProvider";
17
17
  var Spreadsheet = function (_a) {
18
- var isReadOnly = _a.isReadOnly, initialDataSet = _a.initialDataSet, rowWidth = _a.rowWidth, fields = _a.fields, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.highlightFirstRow, highlightFirstRow = _c === void 0 ? false : _c, _d = _a.onValidateRecord, onValidateRecord = _d === void 0 ? null : _d, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows;
19
- return (_jsx(SpreadsheetContextProvider, __assign({ rowWidth: rowWidth, isReadOnly: isReadOnly, fields: fields, initialDataSet: initialDataSet, highlightFirstRow: highlightFirstRow, options: options, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged, selectedRows: selectedRows, setSelectedRows: setSelectedRows }, { children: _jsx(SpreadsheetData, {}) })));
18
+ var isReadOnly = _a.isReadOnly, initialDataSet = _a.initialDataSet, fields = _a.fields, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.highlightFirstRow, highlightFirstRow = _c === void 0 ? false : _c, _d = _a.onValidateRecord, onValidateRecord = _d === void 0 ? null : _d, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged, selectedRows = _a.selectedRows, setSelectedRows = _a.setSelectedRows;
19
+ return (_jsx(SpreadsheetContextProvider, __assign({ isReadOnly: isReadOnly, fields: fields, initialDataSet: initialDataSet, highlightFirstRow: highlightFirstRow, options: options, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged, selectedRows: selectedRows, setSelectedRows: setSelectedRows }, { children: _jsx(SpreadsheetData, {}) })));
20
20
  };
21
21
  export default React.memo(Spreadsheet, areEqual);
22
22
  export * from "./hooks";
@@ -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, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, shouldHaveCustomScrollbar, checkboxColumnWidth, isFiltering, ...props }: import("../../../common/Table/TableView").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, 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>;
10
10
  export {};
@@ -6,11 +6,11 @@ import styled, { css } from "styled-components";
6
6
  import { TableView as TableViewBase, TableViewCellContainer, TableViewRow, } from "../../../common/Table/TableView";
7
7
  import { Div } from "../../../styled/utils";
8
8
  export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n width: 100%;\n"])));
9
- export var SpreadSheetWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"], ["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; }, function (_a) {
9
+ export var SpreadSheetWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-bottom: solid 1px ", ";\n border-top: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"], ["\n border-bottom: solid 1px ", ";\n border-top: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; }, function (_a) {
10
10
  var canShowCheckboxOnHover = _a.canShowCheckboxOnHover, shouldShowOnlyCheckbox = _a.shouldShowOnlyCheckbox;
11
11
  return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "], ["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "])), shouldShowOnlyCheckbox && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "], ["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "]))), !shouldShowOnlyCheckbox &&
12
12
  canShowCheckboxOnHover && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "], ["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "]))));
13
13
  });
14
14
  export var SpreadSheetContainer = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
15
- export var TableView = styled(TableViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"], ["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"])), function (p) { return p.theme.colors.gray50; }, TableViewRow, TableViewCellContainer, function (p) { return p.theme.colors.gray300; });
15
+ export var TableView = styled(TableViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0 !important;\n box-shadow: inset 0 -1px 0 ", ",\n inset -1px 0 0 ", ";\n &.last-column {\n box-shadow: inset 0 -1px 0 ", ",\n inset 1px 0 0 transparent, inset -1px 0 0 transparent !important;\n }\n }\n"], ["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0 !important;\n box-shadow: inset 0 -1px 0 ", ",\n inset -1px 0 0 ", ";\n &.last-column {\n box-shadow: inset 0 -1px 0 ", ",\n inset 1px 0 0 transparent, inset -1px 0 0 transparent !important;\n }\n }\n"])), function (p) { return p.theme.colors.gray50; }, TableViewRow, TableViewCellContainer, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.gray300; });
16
16
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -6,7 +6,7 @@ export var baseUrls = {
6
6
  production: "https://fuse.flatirons.com",
7
7
  test: "https://fuse-test.flatirons.com",
8
8
  };
9
- var MINIMUM_TABLE_HEIGHT = 375;
9
+ var MINIMUM_TABLE_HEIGHT = 100;
10
10
  export var getTableHeight = function (_a) {
11
11
  var _b = _a.headerHeight, headerHeight = _b === void 0 ? defaultTableHeaderHeightPx : _b, _c = _a.rowHeight, rowHeight = _c === void 0 ? defaultTableRowHeightPx : _c, _d = _a.maxVisibleRows, maxVisibleRows = _d === void 0 ? 7 : _d, _e = _a.minimumTableHeight, minimumTableHeight = _e === void 0 ? MINIMUM_TABLE_HEIGHT : _e, dataCount = _a.dataCount;
12
12
  return Math.max(headerHeight + rowHeight * Math.min(dataCount, maxVisibleRows + 0.5), minimumTableHeight);
@@ -1,9 +1,12 @@
1
1
  import { Integration, Record, TemplateHeader } from "../../types";
2
- export declare const getSpreadsheetRowWidth: (fields: any, visibleRowsOnTableViewport: any) => number;
3
2
  type IsEnumFieldArgs = {
4
3
  templateLabel: string;
5
4
  templateHeaders: TemplateHeader[];
6
5
  };
7
6
  export declare const getColumnType: ({ templateLabel, templateHeaders, }: IsEnumFieldArgs) => string;
8
7
  export declare const sendRecordsToIntegrations: (reviewedData: Record[], integrations: Integration[]) => Promise<void>;
8
+ type GenericRecord<T> = {
9
+ [key: string]: T;
10
+ };
11
+ export declare const verifyDuplicateValue: (array: GenericRecord<any>[], key: string, shouldThrow?: boolean, message?: string) => boolean;
9
12
  export {};
@@ -35,10 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import axios from "axios";
38
- export var getSpreadsheetRowWidth = function (fields, visibleRowsOnTableViewport) {
39
- var res = Math.ceil(fields.length / visibleRowsOnTableViewport);
40
- return res > 1 ? res : 1;
41
- };
42
38
  export var getColumnType = function (_a) {
43
39
  var _b;
44
40
  var templateLabel = _a.templateLabel, templateHeaders = _a.templateHeaders;
@@ -87,3 +83,18 @@ export var sendRecordsToIntegrations = function (reviewedData, integrations) { r
87
83
  }
88
84
  });
89
85
  }); };
86
+ export var verifyDuplicateValue = function (array, key, shouldThrow, message) {
87
+ if (shouldThrow === void 0) { shouldThrow = false; }
88
+ var uniqueValues = {};
89
+ for (var i = 0; i < array.length; i++) {
90
+ var currentValue = array[i][key];
91
+ if (uniqueValues[currentValue]) {
92
+ if (shouldThrow) {
93
+ throw new Error(message || "There is a duplicated '".concat(key, "' between your columns."));
94
+ }
95
+ return true;
96
+ }
97
+ uniqueValues[currentValue] = true;
98
+ }
99
+ return false;
100
+ };
@@ -63,6 +63,7 @@ export type Props = {
63
63
  onSubmit: OnSubmit;
64
64
  formatRecord: FormatRecord;
65
65
  onValidateRecord?: OnValidateRecord;
66
+ dynamicColumns: TemplateHeader[] | null;
66
67
  };
67
- export declare const ImporterContextProvider: ({ templateSlug, apiToken, children, options, onSubmit, onClose, formatRecord, onValidateRecord, }: Props) => JSX.Element;
68
+ export declare const ImporterContextProvider: ({ templateSlug, apiToken, children, options, onSubmit, onClose, formatRecord, onValidateRecord, dynamicColumns, }: Props) => JSX.Element;
68
69
  export declare const useImporterContext: () => State;