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
|
@@ -12,24 +12,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { CSS } from "@dnd-kit/utilities";
|
|
14
14
|
import { useSortable } from "@dnd-kit/sortable";
|
|
15
|
-
import { Div } from "
|
|
15
|
+
import { Div } from "../../../../styled/utils";
|
|
16
16
|
import { TableRow } from "./TableRow";
|
|
17
17
|
import React from "react";
|
|
18
18
|
import { areEqual } from "react-window";
|
|
19
|
-
import { useSpreadsheetContext } from "
|
|
20
|
-
var
|
|
19
|
+
import { useSpreadsheetContext } from "../../../../Importer";
|
|
20
|
+
var Row = React.memo(function (_a) {
|
|
21
21
|
var _b;
|
|
22
22
|
var data = _a.data, rowIndex = _a.rowIndex, style = _a.style;
|
|
23
|
-
var items = data.items, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey
|
|
23
|
+
var items = data.items, rowWidth = data.rowWidth, isDraggable = data.isDraggable, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey;
|
|
24
24
|
var item = items[rowIndex];
|
|
25
25
|
var selectedRows = useSpreadsheetContext().selectedRows;
|
|
26
26
|
var isRowSelected = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.includes((_b = item === null || item === void 0 ? void 0 : item._meta) === null || _b === void 0 ? void 0 : _b.id);
|
|
27
|
-
|
|
27
|
+
var Container = isDraggable ? DraggableRow : Div;
|
|
28
|
+
var containerProps = { style: style };
|
|
29
|
+
if (isDraggable)
|
|
30
|
+
containerProps = __assign(__assign({}, containerProps), { item: item });
|
|
31
|
+
return (_jsx(Container, __assign({}, containerProps, { children: _jsx(TableRow, { rowWidth: rowWidth, columns: columns, onRowClick: onRowClick, highlightFirstRow: highlightFirstRow, h: rowHeight, row: item, indexI: rowIndex, isLast: rowIndex === items.length - 1, pRelative: true, getItemKey: getItemKey, isRowSelected: isRowSelected || false }) })));
|
|
28
32
|
}, areEqual);
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var items = data.items, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey;
|
|
32
|
-
var item = items[rowIndex];
|
|
33
|
+
var DraggableRow = React.memo(function (_a) {
|
|
34
|
+
var item = _a.item, baseStyle = _a.style, children = _a.children;
|
|
33
35
|
var _b = useSortable({
|
|
34
36
|
id: item.id,
|
|
35
37
|
}), listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform;
|
|
@@ -38,6 +40,6 @@ var DraggableCell = React.memo(function (_a) {
|
|
|
38
40
|
};
|
|
39
41
|
var dragAndDropHandler = __assign({}, listeners);
|
|
40
42
|
item.dragAndDropHandler = dragAndDropHandler;
|
|
41
|
-
return (_jsx(Div, __assign({ style: __assign(__assign({}, baseStyle), dragAndDropStyles), ref: setNodeRef }, { children:
|
|
43
|
+
return (_jsx(Div, __assign({ style: __assign(__assign({}, baseStyle), dragAndDropStyles), ref: setNodeRef }, { children: children })));
|
|
42
44
|
}, areEqual);
|
|
43
|
-
export {
|
|
45
|
+
export { Row, DraggableRow };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TableViewColumn } from "../types";
|
|
2
|
+
export declare const defaultTableRowHeightPx = 60;
|
|
3
|
+
export declare const defaultTableHeaderHeightPx = 60;
|
|
4
|
+
export declare const getColumnWidthsPx: (columns: TableViewColumn[], rowWidth: number) => string[];
|
|
5
|
+
export declare const TableViewCellContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps, never>;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import styled, { css } from "styled-components";
|
|
6
|
+
import { Div } from "../../../../styled/utils";
|
|
7
|
+
export var defaultTableRowHeightPx = 60;
|
|
8
|
+
export var defaultTableHeaderHeightPx = 60;
|
|
9
|
+
export var getColumnWidthsPx = function (columns, rowWidth) {
|
|
10
|
+
var round4 = function (n) { return Number((Math.floor(n * 10000) / 10000).toFixed(4)); };
|
|
11
|
+
var totalColumnWidthCount = columns.reduce(function (sum, c) {
|
|
12
|
+
return sum + (c.width ? c.width : 1);
|
|
13
|
+
}, 0);
|
|
14
|
+
var remainingPercentage = 1;
|
|
15
|
+
var percentages = columns.map(function (column, index) {
|
|
16
|
+
if (index === columns.length - 1) {
|
|
17
|
+
// for the last column, just use the remaining percentage
|
|
18
|
+
// to avoid floating point errors
|
|
19
|
+
return round4(remainingPercentage);
|
|
20
|
+
}
|
|
21
|
+
var percentage = (column.width || 1) / totalColumnWidthCount;
|
|
22
|
+
percentage = round4(percentage);
|
|
23
|
+
remainingPercentage -= percentage;
|
|
24
|
+
remainingPercentage = round4(remainingPercentage);
|
|
25
|
+
return percentage;
|
|
26
|
+
});
|
|
27
|
+
var res = percentages.map(function (p) { return Math.floor(p * rowWidth); });
|
|
28
|
+
return res.map(function (r) { return r + "px"; });
|
|
29
|
+
};
|
|
30
|
+
export var TableViewCellContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n padding-left: 16px;\n align-items: center;\n color: ", ";\n\n ", "\n ", ";\n"], ["\n display: flex;\n padding-left: 16px;\n align-items: center;\n color: ", ";\n\n ", "\n ", ";\n"])), function (p) { return p.theme.colors.textPrim; }, function (_a) {
|
|
31
|
+
var onClick = _a.onClick;
|
|
32
|
+
return onClick && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n :hover {\n cursor: pointer;\n }\n "], ["\n :hover {\n cursor: pointer;\n }\n "])));
|
|
33
|
+
}, function (_a) {
|
|
34
|
+
var theme = _a.theme;
|
|
35
|
+
return theme.css.body3;
|
|
36
|
+
});
|
|
37
|
+
var templateObject_1, templateObject_2;
|
|
@@ -1,46 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { SortBy } from "../TableDataProvider";
|
|
4
|
-
export * from "./common";
|
|
2
|
+
import { TableViewProps } from "./types";
|
|
5
3
|
export * from "./TableHeaders";
|
|
6
|
-
export * from "./TableRow";
|
|
4
|
+
export * from "./TableRows/TableRow";
|
|
5
|
+
export * from "./common";
|
|
7
6
|
type TableViewWrapperProps = {
|
|
8
7
|
isLoading: boolean;
|
|
9
8
|
checkboxColumnWidth?: number;
|
|
10
9
|
};
|
|
11
10
|
export declare const TableViewWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableViewWrapperProps, never>;
|
|
12
|
-
export
|
|
13
|
-
header?: string;
|
|
14
|
-
Header?: (p: any) => JSX.Element;
|
|
15
|
-
Content?: (p: any) => JSX.Element;
|
|
16
|
-
dataAccessor?: string;
|
|
17
|
-
preventRowClick?: boolean;
|
|
18
|
-
disableSort?: boolean;
|
|
19
|
-
width?: number;
|
|
20
|
-
};
|
|
21
|
-
type TableSection = {
|
|
22
|
-
rowStartIndex?: number;
|
|
23
|
-
rowStopIndex?: number;
|
|
24
|
-
data?: any[];
|
|
25
|
-
};
|
|
26
|
-
export type TableViewProps = {
|
|
27
|
-
data: any[];
|
|
28
|
-
columns: TableViewColumn[];
|
|
29
|
-
sortBy?: SortBy;
|
|
30
|
-
setSortBy?: React.Dispatch<React.SetStateAction<SortBy>>;
|
|
31
|
-
isLoading?: boolean;
|
|
32
|
-
pageSize?: number;
|
|
33
|
-
highlightFirstRow?: boolean;
|
|
34
|
-
rowWidth?: number;
|
|
35
|
-
rowHeight?: number;
|
|
36
|
-
tableHeadersHeight?: number;
|
|
37
|
-
onSectionRendered?: (section: TableSection) => void;
|
|
38
|
-
onTableScroll?: (scrollTop: number) => void;
|
|
39
|
-
onRowClick?: (row: any) => void;
|
|
40
|
-
getItemKey?: (row: any) => string;
|
|
41
|
-
shouldBeDraggable?: boolean;
|
|
42
|
-
isInsideImporter?: boolean;
|
|
43
|
-
checkboxColumnWidth?: number;
|
|
44
|
-
isSpreadsheetTable?: boolean;
|
|
45
|
-
} & DivCSSProps;
|
|
46
|
-
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, isInsideImporter, checkboxColumnWidth, ...props }: TableViewProps) => JSX.Element>;
|
|
11
|
+
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: TableViewProps) => JSX.Element>;
|
|
@@ -25,57 +25,55 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
28
|
+
import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
29
|
+
import React, { Fragment, useCallback, useRef } from "react";
|
|
30
30
|
import AutoSizer from "react-virtualized-auto-sizer";
|
|
31
|
+
import { FixedSizeGrid as Grid, areEqual } from "react-window";
|
|
31
32
|
import styled, { css } from "styled-components";
|
|
32
|
-
import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
33
33
|
import { Div } from "../../../styled/utils";
|
|
34
34
|
import { Spinner } from "../../Spinner";
|
|
35
|
-
import { defaultTableRowHeightPx, defaultTableHeaderHeightPx } from "./common";
|
|
36
35
|
import { TableHeaders } from "./TableHeaders";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
export * from "./common";
|
|
36
|
+
import { Row } from "./TableRows";
|
|
37
|
+
import { defaultTableHeaderHeightPx, defaultTableRowHeightPx } from "./common";
|
|
40
38
|
export * from "./TableHeaders";
|
|
41
|
-
export * from "./TableRow";
|
|
42
|
-
export
|
|
39
|
+
export * from "./TableRows/TableRow";
|
|
40
|
+
export * from "./common";
|
|
41
|
+
export var TableViewWrapper = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n box-shadow: 0 0 0 1px ", ";\n overflow: hidden;\n\n ", "\n\n // prevents clipped dropdowns\n .ReactVirtualized__Grid__innerScrollContainer {\n overflow: visible !important;\n }\n .ReactVirtualized__Table__row {\n overflow: visible !important;\n }\n\n"], ["\n ", "\n box-shadow: 0 0 0 1px ", ";\n overflow: hidden;\n\n ", "\n\n // prevents clipped dropdowns\n .ReactVirtualized__Grid__innerScrollContainer {\n overflow: visible !important;\n }\n .ReactVirtualized__Table__row {\n overflow: visible !important;\n }\n\n"])), function (p) {
|
|
43
42
|
return p.isLoading && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0.5;\n "], ["\n opacity: 0.5;\n "])));
|
|
44
43
|
}, function (p) { return p.theme.colors.gray300; }, function (_a) {
|
|
45
44
|
var checkboxColumnWidth = _a.checkboxColumnWidth;
|
|
46
45
|
return checkboxColumnWidth && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n max-width: calc(100vw - ", "px);\n "], ["\n max-width: calc(100vw - ", "px);\n "])), checkboxColumnWidth);
|
|
47
|
-
}
|
|
46
|
+
});
|
|
48
47
|
var SpinnerWrapper = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n pointer-events: none;\n z-index: 100;\n"], ["\n pointer-events: none;\n z-index: 100;\n"])));
|
|
49
48
|
var tableHeaderId = "tableHeaderId";
|
|
50
|
-
var
|
|
51
|
-
var
|
|
49
|
+
var VirtualizedGrid = styled(Grid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), function (p) { return p.theme.css.scrollbarDark; });
|
|
50
|
+
var loadingUI = (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}) })) })));
|
|
51
|
+
var buildGridStyles = function (rowWidthScalingFactor) {
|
|
52
52
|
/* using style={{ willChange: "unset" }} is important for having items
|
|
53
53
|
like backdrops with position fixed inside of the table working as
|
|
54
54
|
expected. Required for dropdowns in cells */
|
|
55
55
|
var gridStyles = {
|
|
56
56
|
outline: "none",
|
|
57
57
|
willChange: "unset",
|
|
58
|
+
boxSizing: "border-box",
|
|
58
59
|
};
|
|
59
|
-
if (
|
|
60
|
+
if (rowWidthScalingFactor === 1)
|
|
60
61
|
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "hidden", overflowY: "auto" });
|
|
61
|
-
else if (
|
|
62
|
-
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "
|
|
62
|
+
else if (rowWidthScalingFactor > 1)
|
|
63
|
+
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "auto" });
|
|
63
64
|
return gridStyles;
|
|
64
65
|
};
|
|
65
66
|
export var TableView = React.memo(function (_a) {
|
|
66
|
-
var data = _a.data, columns = _a.columns, pageSize = _a.pageSize, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.sortBy, sortBy = _c === void 0 ? { field: null, direction: null } : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.highlightFirstRow, highlightFirstRow = _e === void 0 ? false : _e, _f = _a.setSortBy, setSortBy = _f === void 0 ? null : _f, _g = _a.
|
|
67
|
-
/*
|
|
68
|
-
multiply the rowWidth by 0.95 to let the user know they can scroll
|
|
69
|
-
horizontally (will display partial column on the right)
|
|
70
|
-
*/
|
|
71
|
-
var _rowWidth = rowWidth > 1 ? rowWidth * 0.95 : rowWidth;
|
|
67
|
+
var data = _a.data, columns = _a.columns, pageSize = _a.pageSize, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.sortBy, sortBy = _c === void 0 ? { field: null, direction: null } : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.highlightFirstRow, highlightFirstRow = _e === void 0 ? false : _e, _f = _a.setSortBy, setSortBy = _f === void 0 ? null : _f, _g = _a.rowWidthScalingFactor, rowWidthScalingFactor = _g === void 0 ? 1 : _g, onSectionRendered = _a.onSectionRendered, _h = _a.tableHeadersHeight, tableHeadersHeight = _h === void 0 ? defaultTableHeaderHeightPx : _h, _j = _a.rowHeight, rowHeight = _j === void 0 ? defaultTableRowHeightPx : _j, _k = _a.h, h = _k === void 0 ? 500 : _k, _l = _a.onTableScroll, onTableScroll = _l === void 0 ? null : _l, _m = _a.getItemKey, getItemKey = _m === void 0 ? null : _m, _o = _a.isDraggable, isDraggable = _o === void 0 ? false : _o, checkboxColumnWidth = _a.checkboxColumnWidth, _p = _a.isFiltering, isFiltering = _p === void 0 ? false : _p, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidthScalingFactor", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering"]);
|
|
72
68
|
var headerContainerRef = useRef();
|
|
73
|
-
var listRef = useRef();
|
|
74
|
-
var tableHeadersUI = data.length > 0 && (_jsx(TableHeaders, { id: tableHeaderId, containerRef: headerContainerRef, height: tableHeadersHeight, rowHeight: rowHeight, rowWidth: _rowWidth, scrollLeft: 0, columns: columns, sortBy: sortBy, setSortBy: setSortBy, isSpreadsheetTable: isInsideImporter }));
|
|
75
69
|
var onScroll = function (_a) {
|
|
76
70
|
var scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
|
|
77
71
|
if (headerContainerRef.current && headerContainerRef.current.scrollTo) {
|
|
78
|
-
|
|
72
|
+
requestAnimationFrame(function () {
|
|
73
|
+
headerContainerRef.current.scrollTo({
|
|
74
|
+
left: scrollLeft,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
if (onTableScroll) {
|
|
81
79
|
onTableScroll(scrollTop);
|
|
@@ -91,29 +89,42 @@ export var TableView = React.memo(function (_a) {
|
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
91
|
}, [data, onSectionRendered]);
|
|
94
|
-
var loadingUI = isLoading && (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}) })) })));
|
|
95
92
|
var tableHeight = pageSize
|
|
96
93
|
? pageSize * rowHeight + tableHeadersHeight
|
|
97
94
|
: h;
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
95
|
+
var canRenderTableHeaders = isFiltering ? true : data.length > 0;
|
|
96
|
+
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading, checkboxColumnWidth: checkboxColumnWidth, h: tableHeight }, props, { children: [isLoading && loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
97
|
+
var autosizerWidth = _a.width, autosizerHeight = _a.height;
|
|
98
|
+
// using Math.floor to avoid floating point errors with the grid and table cell widths
|
|
99
|
+
var rowWidth = Math.floor(autosizerWidth * rowWidthScalingFactor);
|
|
100
|
+
var gridProps = {
|
|
101
|
+
itemData: {
|
|
102
|
+
items: data,
|
|
103
|
+
isDraggable: isDraggable,
|
|
104
|
+
rowWidth: rowWidth,
|
|
105
|
+
onRowClick: onRowClick,
|
|
106
|
+
columns: columns,
|
|
107
|
+
highlightFirstRow: highlightFirstRow,
|
|
108
|
+
rowHeight: rowHeight,
|
|
109
|
+
getItemKey: getItemKey,
|
|
110
|
+
},
|
|
111
|
+
style: buildGridStyles(rowWidthScalingFactor),
|
|
112
|
+
width: autosizerWidth,
|
|
113
|
+
columnCount: 1,
|
|
114
|
+
onItemsRendered: onItemsRendered,
|
|
115
|
+
onScroll: onScroll,
|
|
116
|
+
columnWidth: rowWidth,
|
|
117
|
+
height: autosizerHeight - tableHeadersHeight,
|
|
118
|
+
rowHeight: rowHeight,
|
|
119
|
+
rowCount: data.length,
|
|
120
|
+
};
|
|
121
|
+
var GridContainer = isDraggable
|
|
122
|
+
? SortableContext
|
|
123
|
+
: Fragment;
|
|
124
|
+
var gridContainerProps = isDraggable
|
|
125
|
+
? { items: data, strategy: verticalListSortingStrategy }
|
|
126
|
+
: {};
|
|
127
|
+
return (_jsxs(_Fragment, { children: [canRenderTableHeaders && (_jsx(TableHeaders, { rowWidth: rowWidth, containerWidth: autosizerWidth, id: tableHeaderId, containerRef: headerContainerRef, height: tableHeadersHeight, rowHeight: rowHeight, scrollLeft: 0, columns: columns, sortBy: sortBy, setSortBy: setSortBy })), _jsx(GridContainer, __assign({}, gridContainerProps, { children: _jsx(VirtualizedGrid, __assign({}, gridProps, { children: Row })) }))] }));
|
|
117
128
|
} })] })));
|
|
118
129
|
}, areEqual);
|
|
119
130
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DivCSSProps } from "../../../styled/utils";
|
|
3
|
+
import { SortBy } from "../TableDataProvider";
|
|
4
|
+
export type TableViewColumn = {
|
|
5
|
+
header?: string;
|
|
6
|
+
Header?: (p: any) => JSX.Element;
|
|
7
|
+
Content?: (p: any) => JSX.Element;
|
|
8
|
+
dataAccessor?: string;
|
|
9
|
+
preventRowClick?: boolean;
|
|
10
|
+
disableSort?: boolean;
|
|
11
|
+
width?: number;
|
|
12
|
+
};
|
|
13
|
+
type TableSection = {
|
|
14
|
+
rowStartIndex?: number;
|
|
15
|
+
rowStopIndex?: number;
|
|
16
|
+
data?: any[];
|
|
17
|
+
};
|
|
18
|
+
export type TableViewProps = {
|
|
19
|
+
data: any[];
|
|
20
|
+
columns: TableViewColumn[];
|
|
21
|
+
sortBy?: SortBy;
|
|
22
|
+
setSortBy?: React.Dispatch<React.SetStateAction<SortBy>>;
|
|
23
|
+
isLoading?: boolean;
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
highlightFirstRow?: boolean;
|
|
26
|
+
rowWidthScalingFactor?: number;
|
|
27
|
+
rowHeight?: number;
|
|
28
|
+
tableHeadersHeight?: number;
|
|
29
|
+
onSectionRendered?: (section: TableSection) => void;
|
|
30
|
+
onTableScroll?: (scrollTop: number) => void;
|
|
31
|
+
onRowClick?: (row: any) => void;
|
|
32
|
+
getItemKey?: (row: any) => string;
|
|
33
|
+
isDraggable?: boolean;
|
|
34
|
+
checkboxColumnWidth?: number;
|
|
35
|
+
isFiltering?: boolean;
|
|
36
|
+
} & DivCSSProps;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,8 @@ type Props = {
|
|
|
4
4
|
columns: any[];
|
|
5
5
|
onRowClick?: (row: any) => void;
|
|
6
6
|
templateSlug?: string;
|
|
7
|
-
|
|
7
|
+
isDraggable?: boolean;
|
|
8
8
|
} & DivCSSProps;
|
|
9
|
-
declare const Table: ({ columns, onRowClick, blankState, templateSlug,
|
|
9
|
+
declare const Table: ({ columns, onRowClick, blankState, templateSlug, isDraggable, ...props }: Props) => JSX.Element;
|
|
10
10
|
export { Table };
|
|
11
11
|
export * from "./TableDataProvider";
|
|
@@ -75,7 +75,7 @@ var TableView = styled(TableViewBase)(templateObject_2 || (templateObject_2 = __
|
|
|
75
75
|
return p.withPagination && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 0px;\n "], ["\n border-radius: 0px;\n "])));
|
|
76
76
|
});
|
|
77
77
|
var Table = function (_a) {
|
|
78
|
-
var columns = _a.columns, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.blankState, blankState = _c === void 0 ? null : _c, templateSlug = _a.templateSlug, _d = _a.
|
|
78
|
+
var columns = _a.columns, _b = _a.onRowClick, onRowClick = _b === void 0 ? null : _b, _c = _a.blankState, blankState = _c === void 0 ? null : _c, templateSlug = _a.templateSlug, _d = _a.isDraggable, isDraggable = _d === void 0 ? false : _d, props = __rest(_a, ["columns", "onRowClick", "blankState", "templateSlug", "isDraggable"]);
|
|
79
79
|
var _e = useTableContext(), data = _e.data, isLoading = _e.isLoading, sortBy = _e.sortBy, setSortBy = _e.setSortBy, totalPages = _e.totalPages;
|
|
80
80
|
var reorderRows = useReorderRows(templateSlug).reorderRows;
|
|
81
81
|
var withPagination = data.length > 0 && totalPages > 1;
|
|
@@ -115,14 +115,14 @@ var Table = function (_a) {
|
|
|
115
115
|
});
|
|
116
116
|
}); };
|
|
117
117
|
var dndContextValues = {
|
|
118
|
-
sensors:
|
|
119
|
-
collisionDetection:
|
|
120
|
-
onDragEnd:
|
|
121
|
-
modifiers:
|
|
118
|
+
sensors: isDraggable ? sensors : undefined,
|
|
119
|
+
collisionDetection: isDraggable ? closestCenter : undefined,
|
|
120
|
+
onDragEnd: isDraggable ? handleDragEnd : undefined,
|
|
121
|
+
modifiers: isDraggable
|
|
122
122
|
? [restrictToVerticalAxis, restrictToWindowEdges]
|
|
123
123
|
: undefined,
|
|
124
124
|
};
|
|
125
|
-
return (_jsxs(Div, __assign({}, props, { children: [data.length ? (_jsx(DndContext, __assign({ sensors: dndContextValues.sensors, collisionDetection: dndContextValues.collisionDetection, onDragEnd: dndContextValues.onDragEnd, modifiers: dndContextValues.modifiers }, { children: _jsx(TableView, __assign({ pageSize: data.length, withPagination: withPagination,
|
|
125
|
+
return (_jsxs(Div, __assign({}, props, { children: [data.length ? (_jsx(DndContext, __assign({ sensors: dndContextValues.sensors, collisionDetection: dndContextValues.collisionDetection, onDragEnd: dndContextValues.onDragEnd, modifiers: dndContextValues.modifiers }, { children: _jsx(TableView, __assign({ pageSize: data.length, withPagination: withPagination, isDraggable: isDraggable }, {
|
|
126
126
|
isLoading: isLoading,
|
|
127
127
|
data: data,
|
|
128
128
|
columns: columns,
|
|
@@ -16,6 +16,7 @@ export type Props = {
|
|
|
16
16
|
onToggle?: (isOpen: boolean) => void;
|
|
17
17
|
placement?: Placement;
|
|
18
18
|
icon?: JSX.Element;
|
|
19
|
+
prefix?: string;
|
|
19
20
|
} & DivCSSProps;
|
|
20
|
-
declare const Autocomplete: ({ label, isDisabled, isInputDisabled, placeholder, value, icon, onChange, placement, options, onToggle, id, labelTooltip, ...props }: Props) => JSX.Element;
|
|
21
|
+
declare const Autocomplete: ({ label, isDisabled, isInputDisabled, placeholder, value, icon, onChange, placement, options, onToggle, id, labelTooltip, prefix, ...props }: Props) => JSX.Element;
|
|
21
22
|
export { Autocomplete };
|
|
@@ -47,7 +47,7 @@ var ClickableArea = styled(Div)(function (_a) {
|
|
|
47
47
|
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), isInputDisabled && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n :hover {\n cursor: pointer;\n opacity: 0.9;\n }\n "], ["\n :hover {\n cursor: pointer;\n opacity: 0.9;\n }\n "]))));
|
|
48
48
|
});
|
|
49
49
|
var Autocomplete = function (_a) {
|
|
50
|
-
var _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "general:autocomplete.placeholder" : _e, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, id = _a.id, labelTooltip = _a.labelTooltip, props = __rest(_a, ["label", "isDisabled", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle", "id", "labelTooltip"]);
|
|
50
|
+
var _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "general:autocomplete.placeholder" : _e, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, id = _a.id, labelTooltip = _a.labelTooltip, prefix = _a.prefix, props = __rest(_a, ["label", "isDisabled", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle", "id", "labelTooltip", "prefix"]);
|
|
51
51
|
var _f = useState(false), updatedText = _f[0], setUpdatedText = _f[1];
|
|
52
52
|
var selectedLabel = useMemo(function () { var _a; return ((_a = options === null || options === void 0 ? void 0 : options.find(function (o) { return (o === null || o === void 0 ? void 0 : o.value) === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
|
|
53
53
|
var _g = useState(selectedLabel), text = _g[0], setText = _g[1];
|
|
@@ -92,7 +92,7 @@ var Autocomplete = function (_a) {
|
|
|
92
92
|
setText(selectedLabel);
|
|
93
93
|
setIsMenuOpen(false);
|
|
94
94
|
}
|
|
95
|
-
}, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }, index)); }) })))] })));
|
|
95
|
+
}, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: prefix ? "".concat(prefix).concat(text) : text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }, index)); }) })))] })));
|
|
96
96
|
};
|
|
97
97
|
var chevronDownIcon = (_jsx("svg", __assign({ width: "16", height: "9", viewBox: "0 0 16 9", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M14.9263 1L7.9631 7.96317L0.999928 1", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
|
|
98
98
|
var clearIcon = (_jsxs("svg", __assign({ width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M4 4L12.5161 12.5161", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M4 12.5161L12.5161 3.99998", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
@@ -31,7 +31,7 @@ import { FormInputLabel } from "..";
|
|
|
31
31
|
import { useDebounce } from "../../hooks";
|
|
32
32
|
import { Div } from "../../styled/utils";
|
|
33
33
|
import Tooltip from "./tooltip";
|
|
34
|
-
export var HTMLInput = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n\n
|
|
34
|
+
export var HTMLInput = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n\n padding: ", ";\n height: 68px;\n margin: 0px;\n box-shadow: none;\n\n outline: none;\n\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: 8px;\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 ", ";\n\n ::placeholder {\n color: ", ";\n }\n\n :focus {\n border: 2px solid ", ";\n\n /* 3d at the end adds .24 opacity (using 8 digit hex)*/\n box-shadow: 0px 0px 8px ", "3d;\n }\n\n :hover {\n box-shadow: none;\n background: transparent;\n }\n\n ", "\n ", "\n"], ["\n position: relative;\n\n padding: ", ";\n height: 68px;\n margin: 0px;\n box-shadow: none;\n\n outline: none;\n\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: 8px;\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 ", ";\n\n ::placeholder {\n color: ", ";\n }\n\n :focus {\n border: 2px solid ", ";\n\n /* 3d at the end adds .24 opacity (using 8 digit hex)*/\n box-shadow: 0px 0px 8px ", "3d;\n }\n\n :hover {\n box-shadow: none;\n background: transparent;\n }\n\n ", "\n ", "\n"])), function (_a) {
|
|
35
35
|
var padding = _a.padding;
|
|
36
36
|
return (padding ? padding : "20px 16px");
|
|
37
37
|
}, function (props) { return props.theme.colors.gray300; }, function (props) { return props.theme.css.body1; }, function (props) { return props.theme.colors.placeholder; }, function (props) { return props.theme.colors.blue500; }, function (props) { return props.theme.colors.blue500; }, function (props) {
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -6,12 +6,19 @@ declare class FuseImporter {
|
|
|
6
6
|
zIndex: number;
|
|
7
7
|
options: ImporterOptions;
|
|
8
8
|
constructor(apiToken: string, templateSlug: string, options?: ImporterOptions);
|
|
9
|
+
private cleanupIframe;
|
|
9
10
|
formatRecord: FormatRecord;
|
|
10
11
|
onValidateRecord: OnValidateRecord;
|
|
11
12
|
onSubmit: OnSubmit;
|
|
12
13
|
onClose: () => void;
|
|
14
|
+
private windowScrollPosition;
|
|
13
15
|
close(): void;
|
|
14
16
|
show(): Promise<void>;
|
|
17
|
+
private renderImporterComponent;
|
|
18
|
+
private createDivComponent;
|
|
19
|
+
private createIframe;
|
|
20
|
+
private createImporterComponent;
|
|
21
|
+
private configureIframe;
|
|
15
22
|
private configureI18n;
|
|
16
23
|
}
|
|
17
24
|
export default FuseImporter;
|
package/lib/esm/index.js
CHANGED
|
@@ -45,16 +45,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
import
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
49
|
import ReactDOM from "react-dom";
|
|
50
50
|
import { Importer } from "./Importer";
|
|
51
51
|
import { fuseImporterId } from "./common";
|
|
52
52
|
import i18n from "i18next";
|
|
53
53
|
import { initReactI18next } from "react-i18next";
|
|
54
54
|
import * as locales from "./locales";
|
|
55
|
+
import { StyleSheetManager } from "styled-components";
|
|
56
|
+
import { fontsURL } from "./styled/fontsURL";
|
|
57
|
+
var addLinkToHead = function (document, head, href, rel, crossOrigin) {
|
|
58
|
+
if (crossOrigin === void 0) { crossOrigin = ""; }
|
|
59
|
+
var link = document.createElement("link");
|
|
60
|
+
link.href = href;
|
|
61
|
+
link.rel = rel;
|
|
62
|
+
link.crossOrigin = crossOrigin;
|
|
63
|
+
head.appendChild(link);
|
|
64
|
+
};
|
|
55
65
|
var FuseImporter = /** @class */ (function () {
|
|
56
66
|
function FuseImporter(apiToken, templateSlug, options) {
|
|
57
67
|
if (options === void 0) { options = {}; }
|
|
68
|
+
this.cleanupIframe = null;
|
|
69
|
+
this.windowScrollPosition = {
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0,
|
|
72
|
+
};
|
|
58
73
|
this.apiToken = apiToken;
|
|
59
74
|
this.templateSlug = templateSlug;
|
|
60
75
|
this.options = __assign({ env: "production", zIndex: 1000, batchValidationDelayMs: 500 }, options);
|
|
@@ -62,39 +77,93 @@ var FuseImporter = /** @class */ (function () {
|
|
|
62
77
|
FuseImporter.prototype.close = function () {
|
|
63
78
|
var _a;
|
|
64
79
|
(_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
if (this.cleanupIframe) {
|
|
81
|
+
this.cleanupIframe();
|
|
82
|
+
this.cleanupIframe = null;
|
|
83
|
+
}
|
|
84
|
+
var iframe = document.getElementById(fuseImporterId);
|
|
85
|
+
document.body.removeChild(iframe);
|
|
86
|
+
// allow the scroll when the importer is closed
|
|
87
|
+
document.body.style.overflow = "auto";
|
|
88
|
+
window.scrollTo(this.windowScrollPosition.x, this.windowScrollPosition.y);
|
|
68
89
|
};
|
|
69
90
|
FuseImporter.prototype.show = function () {
|
|
70
91
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var
|
|
72
|
-
var _this = this;
|
|
92
|
+
var isRunningTest, iframe, importerComponent;
|
|
73
93
|
return __generator(this, function (_a) {
|
|
74
94
|
switch (_a.label) {
|
|
75
95
|
case 0: return [4 /*yield*/, this.configureI18n()];
|
|
76
96
|
case 1:
|
|
77
97
|
_a.sent();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
isRunningTest = typeof (window === null || window === void 0 ? void 0 : window.Cypress) !== "undefined";
|
|
99
|
+
if (isRunningTest) {
|
|
100
|
+
this.renderImporterComponent();
|
|
101
|
+
i18n.reloadResources();
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
iframe = this.createIframe();
|
|
105
|
+
importerComponent = this.createImporterComponent();
|
|
106
|
+
// saves the position of the page before the importer was opened
|
|
107
|
+
this.windowScrollPosition = {
|
|
108
|
+
x: window.scrollX,
|
|
109
|
+
y: window.scrollY,
|
|
110
|
+
};
|
|
111
|
+
// block the scroll when opening the importer
|
|
112
|
+
window.scrollTo(0, 0);
|
|
113
|
+
document.body.style.overflow = "hidden";
|
|
114
|
+
this.configureIframe(iframe, importerComponent);
|
|
93
115
|
return [2 /*return*/];
|
|
94
116
|
}
|
|
95
117
|
});
|
|
96
118
|
});
|
|
97
119
|
};
|
|
120
|
+
FuseImporter.prototype.renderImporterComponent = function () {
|
|
121
|
+
var importerDiv = this.createDivComponent();
|
|
122
|
+
var importerComponent = this.createImporterComponent();
|
|
123
|
+
ReactDOM.render(importerComponent, importerDiv);
|
|
124
|
+
};
|
|
125
|
+
FuseImporter.prototype.createDivComponent = function () {
|
|
126
|
+
var div = document.createElement("div");
|
|
127
|
+
div.setAttribute("id", fuseImporterId);
|
|
128
|
+
document.body.appendChild(div);
|
|
129
|
+
return div;
|
|
130
|
+
};
|
|
131
|
+
FuseImporter.prototype.createIframe = function () {
|
|
132
|
+
var iframe = document.createElement("iframe");
|
|
133
|
+
iframe.setAttribute("id", fuseImporterId);
|
|
134
|
+
iframe.style.cssText =
|
|
135
|
+
"border: none; width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index: 1000;";
|
|
136
|
+
document.body.appendChild(iframe);
|
|
137
|
+
return iframe;
|
|
138
|
+
};
|
|
139
|
+
FuseImporter.prototype.createImporterComponent = function () {
|
|
140
|
+
var _this = this;
|
|
141
|
+
return (_jsx(Importer, { apiToken: this.apiToken, templateSlug: this.templateSlug, options: this.options, formatRecord: this.formatRecord, onValidateRecord: this.onValidateRecord, onSubmit: this.onSubmit, onClose: function () {
|
|
142
|
+
_this.close();
|
|
143
|
+
} }));
|
|
144
|
+
};
|
|
145
|
+
FuseImporter.prototype.configureIframe = function (iframe, importerComponent) {
|
|
146
|
+
var onLoadCallback = function () {
|
|
147
|
+
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
|
148
|
+
iframeDocument.body.style.margin = "0";
|
|
149
|
+
iframeDocument.body.style.padding = "0";
|
|
150
|
+
var head = iframeDocument.getElementsByTagName("head")[0];
|
|
151
|
+
for (var _i = 0, fontsURL_1 = fontsURL; _i < fontsURL_1.length; _i++) {
|
|
152
|
+
var link = fontsURL_1[_i];
|
|
153
|
+
addLinkToHead(iframeDocument, head, link.href, link.rel, link.crossOrigin);
|
|
154
|
+
}
|
|
155
|
+
ReactDOM.render(_jsx(StyleSheetManager, __assign({ target: iframeDocument.head }, { children: importerComponent })), iframeDocument.body);
|
|
156
|
+
i18n.reloadResources();
|
|
157
|
+
iframe.removeEventListener("load", onLoadCallback);
|
|
158
|
+
};
|
|
159
|
+
iframe.addEventListener("load", onLoadCallback);
|
|
160
|
+
iframe.src = "about:blank";
|
|
161
|
+
var cleanup = function () {
|
|
162
|
+
iframe.removeEventListener("load", onLoadCallback);
|
|
163
|
+
};
|
|
164
|
+
this.cleanupIframe = cleanup;
|
|
165
|
+
return cleanup;
|
|
166
|
+
};
|
|
98
167
|
FuseImporter.prototype.configureI18n = function () {
|
|
99
168
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
169
|
var browserLanguage, language;
|