fuse-importer 0.25.8 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +11 -1
- package/lib/esm/Importer/Review/ReviewWithContext.js +4 -5
- package/lib/esm/Importer/Uploader/HeadersPreview.js +5 -6
- package/lib/esm/Importer/common/GlobalStyle.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +4 -3
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +33 -16
- package/lib/esm/Importer/common/Spreadsheet/common/index.d.ts +3 -3
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +29 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +3 -3
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +4 -2
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +3 -60
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/index.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/styles.js +2 -2
- package/lib/esm/Importer/common/utils.d.ts +0 -1
- package/lib/esm/Importer/common/utils.js +0 -4
- package/lib/esm/Importer/data/index.d.ts +7 -2
- package/lib/esm/Importer/data/index.js +18 -10
- package/lib/esm/Importer/index.js +0 -2
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +10 -4
- package/lib/esm/common/Table/TableActions/ExportData.js +3 -1
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.d.ts +11 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +4 -2
- package/lib/esm/common/Table/TableActions/TableActions.js +2 -1
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +1 -1
- package/lib/esm/common/Table/TableActions/hooks.d.ts +21 -0
- package/lib/esm/common/Table/TableActions/hooks.js +84 -0
- package/lib/esm/common/Table/TableView/TableHeaders.d.ts +6 -8
- package/lib/esm/common/Table/TableView/TableHeaders.js +15 -17
- package/lib/esm/common/Table/TableView/{TableRow.d.ts → TableRows/TableRow.d.ts} +5 -5
- package/lib/esm/common/Table/TableView/{TableRow.js → TableRows/TableRow.js} +9 -6
- package/lib/esm/common/Table/TableView/TableRows/index.d.ts +4 -0
- package/lib/esm/common/Table/TableView/{TableCells.js → TableRows/index.js} +13 -11
- package/lib/esm/common/Table/TableView/common/index.d.ts +5 -0
- package/lib/esm/common/Table/TableView/common/index.js +37 -0
- package/lib/esm/common/Table/TableView/index.d.ts +4 -39
- package/lib/esm/common/Table/TableView/index.js +55 -44
- package/lib/esm/common/Table/TableView/types.d.ts +37 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/index.d.ts +2 -2
- package/lib/esm/common/Table/index.js +6 -6
- package/lib/esm/common/inputs/Autocomplete.d.ts +2 -1
- package/lib/esm/common/inputs/Autocomplete.js +2 -2
- package/lib/esm/common/inputs/TextInput.js +1 -1
- package/lib/esm/index.d.ts +7 -0
- package/lib/esm/index.js +90 -21
- package/lib/esm/locales/de.d.ts +21 -0
- package/lib/esm/locales/de.js +21 -0
- package/lib/esm/locales/en.d.ts +21 -0
- package/lib/esm/locales/en.js +21 -0
- package/lib/esm/locales/es.d.ts +21 -0
- package/lib/esm/locales/es.js +21 -0
- package/lib/esm/locales/fr.d.ts +21 -0
- package/lib/esm/locales/fr.js +21 -0
- package/lib/esm/styled/fontsURL.d.ts +9 -0
- package/lib/esm/styled/fontsURL.js +27 -0
- package/lib/esm/types.d.ts +1 -0
- package/lib/esm/utils/hooks/useWindowSize.d.ts +11 -0
- package/lib/esm/utils/hooks/useWindowSize.js +23 -0
- package/lib/esm/utils/hooks.d.ts +1 -0
- package/lib/esm/utils/hooks.js +1 -0
- package/lib/main.js +11 -11
- package/package.json +1 -1
- package/lib/esm/Importer/useFullscreenOverlay.d.ts +0 -1
- package/lib/esm/Importer/useFullscreenOverlay.js +0 -14
- package/lib/esm/common/Table/TableView/TableCells.d.ts +0 -4
- package/lib/esm/common/Table/TableView/common.d.ts +0 -9
- package/lib/esm/common/Table/TableView/common.js +0 -27
|
@@ -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) {
|
|
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,20 +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 {
|
|
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 {
|
|
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
24
|
var TitleContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
26
25
|
var ReviewWithContext = function () {
|
|
27
26
|
var _a = useReviewContext(), fields = _a.reviewFields, initialDataSet = _a.reviewInitialDataSet, options = _a.options, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged;
|
|
28
27
|
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows, isUsingManualImport = _b.isUsingManualImport;
|
|
29
28
|
var t = useTranslation("review").t;
|
|
30
|
-
var spreadsheetUI = initialDataSet && (_jsx(Spreadsheet, { options: __assign(__assign({}, options), { showCheckboxColumn: true }), selectedRows: selectedRows, setSelectedRows: setSelectedRows, initialDataSet: initialDataSet, fields: fields,
|
|
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 }));
|
|
31
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 }))] }))] })));
|
|
32
31
|
};
|
|
33
32
|
export default ReviewWithContext;
|
|
@@ -14,21 +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
|
|
21
|
+
import Spreadsheet from "../common/Spreadsheet";
|
|
22
22
|
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
23
|
-
import {
|
|
24
|
-
import styled from "styled-components";
|
|
23
|
+
import { HeaderButtons } from "./HeaderButtons";
|
|
25
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"])));
|
|
26
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"])));
|
|
27
26
|
var HeadersPreview = function () {
|
|
28
27
|
var _a = useReviewContext(), fields = _a.previewFields, initialDataSet = _a.previewInitialDataSet;
|
|
29
28
|
var t = useTranslation("upload").t;
|
|
30
29
|
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows;
|
|
31
|
-
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, {
|
|
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: {
|
|
32
31
|
showCheckboxColumn: true,
|
|
33
32
|
firstRowIsHeader: true,
|
|
34
33
|
}, selectedRows: selectedRows, setSelectedRows: setSelectedRows })) }))] })));
|
|
@@ -3,5 +3,5 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import { createGlobalStyle } from "styled-components";
|
|
6
|
-
export var GlobalStyle = createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n
|
|
6
|
+
export var GlobalStyle = createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n #fuse-importer-root > *,\n body > * {\n font-size: 17px;\n margin: 0;\n padding: 0;\n top: 0;\n left: 0;\n font-family: DM Sans;\n color-scheme: normal;\n color: black;\n }\n"], ["\n #fuse-importer-root > *,\n body > * {\n font-size: 17px;\n margin: 0;\n padding: 0;\n top: 0;\n left: 0;\n font-family: DM Sans;\n color-scheme: normal;\n color: black;\n }\n"])));
|
|
7
7
|
var templateObject_1;
|
|
@@ -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,12 +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;
|
|
30
|
+
isFiltering: boolean;
|
|
29
31
|
} & ValidationState;
|
|
30
32
|
type Props = {
|
|
31
33
|
initialDataSet: RecordDataSet;
|
|
32
|
-
rowWidth?: number;
|
|
33
34
|
isReadOnly?: boolean;
|
|
34
35
|
children: JSX.Element;
|
|
35
36
|
fields: Field[];
|
|
@@ -41,6 +42,6 @@ type Props = {
|
|
|
41
42
|
selectedRows: string[];
|
|
42
43
|
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
43
44
|
};
|
|
44
|
-
export declare const SpreadsheetContextProvider: ({ initialDataSet,
|
|
45
|
+
export declare const SpreadsheetContextProvider: ({ initialDataSet, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: Props) => JSX.Element;
|
|
45
46
|
export declare const useSpreadsheetContext: () => State;
|
|
46
47
|
export {};
|
|
@@ -23,17 +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
|
-
import { addEmptyRows } from "../../../Importer/data";
|
|
28
26
|
import { addMeta } from "../../../Importer/data";
|
|
27
|
+
import { useValidationState } from "./hooks";
|
|
29
28
|
var SpreadsheetContext = createContext({});
|
|
30
29
|
export var SpreadsheetContextProvider = function (_a) {
|
|
31
|
-
var initialDataSet = _a.initialDataSet,
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
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];
|
|
37
37
|
var sortByCurrentErrorsRef = useRef({});
|
|
38
38
|
var sortByCurrentWarningsRef = useRef({});
|
|
39
39
|
var _h = useValidationState({
|
|
@@ -45,19 +45,30 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
45
45
|
setDataSet: setDataSet,
|
|
46
46
|
setIsLoading: setIsLoading,
|
|
47
47
|
onValidateRecord: onValidateRecord,
|
|
48
|
-
}), errorsRef = _h.errorsRef, warningsRef = _h.warningsRef, updateRecordAndRevalidate = _h.updateRecordAndRevalidate, deleteRecords = _h.deleteRecords, filterRecordsBySearchValue = _h.filterRecordsBySearchValue, validationState = __rest(_h, ["errorsRef", "warningsRef", "updateRecordAndRevalidate", "deleteRecords", "filterRecordsBySearchValue"]);
|
|
49
|
-
var addNewRowsToSpreadsheet = function () {
|
|
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"]);
|
|
49
|
+
var addNewRowsToSpreadsheet = useCallback(function () {
|
|
50
50
|
var highestRowIndex = Math.max.apply(Math, Object.values(dataSet).map(function (obj) { return obj._meta.rowIndex; }));
|
|
51
51
|
var newRow = addMeta({}, highestRowIndex + 1);
|
|
52
52
|
setDataSet(function (oldValues) {
|
|
53
53
|
var _a;
|
|
54
54
|
return (__assign(__assign({}, oldValues), (_a = {}, _a[newRow._meta.id] = newRow, _a)));
|
|
55
55
|
});
|
|
56
|
-
};
|
|
56
|
+
}, [dataSet]);
|
|
57
|
+
var handleDeleteErrors = useCallback(function (selectedRows) {
|
|
58
|
+
deleteRecords(dataSet, selectedRows, errorsRef.current, warningsRef.current);
|
|
59
|
+
}, []);
|
|
57
60
|
// sort data based on errors (errors group on top and not errors group at bottom)
|
|
58
61
|
var data = useMemo(function () {
|
|
59
|
-
var
|
|
60
|
-
|
|
62
|
+
var filteredDatasetByString = filteredInputValue
|
|
63
|
+
? filterRecordsBySearchValue(dataSet, filteredInputValue, fields)
|
|
64
|
+
: dataSet;
|
|
65
|
+
var filteredDatasetByError = selectedErrorToFilter
|
|
66
|
+
? filterRecordsByError(filteredDatasetByString, selectedErrorToFilter, errorsRef.current, fields)
|
|
67
|
+
: filteredDatasetByString;
|
|
68
|
+
var dataSetValues = Object.values(filteredDatasetByError);
|
|
69
|
+
if (dataSetValues.length === 0) {
|
|
70
|
+
setSelectedErrorToFilter("");
|
|
71
|
+
}
|
|
61
72
|
var errors = sortByCurrentErrorsRef.current; //Sort errors snapshot
|
|
62
73
|
var warnings = sortByCurrentWarningsRef.current; //Sort warnings snapshot
|
|
63
74
|
if (!sortByFieldErrors && !sortByFieldWarnings)
|
|
@@ -70,8 +81,14 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
70
81
|
}
|
|
71
82
|
return bHasErrors ? 1 : -1;
|
|
72
83
|
});
|
|
73
|
-
}, [
|
|
74
|
-
|
|
84
|
+
}, [
|
|
85
|
+
dataSet,
|
|
86
|
+
filteredInputValue,
|
|
87
|
+
selectedErrorToFilter,
|
|
88
|
+
sortByFieldErrors,
|
|
89
|
+
sortByFieldWarnings,
|
|
90
|
+
]);
|
|
91
|
+
var isFiltering = useMemo(function () { return !!filteredInputValue; }, [filteredInputValue]);
|
|
75
92
|
useEffect(function () {
|
|
76
93
|
onDataSetChanged && onDataSetChanged(dataSet);
|
|
77
94
|
var dataSetKeys = Object.keys(dataSet);
|
|
@@ -113,7 +130,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
113
130
|
var baseCheckboxColumnWidth = lastRowIndexLength * singleLetterWidth + horizontalSpacing;
|
|
114
131
|
return baseCheckboxColumnWidth < 40 ? 40 : baseCheckboxColumnWidth;
|
|
115
132
|
}, [data]);
|
|
116
|
-
var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly,
|
|
133
|
+
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 });
|
|
117
134
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
118
135
|
};
|
|
119
136
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
|
@@ -2,9 +2,9 @@ import { Record, Field, FieldTypes } from "../../../../types";
|
|
|
2
2
|
export declare const spreadsheetRowHeightPx = 40;
|
|
3
3
|
export declare const spreadsheetHeaderHeightPx = 40;
|
|
4
4
|
export declare const isNullOrUndefined: (value: any) => boolean;
|
|
5
|
-
export declare const isEmpty: (value:
|
|
6
|
-
export declare const isEmail: (value:
|
|
7
|
-
export declare const isUrl: (value:
|
|
5
|
+
export declare const isEmpty: (value: string) => boolean;
|
|
6
|
+
export declare const isEmail: (value: string) => boolean;
|
|
7
|
+
export declare const isUrl: (value: string) => boolean;
|
|
8
8
|
export declare const isTrue: (value: string) => boolean;
|
|
9
9
|
export declare const isFalse: (value: string) => boolean;
|
|
10
10
|
export declare const isBoolean: (value: string) => boolean;
|
|
@@ -11,7 +11,7 @@ export var isEmpty = function (value) {
|
|
|
11
11
|
(typeof value === "string" && value.trim().length === 0));
|
|
12
12
|
};
|
|
13
13
|
export var isEmail = function (value) {
|
|
14
|
-
var emailRegex = /^[\w
|
|
14
|
+
var emailRegex = /^[\w+.-]+@([\w-]+\.)+[\w-]{2,4}$/;
|
|
15
15
|
return emailRegex.test(value);
|
|
16
16
|
};
|
|
17
17
|
export var isUrl = function (value) {
|
|
@@ -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,
|
|
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;
|
|
@@ -83,6 +109,7 @@ var SpreadsheetData = function () {
|
|
|
83
109
|
});
|
|
84
110
|
}, [dataLength]);
|
|
85
111
|
var showValidationProgress = !isReadOnly && validationPercentage < 100;
|
|
86
|
-
|
|
112
|
+
var isReviewStep = currentStepIndex === 2;
|
|
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 })] }))] }))] })));
|
|
87
114
|
};
|
|
88
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,
|
|
9
|
+
export declare const SpreadsheetRowCheckboxes: ({ height, gridRef, firstRowIsHeader, isLoadingData, ...props }: Props) => JSX.Element;
|
|
11
10
|
export {};
|
|
@@ -62,7 +62,7 @@ var rowIsEmpty = function (row) {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
export var SpreadsheetRowCheckboxes = function (_a) {
|
|
65
|
-
var height = _a.height,
|
|
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); }); }, [
|
|
@@ -20,7 +20,7 @@ import { Autocomplete as AutocompleteBase, } from "../../../../../common/inputs/
|
|
|
20
20
|
import { SelectMenuDiv, SelectMenuScrollArea, } from "../../../../../common/inputs/SelectMenu";
|
|
21
21
|
import { HTMLInput, TextInputIcon, } from "../../../../../common/inputs/TextInput";
|
|
22
22
|
import { spreadsheetRowHeightPx } from "../../common";
|
|
23
|
-
var Autocomplete = styled(AutocompleteBase)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", " {\n border: none
|
|
23
|
+
var Autocomplete = styled(AutocompleteBase)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", " {\n border: none;\n border-radius: 0;\n margin: 0;\n background: transparent;\n height: ", "px;\n padding: 0 12px;\n\n ", "\n\n ::placeholder {\n ", "\n\n ", "\n\n ::placeholder {\n ", "\n }\n }\n\n :focus {\n border: none;\n box-shadow: none;\n }\n\n :hover {\n background: transparent;\n }\n }\n ", " {\n right: 6px;\n }\n ", " {\n border-radius: 7px;\n }\n ", " {\n padding: 4px;\n }\n"], ["\n ", " {\n border: none;\n border-radius: 0;\n margin: 0;\n background: transparent;\n height: ", "px;\n padding: 0 12px;\n\n ", "\n\n ::placeholder {\n ", "\n\n ", "\n\n ::placeholder {\n ", "\n }\n }\n\n :focus {\n border: none;\n box-shadow: none;\n }\n\n :hover {\n background: transparent;\n }\n }\n ", " {\n right: 6px;\n }\n ", " {\n border-radius: 7px;\n }\n ", " {\n padding: 4px;\n }\n"])), HTMLInput, spreadsheetRowHeightPx - 5, function (p) {
|
|
24
24
|
return p.hasWarning && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.orange1200; });
|
|
25
25
|
}, function (p) {
|
|
26
26
|
return p.hasWarning && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.orange1200; });
|
|
@@ -35,9 +35,9 @@ export var SpreadsheetInput = function (_a) {
|
|
|
35
35
|
return setValue(value);
|
|
36
36
|
} }, props)) })));
|
|
37
37
|
};
|
|
38
|
-
export var Input = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n
|
|
39
|
-
return p.hasWarning && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", "
|
|
38
|
+
export var Input = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: transparent;\n border: none;\n box-shadow: none;\n box-sizing: border-box;\n height: calc(100% - 2px);\n margin: 0px;\n outline: none;\n width: 100%;\n\n ::-webkit-outer-spin-button,\n ::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n /* Firefox */\n -moz-appearance: textfield;\n\n padding: 0 12px;\n ", ";\n color: ", ";\n ::placeholder {\n color: ", ";\n }\n\n ", "\n\n ", "\n"], ["\n background: transparent;\n border: none;\n box-shadow: none;\n box-sizing: border-box;\n height: calc(100% - 2px);\n margin: 0px;\n outline: none;\n width: 100%;\n\n ::-webkit-outer-spin-button,\n ::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n /* Firefox */\n -moz-appearance: textfield;\n\n padding: 0 12px;\n ", ";\n color: ", ";\n ::placeholder {\n color: ", ";\n }\n\n ", "\n\n ", "\n"])), function (props) { return props.theme.css.body1; }, function (props) { return props.theme.colors.gray1000; }, function (props) { return props.theme.colors.placeholder; }, function (p) {
|
|
39
|
+
return p.hasWarning && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.orange1200; });
|
|
40
40
|
}, function (p) {
|
|
41
|
-
return p.hasError && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", "
|
|
41
|
+
return p.hasError && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.error; });
|
|
42
42
|
});
|
|
43
43
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -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:
|
|
30
|
-
filterRecordsBySearchValue:
|
|
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,44 +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 { useTableActions, } from "../../../common/Table/TableActions/hooks";
|
|
52
53
|
var checkIfHasErrors = function (errors) {
|
|
53
54
|
return errors && Object.keys(errors).length > 0;
|
|
54
55
|
};
|
|
55
|
-
var removeItemsFromObject = function (obj, idsToRemove) {
|
|
56
|
-
var _a;
|
|
57
|
-
var idSet = new Set(idsToRemove);
|
|
58
|
-
var newObj = {};
|
|
59
|
-
for (var key in obj) {
|
|
60
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
-
var meta = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a._meta;
|
|
62
|
-
if (meta && (meta === null || meta === void 0 ? void 0 : meta.id) && !(idSet === null || idSet === void 0 ? void 0 : idSet.has(meta === null || meta === void 0 ? void 0 : meta.id))) {
|
|
63
|
-
newObj[key] = obj[key];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return newObj;
|
|
68
|
-
};
|
|
69
|
-
var removeErrorsOrWarningsFromObject = function (obj, keysToRemove) {
|
|
70
|
-
var keysSet = new Set(keysToRemove);
|
|
71
|
-
var newObj = {};
|
|
72
|
-
for (var key in obj) {
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(obj, key) && !(keysSet === null || keysSet === void 0 ? void 0 : keysSet.has(key))) {
|
|
74
|
-
newObj[key] = obj[key];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return newObj;
|
|
78
|
-
};
|
|
79
|
-
var isObject = function (value) {
|
|
80
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
81
|
-
};
|
|
82
|
-
var includesSearchValue = function (value, searchValue) {
|
|
83
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
84
|
-
var stringValue = String(value).toLowerCase();
|
|
85
|
-
var searchValueLower = searchValue.toLowerCase();
|
|
86
|
-
return stringValue.includes(searchValueLower);
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
};
|
|
90
56
|
export var useValidationState = function (_a) {
|
|
91
57
|
var initialDataSet = _a.initialDataSet, //Initial Data Set, used to run the initial validation
|
|
92
58
|
dataSet = _a.dataSet, //Current Updated Data Set
|
|
@@ -97,31 +63,7 @@ export var useValidationState = function (_a) {
|
|
|
97
63
|
var validatorsCache = useMemo(function () { return selectValidatorsFor(fields); }, [fields]);
|
|
98
64
|
var errorsRef = useRef(errors);
|
|
99
65
|
var warningsRef = useRef(warnings);
|
|
100
|
-
|
|
101
|
-
var deleteRecords = function (selectedRecords) {
|
|
102
|
-
var newDataSet = removeItemsFromObject(dataSet, selectedRecords);
|
|
103
|
-
var newErrors = removeErrorsOrWarningsFromObject(errors, selectedRecords);
|
|
104
|
-
var newWarnings = removeErrorsOrWarningsFromObject(warnings, selectedRecords);
|
|
105
|
-
setDataSet(newDataSet);
|
|
106
|
-
setErrors(newErrors);
|
|
107
|
-
setWarnings(newWarnings);
|
|
108
|
-
};
|
|
109
|
-
//Filter records by search value
|
|
110
|
-
var filterRecordsBySearchValue = function (obj, value) {
|
|
111
|
-
var filteredObj = {};
|
|
112
|
-
for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
|
|
113
|
-
var _b = _a[_i], key = _b[0], currentObj = _b[1];
|
|
114
|
-
if (isObject(currentObj)) {
|
|
115
|
-
var matches = Object.values(currentObj).some(function (propertyValue) {
|
|
116
|
-
return includesSearchValue(propertyValue, value);
|
|
117
|
-
});
|
|
118
|
-
if (matches) {
|
|
119
|
-
filteredObj[key] = currentObj;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return filteredObj;
|
|
124
|
-
};
|
|
66
|
+
var _e = useTableActions({ setDataSet: setDataSet, setErrors: setErrors, setWarnings: setWarnings }), deleteRecords = _e.deleteRecords, filterRecordsByError = _e.filterRecordsByError, filterRecordsBySearchValue = _e.filterRecordsBySearchValue;
|
|
125
67
|
//Validate record and update dataSet
|
|
126
68
|
var updateRecordAndRevalidate = useCallback(function (record) { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
69
|
var recordId, newDataSet, data, _a, recordErrors, recordWarnings, hasError, hasWarning;
|
|
@@ -292,5 +234,6 @@ export var useValidationState = function (_a) {
|
|
|
292
234
|
updateRecordAndRevalidate: updateRecordAndRevalidate,
|
|
293
235
|
deleteRecords: deleteRecords,
|
|
294
236
|
filterRecordsBySearchValue: filterRecordsBySearchValue,
|
|
237
|
+
filterRecordsByError: filterRecordsByError,
|
|
295
238
|
};
|
|
296
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,
|
|
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,
|
|
19
|
-
return (_jsx(SpreadsheetContextProvider, __assign({
|
|
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,
|
|
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
|
|
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;
|
|
@@ -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 = 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;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader } from "../../types";
|
|
2
2
|
import { EnumFieldValueMatchings, HeaderMatchings } from "../contexts/ImporterContextProvider";
|
|
3
|
-
export declare const addEmptyRows: (data: Record[], fields: Field[]) =>
|
|
4
|
-
|
|
3
|
+
export declare const addEmptyRows: (data: Record[], fields: Field[]) => {
|
|
4
|
+
_meta: {
|
|
5
|
+
id: string;
|
|
6
|
+
rowIndex: number;
|
|
7
|
+
};
|
|
8
|
+
}[];
|
|
9
|
+
export declare const addMeta: (record: any, index: number, uploadedRow?: any) => Record;
|
|
5
10
|
export declare const recordListToDataSet: (data: Record[], fields: Field[]) => RecordDataSet;
|
|
6
11
|
type transformToRecordsArgs = {
|
|
7
12
|
templateHeaderMatchings: HeaderMatchings;
|