fuse-importer 0.23.9 → 0.24.3
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/README.md +5 -5
- package/lib/esm/Importer/ImporterWithContext.d.ts +1 -2
- package/lib/esm/Importer/ImporterWithContext.js +1 -6
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.d.ts +0 -1
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.d.ts +0 -1
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.d.ts +2 -3
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.d.ts +0 -1
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.d.ts +0 -1
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.d.ts +0 -1
- package/lib/esm/Importer/Matcher/common/icons/index.d.ts +0 -1
- package/lib/esm/Importer/Matcher/common/index.d.ts +0 -1
- package/lib/esm/Importer/PreviewFirstTime.d.ts +0 -1
- package/lib/esm/Importer/PreviewFirstTime.js +8 -7
- package/lib/esm/Importer/PreviewModeBanner.d.ts +0 -1
- package/lib/esm/Importer/Review/AppResponseModal.d.ts +0 -1
- package/lib/esm/Importer/Review/ReviewContextProvider.d.ts +3 -3
- package/lib/esm/Importer/Review/ReviewContextProvider.js +39 -5
- package/lib/esm/Importer/Review/ReviewWithContext.d.ts +0 -1
- package/lib/esm/Importer/Review/ReviewWithContext.js +16 -3
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.d.ts +7 -0
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +22 -0
- package/lib/esm/Importer/Stepper/Step.d.ts +0 -1
- package/lib/esm/Importer/Stepper/StepIndex.d.ts +0 -1
- package/lib/esm/Importer/Stepper/StepperSubmitModal.d.ts +1 -2
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.d.ts +1 -2
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.d.ts +1 -1
- package/lib/esm/Importer/Stepper/common/icons.d.ts +0 -1
- package/lib/esm/Importer/Stepper/index.d.ts +1 -2
- package/lib/esm/Importer/Stepper/index.js +9 -4
- package/lib/esm/Importer/TrialModeBanner.d.ts +0 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.d.ts +0 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +4 -3
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.d.ts +0 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.d.ts +0 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +1 -1
- package/lib/esm/Importer/Uploader/HeaderButtons.d.ts +0 -1
- package/lib/esm/Importer/Uploader/HeadersPreview.d.ts +0 -1
- package/lib/esm/Importer/Uploader/HeadersPreview.js +6 -1
- package/lib/esm/Importer/Uploader/UploaderContextProvider.d.ts +2 -2
- package/lib/esm/Importer/common/AppLoading.d.ts +0 -1
- package/lib/esm/Importer/common/Footer.d.ts +0 -1
- package/lib/esm/Importer/common/ImporterFonts.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +10 -5
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +8 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +10 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +106 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.d.ts +1 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +0 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.d.ts +1 -1
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +3 -3
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +4 -2
- package/lib/esm/Importer/common/Spreadsheet/index.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/styles.js +4 -3
- package/lib/esm/Importer/common/Spreadsheet/validation/index.d.ts +3 -3
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +2 -2
- package/lib/esm/Importer/common/icons/index.d.ts +0 -1
- package/lib/esm/Importer/common/index.d.ts +2 -2
- package/lib/esm/Importer/common/theme.d.ts +2 -2
- package/lib/esm/Importer/common/theme.js +2 -1
- package/lib/esm/Importer/common/utils.d.ts +1 -1
- package/lib/esm/Importer/common/utils.js +1 -1
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +7 -5
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +10 -2
- package/lib/esm/Importer/data/index.d.ts +1 -1
- package/lib/esm/Importer/index.d.ts +6 -2
- package/lib/esm/Importer/index.js +6 -0
- package/lib/esm/api/index.d.ts +1 -1
- package/lib/esm/api/responseHandlers.d.ts +1 -1
- package/lib/esm/common/Modal.d.ts +1 -1
- package/lib/esm/common/Spinner.d.ts +0 -1
- package/lib/esm/common/Table/Pagination/icons.d.ts +1 -2
- package/lib/esm/common/Table/Pagination/index.d.ts +0 -1
- package/lib/esm/common/Table/TableDataProvider.d.ts +2 -2
- package/lib/esm/common/Table/TableDataProvider.js +1 -1
- package/lib/esm/common/Table/TableView/TableHeaders.d.ts +3 -3
- package/lib/esm/common/Table/TableView/TableHeaders.js +1 -1
- package/lib/esm/common/Table/TableView/TableRow.d.ts +2 -2
- package/lib/esm/common/Table/TableView/index.d.ts +4 -4
- package/lib/esm/common/Table/icons.d.ts +0 -1
- package/lib/esm/common/Table/index.d.ts +1 -2
- package/lib/esm/common/Toast.d.ts +0 -1
- package/lib/esm/common/TooltipProvider.d.ts +2 -2
- package/lib/esm/common/buttons.d.ts +20 -3
- package/lib/esm/common/buttons.js +22 -5
- package/lib/esm/common/icons/index.d.ts +0 -1
- package/lib/esm/common/index.d.ts +2 -3
- package/lib/esm/common/inputs/Autocomplete.d.ts +4 -4
- package/lib/esm/common/inputs/Autocomplete.js +3 -3
- package/lib/esm/common/inputs/Checkbox.d.ts +9 -0
- package/lib/esm/common/inputs/Checkbox.js +50 -0
- package/lib/esm/common/inputs/SelectMenu.d.ts +1 -2
- package/lib/esm/common/inputs/TextInput.d.ts +2 -2
- package/lib/esm/common/inputs/index.d.ts +1 -0
- package/lib/esm/common/inputs/index.js +1 -0
- package/lib/esm/common/inputs/tooltip.d.ts +0 -1
- package/lib/esm/common/logo.d.ts +0 -1
- package/lib/esm/styled/theme/index.d.ts +1 -1
- package/lib/esm/styled/utils.d.ts +9 -9
- package/lib/esm/types.d.ts +23 -22
- package/lib/main.js +171 -1
- package/lib/main.js.LICENSE.txt +1 -3
- package/package.json +6 -2
|
@@ -2,21 +2,24 @@ import React from "react";
|
|
|
2
2
|
import { SpreadsheetOptions } from "../../..";
|
|
3
3
|
import { Field, OnValidateRecord, Record, RecordDataSet } from "../../../types";
|
|
4
4
|
import { ValidationState } from "./hooks";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
|
|
5
|
+
export type OnDataSetChanged = (dataSet: RecordDataSet) => void;
|
|
6
|
+
export type OnValidationStateChanged = (state: ValidationState) => void;
|
|
7
|
+
type State = {
|
|
8
8
|
rowWidth?: number;
|
|
9
9
|
data: Record[];
|
|
10
10
|
fields: Field[];
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
isReadOnly?: boolean;
|
|
13
13
|
highlightFirstRow: boolean;
|
|
14
|
+
options: SpreadsheetOptions;
|
|
14
15
|
sortByFieldErrors: string;
|
|
15
16
|
updateRecord: (record: Record) => void;
|
|
16
17
|
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
18
|
setSortByFieldErrors: React.Dispatch<React.SetStateAction<string>>;
|
|
19
|
+
selectedRows: number[];
|
|
20
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<number[]>>;
|
|
18
21
|
} & ValidationState;
|
|
19
|
-
|
|
22
|
+
type Props = {
|
|
20
23
|
initialDataSet: RecordDataSet;
|
|
21
24
|
rowWidth?: number;
|
|
22
25
|
isReadOnly?: boolean;
|
|
@@ -27,7 +30,9 @@ declare type Props = {
|
|
|
27
30
|
onValidationStateChanged?: OnValidationStateChanged;
|
|
28
31
|
onValidateRecord?: OnValidateRecord;
|
|
29
32
|
onDataSetChanged?: OnDataSetChanged;
|
|
33
|
+
selectedRows: number[];
|
|
34
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<number[]>>;
|
|
30
35
|
};
|
|
31
|
-
export declare const SpreadsheetContextProvider: ({ initialDataSet, rowWidth, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, }: Props) => JSX.Element;
|
|
36
|
+
export declare const SpreadsheetContextProvider: ({ initialDataSet, rowWidth, fields, options, isReadOnly, highlightFirstRow, children, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: Props) => JSX.Element;
|
|
32
37
|
export declare const useSpreadsheetContext: () => State;
|
|
33
38
|
export {};
|
|
@@ -26,7 +26,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, use
|
|
|
26
26
|
import { useValidationState } from "./hooks";
|
|
27
27
|
var SpreadsheetContext = createContext({});
|
|
28
28
|
export var SpreadsheetContextProvider = function (_a) {
|
|
29
|
-
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;
|
|
29
|
+
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;
|
|
30
30
|
var _c = useState(initialDataSet), dataSet = _c[0], setDataSet = _c[1];
|
|
31
31
|
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
32
32
|
var _e = useState(null), sortByFieldErrors = _e[0], setSortByFieldErrors = _e[1];
|
|
@@ -70,7 +70,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
70
70
|
sortByCurrentErrorsRef.current = __assign({}, errorsRef.current);
|
|
71
71
|
setSortByFieldErrors(value);
|
|
72
72
|
}, []);
|
|
73
|
-
var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, rowWidth: rowWidth, sortByFieldErrors: sortByFieldErrors, highlightFirstRow: highlightFirstRow, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate });
|
|
73
|
+
var value = __assign(__assign({ data: data, fields: fields, isLoading: isLoading }, validationState), { isReadOnly: isReadOnly, rowWidth: rowWidth, sortByFieldErrors: sortByFieldErrors, highlightFirstRow: highlightFirstRow, options: options, setIsLoading: setIsLoading, setSortByFieldErrors: handleSortByFieldErrors, onValidateRecord: onValidateRecord, updateRecord: updateRecordAndRevalidate, selectedRows: selectedRows, setSelectedRows: setSelectedRows });
|
|
74
74
|
return (_jsx(SpreadsheetContext.Provider, __assign({ value: value }, { children: children })));
|
|
75
75
|
};
|
|
76
76
|
export var useSpreadsheetContext = function () { return useContext(SpreadsheetContext); };
|
|
@@ -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 = /^
|
|
14
|
+
var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
|
|
15
15
|
return emailRegex.test(value);
|
|
16
16
|
};
|
|
17
17
|
export var isUrl = function (value) {
|
|
@@ -32,11 +32,13 @@ import { FieldHeader } from "./FieldHeader";
|
|
|
32
32
|
import GlobalStyle from "./GlobalStyle";
|
|
33
33
|
import { inputTypes } from "./inputs";
|
|
34
34
|
import { SpreadsheetRowNumbers } from "./SpreadsheetRowNumbers";
|
|
35
|
+
import { SpreadsheetRowCheckboxes } from "./SpreadsheetRowCheckboxes";
|
|
35
36
|
import ValidationProgress from "./ValidationProgress";
|
|
36
37
|
var getItemKey = function (record) { return record._meta.id; };
|
|
37
38
|
var SpreadsheetData = function () {
|
|
38
|
-
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;
|
|
39
|
+
var _a = useSpreadsheetContext(), fields = _a.fields, data = _a.data, isLoading = _a.isLoading, isReadOnly = _a.isReadOnly, rowWidth = _a.rowWidth, totalErrors = _a.totalErrors, validationPercentage = _a.validationPercentage, setSortByFieldErrors = _a.setSortByFieldErrors, options = _a.options;
|
|
39
40
|
var rowNumbersGridRef = useRef();
|
|
41
|
+
var rowCheckboxesGridRef = useRef();
|
|
40
42
|
var sortByErrors = useCallback(function (field) {
|
|
41
43
|
return setSortByFieldErrors(function (sortByFieldErrors) {
|
|
42
44
|
return sortByFieldErrors === field ? null : field;
|
|
@@ -57,6 +59,10 @@ var SpreadsheetData = function () {
|
|
|
57
59
|
var grid = rowNumbersGridRef.current;
|
|
58
60
|
grid.scrollTo({ scrollTop: scrollTop });
|
|
59
61
|
}
|
|
62
|
+
if (rowCheckboxesGridRef.current) {
|
|
63
|
+
var grid = rowCheckboxesGridRef.current;
|
|
64
|
+
grid.scrollTo({ scrollTop: scrollTop });
|
|
65
|
+
}
|
|
60
66
|
}, []);
|
|
61
67
|
var dataLength = data === null || data === void 0 ? void 0 : data.length;
|
|
62
68
|
var spreadsheetHeight = useMemo(function () {
|
|
@@ -69,6 +75,6 @@ var SpreadsheetData = function () {
|
|
|
69
75
|
});
|
|
70
76
|
}, [dataLength]);
|
|
71
77
|
var showValidationProgress = !isReadOnly && validationPercentage < 100;
|
|
72
|
-
return (_jsxs(
|
|
78
|
+
return (_jsxs(S.SpreadSheetData, { children: [_jsx(GlobalStyle, {}), _jsx(Div, __assign({ h: 32 }, { children: showValidationProgress && (_jsx(ValidationProgress, { totalErrors: totalErrors, validationPercentage: validationPercentage })) })), _jsxs(S.SpreadSheetWrapper, __assign({ h: spreadsheetHeight, dflex: true }, { children: [options.showCheckboxColumn && (_jsx(SpreadsheetRowCheckboxes, { gridRef: rowCheckboxesGridRef, spreadsheetHasXScroll: rowWidth > 1, height: spreadsheetHeight, firstRowIsHeader: options.firstRowIsHeader })), _jsx(SpreadsheetRowNumbers, { gridRef: rowNumbersGridRef, spreadsheetHasXScroll: rowWidth > 1, height: spreadsheetHeight }), _jsx(S.TableView, { tableHeadersHeight: spreadsheetHeaderHeightPx, highlightFirstRow: isReadOnly, rowHeight: spreadsheetRowHeightPx, h: spreadsheetHeight, rowWidth: rowWidth, data: data, columns: columns, isLoading: isLoading, onTableScroll: onTableScroll, getItemKey: getItemKey })] }))] }));
|
|
73
79
|
};
|
|
74
80
|
export default React.memo(SpreadsheetData, areEqual);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DivCSSProps } from "../../../../styled/utils";
|
|
3
|
+
type Props = {
|
|
4
|
+
height?: number;
|
|
5
|
+
spreadsheetHasXScroll?: boolean;
|
|
6
|
+
gridRef: React.MutableRefObject<any>;
|
|
7
|
+
firstRowIsHeader?: boolean;
|
|
8
|
+
} & DivCSSProps;
|
|
9
|
+
export declare const SpreadsheetRowCheckboxes: ({ height, spreadsheetHasXScroll, gridRef, firstRowIsHeader, ...props }: Props) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
28
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
29
|
+
if (ar || !(i in from)) {
|
|
30
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
31
|
+
ar[i] = from[i];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
35
|
+
};
|
|
36
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
37
|
+
import { useMemo } from "react";
|
|
38
|
+
import { FixedSizeGrid as Grid } from "react-window";
|
|
39
|
+
import styled, { css } from "styled-components";
|
|
40
|
+
import { Div } from "../../../../styled/utils";
|
|
41
|
+
import { spreadsheetRowHeightPx } from "../common";
|
|
42
|
+
import { spreadsheetHeaderHeightPx } from "../common/index";
|
|
43
|
+
import { useSpreadsheetContext } from "../SpreadsheetContextProvider";
|
|
44
|
+
import { Checkbox } from "../../../../common/inputs/Checkbox";
|
|
45
|
+
var SPREADSHEET_ROW_CHECKBOXES_WIDTH = 40;
|
|
46
|
+
var gridStyles = {
|
|
47
|
+
outline: "none",
|
|
48
|
+
willChange: "unset",
|
|
49
|
+
overflowY: "hidden",
|
|
50
|
+
overflowX: "scroll",
|
|
51
|
+
};
|
|
52
|
+
var rowIsEmpty = function (row) {
|
|
53
|
+
return Object.keys(row).every(function (key) {
|
|
54
|
+
if (key === "_meta")
|
|
55
|
+
return true;
|
|
56
|
+
return !row[key];
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export var SpreadsheetRowCheckboxes = function (_a) {
|
|
60
|
+
var height = _a.height, spreadsheetHasXScroll = _a.spreadsheetHasXScroll, gridRef = _a.gridRef, _b = _a.firstRowIsHeader, firstRowIsHeader = _b === void 0 ? false : _b, props = __rest(_a, ["height", "spreadsheetHasXScroll", "gridRef", "firstRowIsHeader"]);
|
|
61
|
+
var _c = useSpreadsheetContext(), data = _c.data, selectedRows = _c.selectedRows, setSelectedRows = _c.setSelectedRows;
|
|
62
|
+
var nonEmptyRows = useMemo(function () { return data.filter(function (row) { return !rowIsEmpty(row); }); }, [
|
|
63
|
+
data,
|
|
64
|
+
]);
|
|
65
|
+
var isIndeterminate = selectedRows.length > 0 && selectedRows.length < nonEmptyRows.length;
|
|
66
|
+
var handleRowSelect = function (checked, rowIndex) {
|
|
67
|
+
if (checked && rowIsEmpty(data[rowIndex])) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// If the first row is a header, we don't want to select it
|
|
71
|
+
if (firstRowIsHeader && rowIndex === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// If the first row is a header, we need to adjust the rowIndex
|
|
75
|
+
var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
|
|
76
|
+
if (checked) {
|
|
77
|
+
setSelectedRows(function (prev) { return __spreadArray(__spreadArray([], prev, true), [adjustedRowIndex], false); });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
setSelectedRows(function (prev) { return prev.filter(function (row) { return row !== adjustedRowIndex; }); });
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var handleSelectAllRows = function (checked) {
|
|
84
|
+
if (checked) {
|
|
85
|
+
var allRows = data
|
|
86
|
+
.filter(function (row) { return !rowIsEmpty(row); })
|
|
87
|
+
.map(function (_, index) { return (firstRowIsHeader ? index - 1 : index); });
|
|
88
|
+
setSelectedRows(allRows);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
setSelectedRows([]);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var Cell = function (_a) {
|
|
95
|
+
var rowIndex = _a.rowIndex, style = _a.style;
|
|
96
|
+
var adjustedRowIndex = firstRowIsHeader ? rowIndex - 1 : rowIndex;
|
|
97
|
+
return (_jsx(RowCheckbox, __assign({ style: style, alignCenter: true, justifyEnd: true, isLast: adjustedRowIndex === data.length - 1 }, { children: firstRowIsHeader && rowIndex === 0 ? ("") : (_jsx(Checkbox, { isChecked: selectedRows.includes(adjustedRowIndex), onChange: function (checked) { return handleRowSelect(checked, rowIndex); } })) }), adjustedRowIndex));
|
|
98
|
+
};
|
|
99
|
+
return (_jsxs(SpreadsheetRowCheckboxesContainer, __assign({}, props, { h: height }, { children: [_jsx(SpreadsheetRowCheckboxesHeader, { children: _jsx(Checkbox, { isChecked: selectedRows.length >= nonEmptyRows.length, onChange: handleSelectAllRows, isIndeterminate: isIndeterminate }) }), _jsx(Grid, __assign({ ref: gridRef, style: gridStyles, width: SPREADSHEET_ROW_CHECKBOXES_WIDTH, columnCount: 1, columnWidth: SPREADSHEET_ROW_CHECKBOXES_WIDTH, height: height - spreadsheetHeaderHeightPx, rowHeight: 40, rowCount: data.length }, { children: Cell }))] })));
|
|
100
|
+
};
|
|
101
|
+
var RowCheckbox = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n ", ";\n ", "\n display: flex;\n justify-content: center;\n"], ["\n background-color: ", ";\n ", ";\n ", "\n display: flex;\n justify-content: center;\n"])), function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.css.label3; }, function (p) {
|
|
102
|
+
return !p.isLast && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: inset 0 -1px 0 ", ";\n "], ["\n box-shadow: inset 0 -1px 0 ", ";\n "])), function (p) { return p.theme.colors.gray300; });
|
|
103
|
+
});
|
|
104
|
+
var SpreadsheetRowCheckboxesHeader = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-items: center;\n height: ", "px;\n border-top-left-radius: 8px;\n background-color: ", ";\n box-shadow: inset 0 -1px 0 ", ";\n padding-left: 2px;\n display: flex;\n justify-content: center;\n"], ["\n align-items: center;\n height: ", "px;\n border-top-left-radius: 8px;\n background-color: ", ";\n box-shadow: inset 0 -1px 0 ", ";\n padding-left: 2px;\n display: flex;\n justify-content: center;\n"])), spreadsheetRowHeightPx, function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.colors.gray300; });
|
|
105
|
+
var SpreadsheetRowCheckboxesContainer = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", "px;\n border-top-left-radius: 8px;\n border-right: solid 1px ", ";\n\n .ReactVirtualized__Grid {\n /* Scrollbar */\n ::-webkit-scrollbar {\n width: 8px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background-color: ", " !important;\n }\n }\n"], ["\n width: ", "px;\n border-top-left-radius: 8px;\n border-right: solid 1px ", ";\n\n .ReactVirtualized__Grid {\n /* Scrollbar */\n ::-webkit-scrollbar {\n width: 8px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background-color: ", " !important;\n }\n }\n"])), SPREADSHEET_ROW_CHECKBOXES_WIDTH, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.tableHeader; });
|
|
106
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Option } from "../../../../../common/inputs/Autocomplete";
|
|
3
3
|
import { FieldTypes, Record } from "../../../../../types";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type AutoCompleteOption = Option;
|
|
5
|
+
export type SpreadsheetAutocompleteProps = {
|
|
6
6
|
name: string;
|
|
7
7
|
record: Record;
|
|
8
8
|
options: AutoCompleteOption[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { HTMLInputCSSProps } from "../../../../../styled/utils";
|
|
3
2
|
import { FieldTypes, Record } from "../../../../../types";
|
|
4
|
-
export
|
|
3
|
+
export type SpreadsheetTextInputArgs = {
|
|
5
4
|
name: string;
|
|
6
5
|
record: Record;
|
|
7
6
|
fieldType: FieldTypes;
|
|
@@ -28,7 +28,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
28
28
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
29
|
function step(op) {
|
|
30
30
|
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
32
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
33
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
34
|
switch (op[0]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpreadsheetAutocompleteProps } from "../fields/SpeadsheetAutocomplete";
|
|
3
|
-
export
|
|
3
|
+
export type EnumInputProps = {
|
|
4
4
|
options: any;
|
|
5
5
|
} & SpreadsheetAutocompleteProps;
|
|
6
6
|
export declare const EnumInput: React.FC<EnumInputProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpreadsheetOptions } from "../../..";
|
|
3
3
|
import { BatchValidationErrors, Field, OnValidateRecord, Record, RecordDataSet } from "../../../types";
|
|
4
|
-
|
|
4
|
+
type UseValidationStateArgs = {
|
|
5
5
|
onValidateRecord?: OnValidateRecord;
|
|
6
6
|
setDataSet: React.Dispatch<React.SetStateAction<RecordDataSet>>;
|
|
7
7
|
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -11,7 +11,7 @@ declare type UseValidationStateArgs = {
|
|
|
11
11
|
options: SpreadsheetOptions;
|
|
12
12
|
isReadOnly: boolean;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type ValidationState = {
|
|
15
15
|
isValid: boolean;
|
|
16
16
|
isValidationCompleted: boolean;
|
|
17
17
|
validationPercentage: number;
|
|
@@ -21,7 +21,7 @@ export declare type ValidationState = {
|
|
|
21
21
|
[column: string]: number;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type UseValidationStateReturnValue = ValidationState & {
|
|
25
25
|
updateRecordAndRevalidate: (record: Record) => Promise<void>;
|
|
26
26
|
errorsRef: React.MutableRefObject<BatchValidationErrors>;
|
|
27
27
|
};
|
|
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
28
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
30
|
switch (op[0]) {
|
|
@@ -126,7 +126,7 @@ export var useValidationState = function (_a) {
|
|
|
126
126
|
if (!(index < batch.length)) return [3 /*break*/, 5];
|
|
127
127
|
if (isCancelled)
|
|
128
128
|
return [2 /*return*/];
|
|
129
|
-
record =
|
|
129
|
+
record = batch[index];
|
|
130
130
|
recordId = record._meta.id;
|
|
131
131
|
return [4 /*yield*/, validateRecord({
|
|
132
132
|
onValidateRecord: onValidateRecord,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Field, OnValidateRecord, Record, RecordDataSet, SpreadsheetOptions } from "../../../types";
|
|
3
3
|
import { OnDataSetChanged, OnValidationStateChanged } from "./SpreadsheetContextProvider";
|
|
4
|
-
export
|
|
4
|
+
export type SpreadsheetProps = {
|
|
5
5
|
initialDataSet: RecordDataSet;
|
|
6
6
|
rowWidth?: number;
|
|
7
7
|
isReadOnly?: boolean;
|
|
@@ -12,8 +12,10 @@ export declare type SpreadsheetProps = {
|
|
|
12
12
|
onValidateRecord?: OnValidateRecord;
|
|
13
13
|
onDataSetChanged?: OnDataSetChanged;
|
|
14
14
|
onValidationStateChanged?: OnValidationStateChanged;
|
|
15
|
+
selectedRows?: number[];
|
|
16
|
+
setSelectedRows?: React.Dispatch<React.SetStateAction<number[]>>;
|
|
15
17
|
};
|
|
16
|
-
declare const _default: React.MemoExoticComponent<({ isReadOnly, initialDataSet, rowWidth, fields, options, highlightFirstRow, onValidateRecord, onDataSetChanged, onValidationStateChanged, }: SpreadsheetProps) => JSX.Element>;
|
|
18
|
+
declare const _default: React.MemoExoticComponent<({ isReadOnly, initialDataSet, rowWidth, fields, options, highlightFirstRow, onValidateRecord, onDataSetChanged, onValidationStateChanged, selectedRows, setSelectedRows, }: SpreadsheetProps) => JSX.Element>;
|
|
17
19
|
export default _default;
|
|
18
20
|
export * from "./hooks";
|
|
19
21
|
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;
|
|
19
|
-
return (_jsx(SpreadsheetContextProvider, __assign({ rowWidth: rowWidth, isReadOnly: isReadOnly, fields: fields, initialDataSet: initialDataSet, highlightFirstRow: highlightFirstRow, options: options, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged }, { children: _jsx(SpreadsheetData, {}) })));
|
|
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, {}) })));
|
|
20
20
|
};
|
|
21
21
|
export default React.memo(Spreadsheet, areEqual);
|
|
22
22
|
export * from "./hooks";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
export declare const SpreadSheetData: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
2
3
|
export declare const SpreadSheetWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
3
4
|
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, ...props }: import("../../../common/Table/TableView").TableViewProps) => JSX.Element>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -5,6 +5,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { TableView as TableViewBase, TableViewCellContainer, TableViewRow, } from "../../../common/Table/TableView";
|
|
7
7
|
import { Div } from "../../../styled/utils";
|
|
8
|
-
export var
|
|
9
|
-
export var
|
|
10
|
-
var
|
|
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_2 || (templateObject_2 = __makeTemplateObject(["\n border: solid 1px ", ";\n border-radius: 8px;\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n margin-left: 32px;\n margin-right: 32px;\n"], ["\n border: solid 1px ", ";\n border-radius: 8px;\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n margin-left: 32px;\n margin-right: 32px;\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; });
|
|
10
|
+
export var TableView = styled(TableViewBase)(templateObject_3 || (templateObject_3 = __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; });
|
|
11
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Field, FieldValidation, OnValidateRecord, Record, ValidationErrors } from "../../../../types";
|
|
2
2
|
import { FieldValidator } from "./validators";
|
|
3
|
-
|
|
3
|
+
type SelectedValidator = {
|
|
4
4
|
validator: FieldValidation;
|
|
5
5
|
validatorFunction: FieldValidator;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type SelectedFieldValidators = {
|
|
8
8
|
field: Field;
|
|
9
9
|
validators: SelectedValidator[];
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type ValidateRecordArgs = {
|
|
12
12
|
onValidateRecord?: OnValidateRecord;
|
|
13
13
|
validatorsCache?: SelectedFieldValidators[];
|
|
14
14
|
record: Record;
|
|
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
28
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
30
|
switch (op[0]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, FieldValidation, Record } from "../../../../types";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type FieldValidator = (field: Field, fieldValue: any, validation?: FieldValidation, data?: Record[]) => null | string;
|
|
3
|
+
export type FieldValidations = Partial<{
|
|
4
4
|
[key: string]: FieldValidator;
|
|
5
5
|
}>;
|
|
6
6
|
export declare const fieldValidations: FieldValidations;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EnvironmentType } from "../../types";
|
|
2
2
|
export declare const contentWidth = 1120;
|
|
3
|
-
|
|
3
|
+
type Environments = {
|
|
4
4
|
[K in EnvironmentType]?: any;
|
|
5
5
|
};
|
|
6
6
|
export declare const baseUrls: Environments;
|
|
7
|
-
|
|
7
|
+
type GetTableHeightArgs = {
|
|
8
8
|
headerHeight: number;
|
|
9
9
|
rowHeight: number;
|
|
10
10
|
maxVisibleRows: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { theme } from "../../styled/theme";
|
|
2
|
-
export
|
|
2
|
+
export type ImporterStylePreferences = {
|
|
3
3
|
id: number;
|
|
4
4
|
background: string;
|
|
5
5
|
highlight1: string;
|
|
@@ -8,7 +8,7 @@ export declare type ImporterStylePreferences = {
|
|
|
8
8
|
secondary_color: string;
|
|
9
9
|
logo_url: string;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type Theme = typeof theme;
|
|
12
12
|
declare const getCustomTheme: (importerStylePreferences: ImporterStylePreferences) => {
|
|
13
13
|
theme: {
|
|
14
14
|
readonly colors: {
|
|
@@ -9,10 +9,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
import Color from 'color';
|
|
12
13
|
import { theme } from "../../styled/theme";
|
|
13
14
|
var getCustomTheme = function (importerStylePreferences) {
|
|
14
15
|
var primary_color = importerStylePreferences.primary_color, secondary_color = importerStylePreferences.secondary_color, highlight1 = importerStylePreferences.highlight1, highlight2 = importerStylePreferences.highlight2, background = importerStylePreferences.background;
|
|
15
|
-
var customTheme = __assign(__assign({}, theme), { colors: __assign(__assign({}, theme.colors), { pink500: primary_color, black: secondary_color, blue500: highlight1, blue100: highlight2, backgroundInterface: background }) });
|
|
16
|
+
var customTheme = __assign(__assign({}, theme), { colors: __assign(__assign({}, theme.colors), { pink500: primary_color, pink700: Color(primary_color).darken(0.2).hex(), black: secondary_color, blue500: highlight1, blue100: highlight2, backgroundInterface: background }) });
|
|
16
17
|
return { theme: customTheme, logoURL: importerStylePreferences.logo_url };
|
|
17
18
|
};
|
|
18
19
|
export { theme, getCustomTheme };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Integration, Record, TemplateHeader } from "../../types";
|
|
2
2
|
export declare const getSpreadsheetRowWidth: (fields: any, visibleRowsOnTableViewport: any) => number;
|
|
3
|
-
|
|
3
|
+
type IsEnumFieldArgs = {
|
|
4
4
|
templateLabel: string;
|
|
5
5
|
templateHeaders: TemplateHeader[];
|
|
6
6
|
};
|
|
@@ -13,7 +13,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
13
13
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
14
|
function step(op) {
|
|
15
15
|
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
17
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
18
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
19
|
switch (op[0]) {
|
|
@@ -3,18 +3,18 @@ import React from "react";
|
|
|
3
3
|
import { FormatRecord, ImporterOptions, Integration, OnSubmit, OnValidateRecord, TemplateHeader } from "../../types";
|
|
4
4
|
import { FuseApi } from "../common/FuseApi";
|
|
5
5
|
export declare const fusejsOptions: Fuse.IFuseOptions<string>;
|
|
6
|
-
export
|
|
6
|
+
export type HeaderMatchings = {
|
|
7
7
|
[templateHeaderLabel: string]: string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type EnumFieldValueMatchings = {
|
|
10
10
|
[templateHeaderLabel: string]: {
|
|
11
11
|
[uploadedDataValue: string]: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type UploadedDataEnumFieldValues = {
|
|
15
15
|
[templateHeaderLabel: string]: string[];
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type State = {
|
|
18
18
|
currentStepIndex: number;
|
|
19
19
|
templateError: string | null;
|
|
20
20
|
uploadedData: any[];
|
|
@@ -44,8 +44,10 @@ export declare type State = {
|
|
|
44
44
|
formatRecord: FormatRecord;
|
|
45
45
|
onValidateRecord?: OnValidateRecord;
|
|
46
46
|
setMatcherSubstep: React.Dispatch<number>;
|
|
47
|
+
selectedRows: number[];
|
|
48
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<number[]>>;
|
|
47
49
|
};
|
|
48
|
-
export
|
|
50
|
+
export type Props = {
|
|
49
51
|
templateSlug: string;
|
|
50
52
|
apiToken: string;
|
|
51
53
|
options: ImporterOptions;
|
|
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
28
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
30
|
switch (op[0]) {
|
|
@@ -74,6 +74,7 @@ export var ImporterContextProvider = function (_a) {
|
|
|
74
74
|
var _l = useState(null), templateHeaderMatchings = _l[0], setTemplateHeaderMatchings = _l[1];
|
|
75
75
|
var _m = useState(null), enumFieldValueMatchings = _m[0], setEnumFieldValueMatchings = _m[1];
|
|
76
76
|
var _o = useState(null), uploadedDataEnumFieldValues = _o[0], setUploadedDataEnumFieldValues = _o[1];
|
|
77
|
+
var _p = useState([]), selectedRows = _p[0], setSelectedRows = _p[1];
|
|
77
78
|
var fuseApi = useMemo(function () { return new FuseApi(options.env, apiToken); }, [
|
|
78
79
|
options.env,
|
|
79
80
|
apiToken,
|
|
@@ -109,9 +110,14 @@ export var ImporterContextProvider = function (_a) {
|
|
|
109
110
|
setUploadedDataEnumFieldValues(_uploadedDataEnumFieldValues);
|
|
110
111
|
}, [templateHeaderMatchings]);
|
|
111
112
|
useEffect(function () {
|
|
112
|
-
if (uploadedData)
|
|
113
|
+
if (uploadedData) {
|
|
113
114
|
setHeadersFromDataset();
|
|
115
|
+
selectAllRows();
|
|
116
|
+
}
|
|
114
117
|
}, [uploadedData]);
|
|
118
|
+
var selectAllRows = function () {
|
|
119
|
+
setSelectedRows(uploadedData.map(function (_, index) { return index; }));
|
|
120
|
+
};
|
|
115
121
|
useEffect(function () {
|
|
116
122
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
123
|
var _a, organization_1, columns, importer_style_preferences, integrations_1, preview_first_time, error_1, errorMsg;
|
|
@@ -187,6 +193,8 @@ export var ImporterContextProvider = function (_a) {
|
|
|
187
193
|
onClose: onClose,
|
|
188
194
|
setPreviewFirstTime: setPreviewFirstTime,
|
|
189
195
|
onSubmit: onSubmit,
|
|
196
|
+
selectedRows: selectedRows,
|
|
197
|
+
setSelectedRows: setSelectedRows,
|
|
190
198
|
};
|
|
191
199
|
return (_jsx(ImporterContext.Provider, __assign({ value: value }, { children: children })));
|
|
192
200
|
};
|
|
@@ -2,7 +2,7 @@ import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader
|
|
|
2
2
|
import { EnumFieldValueMatchings, HeaderMatchings } from "../contexts/ImporterContextProvider";
|
|
3
3
|
export declare const addMeta: (record: any, index: number) => Record;
|
|
4
4
|
export declare const recordListToDataSet: (data: Record[], fields: Field[]) => RecordDataSet;
|
|
5
|
-
|
|
5
|
+
type transformToRecordsArgs = {
|
|
6
6
|
templateHeaderMatchings: HeaderMatchings;
|
|
7
7
|
enumFieldValueMatchings: EnumFieldValueMatchings;
|
|
8
8
|
uploadedDataHeaders: string[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FormatRecord, ImporterOptions, OnSubmit, OnValidateRecord } from "../types";
|
|
3
|
-
declare
|
|
2
|
+
export declare const ACCOUNT_ROUTES: {
|
|
3
|
+
TEMPLATES: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const ACCOUNT_VIEW_PATH = "/account";
|
|
6
|
+
export declare const TEMPLATES_ROUTE: string;
|
|
7
|
+
type ImporterProps = {
|
|
4
8
|
templateSlug: string;
|
|
5
9
|
apiToken: string;
|
|
6
10
|
options: ImporterOptions;
|