fuse-importer 0.25.7 → 0.25.9
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/tableColumns.js +1 -1
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +1 -1
- package/lib/esm/Importer/Review/ReviewWithContext.js +4 -1
- package/lib/esm/Importer/Stepper/index.js +4 -3
- package/lib/esm/Importer/Uploader/HeadersPreview.js +4 -1
- package/lib/esm/Importer/common/GlobalStyle.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +4 -5
- 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 +3 -2
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +4 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +9 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
- package/lib/esm/Importer/common/utils.js +1 -1
- package/lib/esm/common/Table/TableActions/SearchRows.js +1 -1
- package/lib/esm/common/Table/TableView/CustomScrollbar.d.ts +2 -0
- package/lib/esm/common/Table/TableView/CustomScrollbar.js +34 -0
- package/lib/esm/common/Table/TableView/TableCells.js +2 -2
- package/lib/esm/common/Table/TableView/TableHeaders.d.ts +4 -4
- package/lib/esm/common/Table/TableView/TableHeaders.js +8 -11
- package/lib/esm/common/Table/TableView/TableRow.d.ts +2 -2
- package/lib/esm/common/Table/TableView/TableRow.js +4 -4
- package/lib/esm/common/Table/TableView/common.d.ts +1 -1
- package/lib/esm/common/Table/TableView/common.js +2 -5
- package/lib/esm/common/Table/TableView/index.d.ts +3 -3
- package/lib/esm/common/Table/TableView/index.js +38 -8
- package/lib/esm/common/inputs/Checkbox.js +1 -1
- package/lib/esm/common/inputs/TextInput.js +1 -1
- package/lib/esm/index.d.ts +6 -0
- package/lib/esm/index.js +75 -21
- package/lib/esm/styled/fontsURL.d.ts +9 -0
- package/lib/esm/styled/fontsURL.js +27 -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 +12 -12
- package/package.json +2 -1
|
@@ -35,6 +35,7 @@ import { Spinner } from "../../Spinner";
|
|
|
35
35
|
import { defaultTableRowHeightPx, defaultTableHeaderHeightPx } from "./common";
|
|
36
36
|
import { TableHeaders } from "./TableHeaders";
|
|
37
37
|
import { Cell, DraggableCell } from "./TableCells";
|
|
38
|
+
import { CustomScrollbarsVirtualList } from "./CustomScrollbar";
|
|
38
39
|
export * from "./common";
|
|
39
40
|
export * from "./TableHeaders";
|
|
40
41
|
export * from "./TableRow";
|
|
@@ -46,7 +47,7 @@ export var TableViewWrapper = styled(Div)(templateObject_3 || (templateObject_3
|
|
|
46
47
|
}, function (p) { return p.theme.css.scrollbarDark; });
|
|
47
48
|
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"])));
|
|
48
49
|
var tableHeaderId = "tableHeaderId";
|
|
49
|
-
var StyledGrid = styled(Grid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ::-webkit-scrollbar {\n width:
|
|
50
|
+
var StyledGrid = styled(Grid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n scrollbar-width: thin;\n\n /* width */\n ::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background-color: #b1b1b2;\n border-radius: 3px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n"], ["\n scrollbar-width: thin;\n\n /* width */\n ::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background-color: #b1b1b2;\n border-radius: 3px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n"])));
|
|
50
51
|
var buildGridStyles = function (rowWidth) {
|
|
51
52
|
/* using style={{ willChange: "unset" }} is important for having items
|
|
52
53
|
like backdrops with position fixed inside of the table working as
|
|
@@ -58,18 +59,20 @@ var buildGridStyles = function (rowWidth) {
|
|
|
58
59
|
if (rowWidth === 1)
|
|
59
60
|
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "hidden", overflowY: "auto" });
|
|
60
61
|
else if (rowWidth > 1)
|
|
61
|
-
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "
|
|
62
|
+
gridStyles = __assign(__assign({}, gridStyles), { overflowX: "hidden" });
|
|
62
63
|
return gridStyles;
|
|
63
64
|
};
|
|
64
65
|
export var TableView = React.memo(function (_a) {
|
|
65
|
-
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.rowWidth, rowWidth = _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.shouldBeDraggable, shouldBeDraggable = _o === void 0 ? false : _o, _p = _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.rowWidth, rowWidth = _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.shouldBeDraggable, shouldBeDraggable = _o === void 0 ? false : _o, _p = _a.shouldHaveCustomScrollbar, shouldHaveCustomScrollbar = _p === void 0 ? false : _p, checkboxColumnWidth = _a.checkboxColumnWidth, _q = _a.isFiltering, isFiltering = _q === void 0 ? false : _q, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidth", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "shouldBeDraggable", "shouldHaveCustomScrollbar", "checkboxColumnWidth", "isFiltering"]);
|
|
66
67
|
/*
|
|
67
68
|
multiply the rowWidth by 0.95 to let the user know they can scroll
|
|
68
69
|
horizontally (will display partial column on the right)
|
|
69
70
|
*/
|
|
70
71
|
var _rowWidth = rowWidth > 1 ? rowWidth * 0.95 : rowWidth;
|
|
71
72
|
var headerContainerRef = useRef();
|
|
72
|
-
var
|
|
73
|
+
var listRef = useRef();
|
|
74
|
+
var canRenderTableHeaders = isFiltering ? true : data.length > 0;
|
|
75
|
+
var tableHeadersUI = canRenderTableHeaders && (_jsx(TableHeaders, { id: tableHeaderId, containerRef: headerContainerRef, height: tableHeadersHeight, rowHeight: rowHeight, rowWidth: _rowWidth, scrollLeft: 0, columns: columns, sortBy: sortBy, setSortBy: setSortBy, shouldHaveCustomScrollbar: shouldHaveCustomScrollbar }));
|
|
73
76
|
var onScroll = function (_a) {
|
|
74
77
|
var scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
|
|
75
78
|
if (headerContainerRef.current && headerContainerRef.current.scrollTo) {
|
|
@@ -100,18 +103,45 @@ export var TableView = React.memo(function (_a) {
|
|
|
100
103
|
highlightFirstRow: highlightFirstRow,
|
|
101
104
|
rowHeight: rowHeight,
|
|
102
105
|
getItemKey: getItemKey,
|
|
103
|
-
|
|
106
|
+
shouldHaveCustomScrollbar: shouldHaveCustomScrollbar,
|
|
104
107
|
}); }, [
|
|
105
108
|
data,
|
|
106
109
|
onRowClick,
|
|
107
110
|
columns,
|
|
108
111
|
highlightFirstRow,
|
|
109
112
|
rowHeight,
|
|
110
|
-
|
|
113
|
+
shouldHaveCustomScrollbar,
|
|
111
114
|
]);
|
|
112
|
-
|
|
115
|
+
var buildGridProps = function (width, isDraggable, columnWidth, height) { return ({
|
|
116
|
+
style: buildGridStyles(_rowWidth),
|
|
117
|
+
width: width,
|
|
118
|
+
columnCount: 1,
|
|
119
|
+
itemData: itemData,
|
|
120
|
+
onItemsRendered: onItemsRendered,
|
|
121
|
+
onScroll: onScroll,
|
|
122
|
+
columnWidth: isDraggable ? Math.floor(width * _rowWidth) : columnWidth,
|
|
123
|
+
height: height - tableHeadersHeight,
|
|
124
|
+
rowHeight: rowHeight,
|
|
125
|
+
rowCount: data.length,
|
|
126
|
+
}); };
|
|
127
|
+
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading, checkboxColumnWidth: checkboxColumnWidth }, (!shouldHaveCustomScrollbar ? { h: tableHeight } : {}), props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
113
128
|
var width = _a.width, height = _a.height;
|
|
114
|
-
|
|
129
|
+
var canUseCustomScrollbar = shouldHaveCustomScrollbar && !shouldBeDraggable;
|
|
130
|
+
var gridProps = {
|
|
131
|
+
style: buildGridStyles(_rowWidth),
|
|
132
|
+
width: width,
|
|
133
|
+
columnCount: 1,
|
|
134
|
+
itemData: itemData,
|
|
135
|
+
onItemsRendered: onItemsRendered,
|
|
136
|
+
onScroll: onScroll,
|
|
137
|
+
columnWidth: Math.floor(width * _rowWidth),
|
|
138
|
+
height: height - tableHeadersHeight,
|
|
139
|
+
rowHeight: rowHeight,
|
|
140
|
+
rowCount: data.length,
|
|
141
|
+
};
|
|
142
|
+
return (_jsx(_Fragment, { children: shouldBeDraggable ? (_jsx(SortableContext, __assign({ items: data, strategy: verticalListSortingStrategy }, { children: _jsx(StyledGrid, __assign({}, gridProps, { children: DraggableCell })) }))) : (_jsx(StyledGrid, __assign({}, gridProps, { ref: canUseCustomScrollbar ? listRef : undefined, outerElementType: canUseCustomScrollbar
|
|
143
|
+
? CustomScrollbarsVirtualList
|
|
144
|
+
: undefined }, { children: Cell }))) }));
|
|
115
145
|
} })] })));
|
|
116
146
|
}, areEqual);
|
|
117
147
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -38,7 +38,7 @@ var Checkbox = function (_a) {
|
|
|
38
38
|
var handleOnChange = function (event) {
|
|
39
39
|
if (!onChange)
|
|
40
40
|
return;
|
|
41
|
-
if (event.shiftKey && onShiftKeyPressed) {
|
|
41
|
+
if ((event.shiftKey || event.nativeEvent.metaKey) && onShiftKeyPressed) {
|
|
42
42
|
onShiftKeyPressed();
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
@@ -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 padding: ", ";\n height: 68px;\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 ", "\n ", "\n"], ["\n position: relative;\n padding: ", ";\n height: 68px;\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 ", "\n ", "\n"])), function (_a) {
|
|
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,18 @@ 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;
|
|
13
14
|
close(): void;
|
|
14
15
|
show(): Promise<void>;
|
|
16
|
+
private renderImporterComponent;
|
|
17
|
+
private createDivComponent;
|
|
18
|
+
private createIframe;
|
|
19
|
+
private createImporterComponent;
|
|
20
|
+
private configureIframe;
|
|
15
21
|
private configureI18n;
|
|
16
22
|
}
|
|
17
23
|
export default FuseImporter;
|
package/lib/esm/index.js
CHANGED
|
@@ -45,16 +45,27 @@ 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;
|
|
58
69
|
this.apiToken = apiToken;
|
|
59
70
|
this.templateSlug = templateSlug;
|
|
60
71
|
this.options = __assign({ env: "production", zIndex: 1000, batchValidationDelayMs: 500 }, options);
|
|
@@ -62,39 +73,82 @@ var FuseImporter = /** @class */ (function () {
|
|
|
62
73
|
FuseImporter.prototype.close = function () {
|
|
63
74
|
var _a;
|
|
64
75
|
(_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
if (this.cleanupIframe) {
|
|
77
|
+
this.cleanupIframe();
|
|
78
|
+
this.cleanupIframe = null;
|
|
79
|
+
}
|
|
80
|
+
var iframe = document.getElementById(fuseImporterId);
|
|
81
|
+
document.body.removeChild(iframe);
|
|
68
82
|
};
|
|
69
83
|
FuseImporter.prototype.show = function () {
|
|
70
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var
|
|
72
|
-
var _this = this;
|
|
85
|
+
var isRunningTest, iframe, importerComponent;
|
|
73
86
|
return __generator(this, function (_a) {
|
|
74
87
|
switch (_a.label) {
|
|
75
88
|
case 0: return [4 /*yield*/, this.configureI18n()];
|
|
76
89
|
case 1:
|
|
77
90
|
_a.sent();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
onSubmit: this.onSubmit,
|
|
88
|
-
onClose: function () {
|
|
89
|
-
_this.close();
|
|
90
|
-
},
|
|
91
|
-
}), document.getElementById(fuseImporterId));
|
|
92
|
-
i18n.reloadResources();
|
|
91
|
+
isRunningTest = typeof (window === null || window === void 0 ? void 0 : window.Cypress) !== "undefined";
|
|
92
|
+
if (isRunningTest) {
|
|
93
|
+
this.renderImporterComponent();
|
|
94
|
+
i18n.reloadResources();
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
iframe = this.createIframe();
|
|
98
|
+
importerComponent = this.createImporterComponent();
|
|
99
|
+
this.configureIframe(iframe, importerComponent);
|
|
93
100
|
return [2 /*return*/];
|
|
94
101
|
}
|
|
95
102
|
});
|
|
96
103
|
});
|
|
97
104
|
};
|
|
105
|
+
FuseImporter.prototype.renderImporterComponent = function () {
|
|
106
|
+
var importerDiv = this.createDivComponent();
|
|
107
|
+
var importerComponent = this.createImporterComponent();
|
|
108
|
+
ReactDOM.render(importerComponent, importerDiv);
|
|
109
|
+
};
|
|
110
|
+
FuseImporter.prototype.createDivComponent = function () {
|
|
111
|
+
var div = document.createElement("div");
|
|
112
|
+
div.setAttribute("id", fuseImporterId);
|
|
113
|
+
document.body.appendChild(div);
|
|
114
|
+
return div;
|
|
115
|
+
};
|
|
116
|
+
FuseImporter.prototype.createIframe = function () {
|
|
117
|
+
var iframe = document.createElement("iframe");
|
|
118
|
+
iframe.setAttribute("id", fuseImporterId);
|
|
119
|
+
iframe.style.cssText =
|
|
120
|
+
"border: none; width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index: 1000;";
|
|
121
|
+
document.body.appendChild(iframe);
|
|
122
|
+
return iframe;
|
|
123
|
+
};
|
|
124
|
+
FuseImporter.prototype.createImporterComponent = function () {
|
|
125
|
+
var _this = this;
|
|
126
|
+
return (_jsx(Importer, { apiToken: this.apiToken, templateSlug: this.templateSlug, options: this.options, formatRecord: this.formatRecord, onValidateRecord: this.onValidateRecord, onSubmit: this.onSubmit, onClose: function () {
|
|
127
|
+
_this.close();
|
|
128
|
+
} }));
|
|
129
|
+
};
|
|
130
|
+
FuseImporter.prototype.configureIframe = function (iframe, importerComponent) {
|
|
131
|
+
var onLoadCallback = function () {
|
|
132
|
+
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
|
133
|
+
iframeDocument.body.style.margin = "0";
|
|
134
|
+
iframeDocument.body.style.padding = "0";
|
|
135
|
+
var head = iframeDocument.getElementsByTagName("head")[0];
|
|
136
|
+
for (var _i = 0, fontsURL_1 = fontsURL; _i < fontsURL_1.length; _i++) {
|
|
137
|
+
var link = fontsURL_1[_i];
|
|
138
|
+
addLinkToHead(iframeDocument, head, link.href, link.rel, link.crossOrigin);
|
|
139
|
+
}
|
|
140
|
+
ReactDOM.render(_jsx(StyleSheetManager, __assign({ target: iframeDocument.head }, { children: importerComponent })), iframeDocument.body);
|
|
141
|
+
i18n.reloadResources();
|
|
142
|
+
iframe.removeEventListener("load", onLoadCallback);
|
|
143
|
+
};
|
|
144
|
+
iframe.addEventListener("load", onLoadCallback);
|
|
145
|
+
iframe.src = "about:blank";
|
|
146
|
+
var cleanup = function () {
|
|
147
|
+
iframe.removeEventListener("load", onLoadCallback);
|
|
148
|
+
};
|
|
149
|
+
this.cleanupIframe = cleanup;
|
|
150
|
+
return cleanup;
|
|
151
|
+
};
|
|
98
152
|
FuseImporter.prototype.configureI18n = function () {
|
|
99
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
154
|
var browserLanguage, language;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var fontsURL = [
|
|
2
|
+
{
|
|
3
|
+
href: "https://fonts.googleapis.com",
|
|
4
|
+
rel: "preconnect",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
href: "https://fonts.gstatic.com",
|
|
8
|
+
rel: "preconnect",
|
|
9
|
+
crossOrigin: "",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
href: "https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600&display=swap",
|
|
13
|
+
rel: "stylesheet",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
href: "https://fonts.googleapis.com/css?family=DM+Serif+Text:300,400,500,600&display=swap",
|
|
17
|
+
rel: "stylesheet",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
href: "https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=DM+Serif+Display&family=DM+Serif+Text&display=swap",
|
|
21
|
+
rel: "stylesheet",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
href: "https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=DM+Serif+Text&display=swap",
|
|
25
|
+
rel: "stylesheet",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type WindowDimentions = {
|
|
2
|
+
width: number | undefined;
|
|
3
|
+
height: number | undefined;
|
|
4
|
+
};
|
|
5
|
+
type IsOnMobileDevice = boolean;
|
|
6
|
+
interface UseWindowDimensions {
|
|
7
|
+
isOnSmallScreens: IsOnMobileDevice;
|
|
8
|
+
windowDimensions: WindowDimentions;
|
|
9
|
+
}
|
|
10
|
+
declare const useWindowDimensions: () => UseWindowDimensions;
|
|
11
|
+
export default useWindowDimensions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
var useWindowDimensions = function () {
|
|
3
|
+
var _a = useState({
|
|
4
|
+
width: undefined,
|
|
5
|
+
height: undefined,
|
|
6
|
+
}), windowDimensions = _a[0], setWindowDimensions = _a[1];
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
var handleResize = function () {
|
|
9
|
+
setWindowDimensions({
|
|
10
|
+
width: window.innerWidth,
|
|
11
|
+
height: window.innerHeight,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
handleResize();
|
|
15
|
+
window.addEventListener("resize", handleResize);
|
|
16
|
+
return function () { return window.removeEventListener("resize", handleResize); };
|
|
17
|
+
}, []);
|
|
18
|
+
var isOnSmallScreens = windowDimensions.width
|
|
19
|
+
? windowDimensions.width <= 1050
|
|
20
|
+
: false;
|
|
21
|
+
return { windowDimensions: windowDimensions, isOnSmallScreens: isOnSmallScreens };
|
|
22
|
+
};
|
|
23
|
+
export default useWindowDimensions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./hooks/useWindowSize";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./hooks/useWindowSize";
|