fuse-importer 0.13.0 → 0.16.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/ImporterContextProvider.d.ts +7 -6
- package/lib/esm/Importer/ImporterContextProvider.js +19 -17
- package/lib/esm/Importer/{LoadFonts.d.ts → ImporterFonts.d.ts} +0 -0
- package/lib/esm/Importer/{LoadFonts.js → ImporterFonts.js} +0 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +20 -4
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +6 -5
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +19 -4
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.d.ts +0 -5
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +7 -14
- package/lib/esm/Importer/Matcher/common/index.d.ts +4 -2
- package/lib/esm/Importer/Matcher/common/index.js +32 -2
- package/lib/esm/Importer/Review/AppResponseModal.js +1 -1
- package/lib/esm/Importer/Review/index.js +32 -22
- package/lib/esm/Importer/SpreadsheetReviewContextProvider.js +2 -2
- package/lib/esm/Importer/Stepper.js +7 -6
- package/lib/esm/Importer/TrialModeBanner.js +1 -1
- package/lib/esm/Importer/Uploader/HeadersPreview.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +4 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +21 -24
- package/lib/esm/Importer/common/Spreadsheet/common/fields/SpeadsheetAutocomplete.js +5 -4
- package/lib/esm/Importer/common/Spreadsheet/common/fields/SpreadsheetInput.d.ts +12 -0
- package/lib/esm/Importer/common/Spreadsheet/common/fields/{SpreadsheetTextInput.js → SpreadsheetInput.js} +15 -4
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +17 -14
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +3 -3
- package/lib/esm/Importer/common/Spreadsheet/index.js +39 -30
- package/lib/esm/Importer/common/index.d.ts +8 -0
- package/lib/esm/Importer/common/index.js +6 -0
- package/lib/esm/Importer/common/utils.d.ts +3 -2
- package/lib/esm/Importer/common/utils.js +21 -4
- package/lib/esm/Importer/index.d.ts +4 -5
- package/lib/esm/Importer/index.js +7 -7
- package/lib/esm/common/Table/TableView/TableHeaders.d.ts +2 -1
- package/lib/esm/common/Table/TableView/TableHeaders.js +4 -4
- package/lib/esm/common/Table/TableView/common.d.ts +1 -1
- package/lib/esm/common/Table/TableView/common.js +1 -1
- package/lib/esm/common/Table/TableView/index.d.ts +2 -1
- package/lib/esm/common/Table/TableView/index.js +3 -7
- package/lib/esm/common/TooltipProvider.js +8 -0
- package/lib/esm/common/index.d.ts +0 -1
- package/lib/esm/common/index.js +7 -9
- package/lib/esm/common/inputs/Autocomplete.d.ts +3 -2
- package/lib/esm/common/inputs/Autocomplete.js +19 -10
- package/lib/esm/common/inputs/TextInput.d.ts +1 -0
- package/lib/esm/common/inputs/TextInput.js +2 -2
- package/lib/esm/index.d.ts +4 -3
- package/lib/esm/index.js +17 -9
- package/lib/esm/styled/utils.d.ts +2 -0
- package/lib/esm/types.d.ts +16 -4
- package/lib/main.js +1 -1
- package/package.json +3 -3
- package/lib/esm/Importer/common/Spreadsheet/common/fields/SpreadsheetTextInput.d.ts +0 -13
|
@@ -31,7 +31,7 @@ import { Div } from "../../../styled/utils";
|
|
|
31
31
|
import { chevronDown as chevronDownIcon } from "../icons";
|
|
32
32
|
import { SortDirection } from "../TableDataProvider";
|
|
33
33
|
import { columnWidthPercentage, defaultTableHeaderHeightPx, TableViewCellContainer, } from "./common";
|
|
34
|
-
export var TableViewHeader = styled(TableViewCellContainer)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-bottom:
|
|
34
|
+
export var TableViewHeader = styled(TableViewCellContainer)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-bottom: none;\n box-shadow: inset 0 -1px 0 ", ";\n background-color: ", ";\n ", ";\n color: ", ";\n ", "\n"], ["\n border-bottom: none;\n box-shadow: inset 0 -1px 0 ", ";\n background-color: ", ";\n ", ";\n color: ", ";\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.tableHeader; }, function (p) { return p.theme.css.body2; }, function (p) { return p.theme.colors.text; }, function (p) {
|
|
35
35
|
return p.isLast && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-right: solid 1px transparent !important;\n "], ["\n border-right: solid 1px transparent !important;\n "])));
|
|
36
36
|
});
|
|
37
37
|
export var SortIndicator = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"], ["\n margin-left: 10px;\n margin-top: -4px;\n ", "\n svg {\n path {\n fill: ", ";\n }\n }\n"])), function (p) {
|
|
@@ -40,11 +40,11 @@ export var SortIndicator = styled(Div)(templateObject_4 || (templateObject_4 = _
|
|
|
40
40
|
export var TableHeadersContainer = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n overflow-x: hidden;\n"], ["\n overflow-x: hidden;\n"])));
|
|
41
41
|
export var TableHeadersContent = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n /* table scrollbar offset */\n border-right: solid 10px ", ";\n"], ["\n /* table scrollbar offset */\n border-right: solid 10px ", ";\n"])), function (p) { return p.theme.colors.tableHeader; });
|
|
42
42
|
export var TableHeaders = function (_a) {
|
|
43
|
-
var _b = _a.scrollLeft, scrollLeft = _b === void 0 ? 0 : _b, columns = _a.columns, sortBy = _a.sortBy, setSortBy = _a.setSortBy, rowHeight = _a.rowHeight, _c = _a.rowWidth, rowWidth = _c === void 0 ? 1 : _c, props = __rest(_a, ["scrollLeft", "columns", "sortBy", "setSortBy", "rowHeight", "rowWidth"]);
|
|
43
|
+
var _b = _a.scrollLeft, scrollLeft = _b === void 0 ? 0 : _b, columns = _a.columns, sortBy = _a.sortBy, setSortBy = _a.setSortBy, rowHeight = _a.rowHeight, _c = _a.rowWidth, rowWidth = _c === void 0 ? 1 : _c, _d = _a.height, height = _d === void 0 ? defaultTableHeaderHeightPx : _d, props = __rest(_a, ["scrollLeft", "columns", "sortBy", "setSortBy", "rowHeight", "rowWidth", "height"]);
|
|
44
44
|
var containerRef = useRef(null);
|
|
45
45
|
if (containerRef.current)
|
|
46
46
|
containerRef.current.scrollLeft = scrollLeft;
|
|
47
|
-
return (_jsx(TableHeadersContainer, __assign({ ref: containerRef },
|
|
47
|
+
return (_jsx(TableHeadersContainer, __assign({ ref: containerRef }, { children: _jsx(TableHeadersContent, __assign({ dflex: true, w: "".concat(100 * rowWidth, "%") }, { children: columns.map(function (column, index) {
|
|
48
48
|
var header = column.header, Header = column.Header;
|
|
49
49
|
var onHeaderClick = function () {
|
|
50
50
|
if (!setSortBy || column.disableSort)
|
|
@@ -64,7 +64,7 @@ export var TableHeaders = function (_a) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
return (_jsxs(TableViewHeader, __assign({ isLast: index === columns.length - 1, w: columnWidthPercentage(column, columns), onClick: onHeaderClick }, { children: [_jsx(_Fragment, { children: Header ? _jsx(Header, {}, void 0) : header }, void 0), (sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === column.dataAccessor && (_jsx(SortIndicator, __assign({ direction: sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction }, { children: chevronDownIcon }), void 0))] }), index));
|
|
67
|
+
return (_jsxs(TableViewHeader, __assign({ isLast: index === columns.length - 1, w: columnWidthPercentage(column, columns), onClick: onHeaderClick, h: height }, props, { children: [_jsx(_Fragment, { children: Header ? _jsx(Header, {}, void 0) : header }, void 0), (sortBy === null || sortBy === void 0 ? void 0 : sortBy.field) === column.dataAccessor && (_jsx(SortIndicator, __assign({ direction: sortBy === null || sortBy === void 0 ? void 0 : sortBy.direction }, { children: chevronDownIcon }), void 0))] }), index));
|
|
68
68
|
}) }), void 0) }), void 0));
|
|
69
69
|
};
|
|
70
70
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TableViewColumn } from ".";
|
|
2
2
|
export declare const defaultTableRowHeightPx = 60;
|
|
3
|
-
export declare const defaultTableHeaderHeightPx =
|
|
3
|
+
export declare const defaultTableHeaderHeightPx = 60;
|
|
4
4
|
export declare const columnWidthPercentage: (column: TableViewColumn, columns: TableViewColumn[]) => string;
|
|
5
5
|
export declare const TableViewCellContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
@@ -5,7 +5,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
5
5
|
import styled, { css } from "styled-components";
|
|
6
6
|
import { Div } from "../../../styled/utils";
|
|
7
7
|
export var defaultTableRowHeightPx = 60;
|
|
8
|
-
export var defaultTableHeaderHeightPx =
|
|
8
|
+
export var defaultTableHeaderHeightPx = 60;
|
|
9
9
|
export var columnWidthPercentage = function (column, columns) {
|
|
10
10
|
var totalColumnWidthCount = columns.reduce(function (sum, c) {
|
|
11
11
|
return sum + (c.width ? c.width : 1);
|
|
@@ -33,8 +33,9 @@ export declare type TableViewProps = {
|
|
|
33
33
|
highlightFirstRow?: boolean;
|
|
34
34
|
rowWidth?: number;
|
|
35
35
|
rowHeight?: number;
|
|
36
|
+
tableHeadersHeight?: number;
|
|
36
37
|
onSectionRendered?: (section: TableSection) => void;
|
|
37
38
|
onTableScroll?: (scrollTop: number) => void;
|
|
38
39
|
onRowClick?: (row: any) => void;
|
|
39
40
|
} & DivCSSProps;
|
|
40
|
-
declare const TableView: ({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, rowHeight, h, onTableScroll, ...props }: TableViewProps) => JSX.Element;
|
|
41
|
+
declare const TableView: ({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, ...props }: TableViewProps) => JSX.Element;
|
|
@@ -43,16 +43,14 @@ export var TableViewWrapper = styled(Div)(templateObject_2 || (templateObject_2
|
|
|
43
43
|
var SpinnerWrapper = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n pointer-events: none;\n z-index: 100;\n"], ["\n pointer-events: none;\n z-index: 100;\n"])));
|
|
44
44
|
var tableHeaderId = "tableHeaderId";
|
|
45
45
|
var TableView = function (_a) {
|
|
46
|
-
var _b;
|
|
47
|
-
var data = _a.data, columns = _a.columns, pageSize = _a.pageSize, _c = _a.onRowClick, onRowClick = _c === void 0 ? null : _c, _d = _a.sortBy, sortBy = _d === void 0 ? { field: null, direction: null } : _d, _e = _a.isLoading, isLoading = _e === void 0 ? false : _e, _f = _a.highlightFirstRow, highlightFirstRow = _f === void 0 ? false : _f, _g = _a.setSortBy, setSortBy = _g === void 0 ? null : _g, _h = _a.rowWidth, rowWidth = _h === void 0 ? 1 : _h, onSectionRendered = _a.onSectionRendered, _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, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidth", "onSectionRendered", "rowHeight", "h", "onTableScroll"]);
|
|
46
|
+
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, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidth", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll"]);
|
|
48
47
|
var _m = useState(0), scrollLeft = _m[0], setScrollLeft = _m[1];
|
|
49
48
|
/*
|
|
50
49
|
multiply the rowWidth by 0.95 to let the user know they can scroll
|
|
51
50
|
horizontally (will display partial column on the right)
|
|
52
51
|
*/
|
|
53
52
|
var _rowWidth = rowWidth > 1 ? rowWidth * 0.95 : rowWidth;
|
|
54
|
-
var
|
|
55
|
-
var tableHeadersUI = (_jsx(_Fragment, { children: data.length > 0 && (_jsx(TableHeaders, __assign({ id: tableHeaderId }, {
|
|
53
|
+
var tableHeadersUI = (_jsx(_Fragment, { children: data.length > 0 && (_jsx(TableHeaders, __assign({ id: tableHeaderId, height: tableHeadersHeight }, {
|
|
56
54
|
rowHeight: rowHeight,
|
|
57
55
|
rowWidth: _rowWidth,
|
|
58
56
|
scrollLeft: scrollLeft,
|
|
@@ -84,9 +82,7 @@ var TableView = function (_a) {
|
|
|
84
82
|
}, { h: rowHeight, row: data[rowIndex], indexI: rowIndex, isLast: rowIndex === data.length - 1, pRelative: true }), void 0) }), key));
|
|
85
83
|
};
|
|
86
84
|
var loadingUI = (_jsx(_Fragment, { children: isLoading && (_jsx(SpinnerWrapper, __assign({ pRelative: true }, { children: _jsx(Div, __assign({ w100: true, h100: true, centered: true, h: 400, pAbsolute: true }, { children: _jsx(Spinner, {}, void 0) }), void 0) }), void 0)) }, void 0));
|
|
87
|
-
var tableHeight = pageSize
|
|
88
|
-
? pageSize * rowHeight + defaultTableHeaderHeightPx
|
|
89
|
-
: h;
|
|
85
|
+
var tableHeight = pageSize ? pageSize * rowHeight + tableHeadersHeight : h;
|
|
90
86
|
return (_jsxs(TableViewWrapper, __assign({}, { isLoading: isLoading }, { h: tableHeight }, props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
91
87
|
var width = _a.width, height = _a.height;
|
|
92
88
|
/* using style={{ willChange: "unset" }} is important for having items
|
|
@@ -37,6 +37,14 @@ export var TooltipProvider = function (_a) {
|
|
|
37
37
|
var _e = useState(null), popperElement = _e[0], setPopperElement = _e[1];
|
|
38
38
|
var _f = usePopper(referenceElement, popperElement, {
|
|
39
39
|
placement: placement,
|
|
40
|
+
modifiers: [
|
|
41
|
+
{
|
|
42
|
+
name: "offset",
|
|
43
|
+
options: {
|
|
44
|
+
offset: [0, 4],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
40
48
|
}), styles = _f.styles, attributes = _f.attributes, update = _f.update;
|
|
41
49
|
useEffect(function () {
|
|
42
50
|
if (update)
|
|
@@ -3,7 +3,6 @@ import { CSSProps } from "../styled/utils";
|
|
|
3
3
|
export declare const fuseImporterId = "fuse-importer-root";
|
|
4
4
|
declare type MenuItemProps = {
|
|
5
5
|
isSelected?: boolean;
|
|
6
|
-
isLast?: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare const MenuItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, CSSProps & MenuItemProps, never>;
|
|
9
8
|
declare type LabelProps = {
|
package/lib/esm/common/index.js
CHANGED
|
@@ -18,20 +18,18 @@ import styled, { css } from "styled-components";
|
|
|
18
18
|
import { Div, themeProps } from "../styled/utils";
|
|
19
19
|
import { colors } from "../styled/theme/colorPalette";
|
|
20
20
|
export var fuseImporterId = "fuse-importer-root";
|
|
21
|
-
export var MenuItem = styled(Div)(
|
|
22
|
-
return
|
|
23
|
-
}, function (props) { return props.theme.colors.white; }, function (props) { return props.theme.colors.text; }, function (props) { return props.theme.css.body1; }, function (p) { return p.theme.css.selectNone; }, function (p) {
|
|
24
|
-
return p.isSelected && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.blue500; });
|
|
21
|
+
export var MenuItem = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: 8px;\n padding: 12px 16px;\n display: flex;\n align-items: center;\n background: ", ";\n color: ", ";\n ", "\n ", ";\n ", "\n :hover {\n background: ", ";\n cursor: pointer;\n }\n"], ["\n border-radius: 8px;\n padding: 12px 16px;\n display: flex;\n align-items: center;\n background: ", ";\n color: ", ";\n ", "\n ", ";\n ", "\n :hover {\n background: ", ";\n cursor: pointer;\n }\n"])), function (props) { return props.theme.colors.white; }, function (props) { return props.theme.colors.text; }, function (props) { return props.theme.css.body1; }, function (p) { return p.theme.css.selectNone; }, function (p) {
|
|
22
|
+
return p.isSelected && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.blue500; });
|
|
25
23
|
}, function (props) { return props.theme.colors.blue100; });
|
|
26
|
-
export var FormInputLabel = styled(Div)(
|
|
27
|
-
return props.isDisabled && css(
|
|
24
|
+
export var FormInputLabel = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n color: ", ";\n ", "\n"], ["\n ", ";\n color: ", ";\n ", "\n"])), function (props) { return props.theme.css.body4; }, function (props) { return props.theme.colors.text; }, function (props) {
|
|
25
|
+
return props.isDisabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (props) { return props.theme.colors.gray500; });
|
|
28
26
|
});
|
|
29
27
|
export var InfoDivider = function (_a) {
|
|
30
28
|
var msg = _a.msg;
|
|
31
29
|
return (_jsxs(Div, __assign({ dflex: true, alignCenter: true, mt: 7, mb: 7 }, { children: [_jsx(Div, { w100: true, h: 1, bg: colors.gray300 }, void 0), _jsx(Div, __assign({ w100: true, textAlignCenter: true, c: colors.gray700, body1: true, centered: true, p: 20 }, { children: msg }), void 0), _jsx(Div, { w100: true, h: 1, bg: colors.gray300 }, void 0)] }), void 0));
|
|
32
30
|
};
|
|
33
|
-
export var Avatar = styled.img(
|
|
34
|
-
export var Divider = styled(Div)(
|
|
31
|
+
export var Avatar = styled.img(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n border-radius: 100%;\n height: 36px;\n width: 36px;\n"], ["\n ", ";\n border-radius: 100%;\n height: 36px;\n width: 36px;\n"])), themeProps);
|
|
32
|
+
export var Divider = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: 100%;\n height: 1px;\n background: ", ";\n"], ["\n width: 100%;\n height: 1px;\n background: ", ";\n"])), colors.black);
|
|
35
33
|
export * from "./icons";
|
|
36
34
|
export * from "./inputs";
|
|
37
35
|
export * from "./Table";
|
|
@@ -41,4 +39,4 @@ export * from "./logo";
|
|
|
41
39
|
export * from "./Modal";
|
|
42
40
|
export * from "./Spinner";
|
|
43
41
|
export * from "./TooltipProvider";
|
|
44
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6
|
|
42
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -8,12 +8,13 @@ declare type Option = {
|
|
|
8
8
|
declare type Props = {
|
|
9
9
|
label?: any;
|
|
10
10
|
placeholder?: string;
|
|
11
|
-
value
|
|
11
|
+
value?: any;
|
|
12
12
|
onChange: (v: string | null) => void;
|
|
13
13
|
options: Option[];
|
|
14
14
|
isInputDisabled?: boolean;
|
|
15
15
|
onToggle?: (isOpen: boolean) => void;
|
|
16
16
|
placement?: Placement;
|
|
17
|
+
icon?: JSX.Element;
|
|
17
18
|
} & DivCSSProps;
|
|
18
|
-
declare const Autocomplete: ({ label, isInputDisabled, placeholder, value, onChange, placement, options, onToggle, ...props }: Props) => JSX.Element;
|
|
19
|
+
declare const Autocomplete: ({ label, isInputDisabled, placeholder, value, icon, onChange, placement, options, onToggle, ...props }: Props) => JSX.Element;
|
|
19
20
|
export { Autocomplete };
|
|
@@ -29,7 +29,6 @@ import { useEffect, useState } from "react";
|
|
|
29
29
|
import styled, { css } from "styled-components";
|
|
30
30
|
import { MenuItem } from "..";
|
|
31
31
|
import { Div } from "../../styled/utils";
|
|
32
|
-
import { chevronDown } from "../Table/icons";
|
|
33
32
|
import { SelectMenu } from "./SelectMenu";
|
|
34
33
|
import { TextInput as TextInputBase } from "./TextInput";
|
|
35
34
|
var TextInput = styled(TextInputBase)(function (_a) {
|
|
@@ -42,16 +41,20 @@ var ClearIcon = styled(Div)(function (_a) {
|
|
|
42
41
|
var _b = _a.theme, colors = _b.colors, c = _b.css;
|
|
43
42
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n pointer-events: auto;\n "], ["\n pointer-events: auto;\n "])));
|
|
44
43
|
});
|
|
44
|
+
var ClickableArea = styled(Div)(function (_a) {
|
|
45
|
+
var _b = _a.theme, colors = _b.colors, c = _b.css, isInputDisabled = _a.isInputDisabled;
|
|
46
|
+
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 "]))));
|
|
47
|
+
});
|
|
45
48
|
var Autocomplete = function (_a) {
|
|
46
49
|
var _b;
|
|
47
|
-
var _c = _a.label, label = _c === void 0 ? null : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "Select option..." : _e, value = _a.value, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, props = __rest(_a, ["label", "isInputDisabled", "placeholder", "value", "onChange", "placement", "options", "onToggle"]);
|
|
50
|
+
var _c = _a.label, label = _c === void 0 ? null : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "Select option..." : _e, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, props = __rest(_a, ["label", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle"]);
|
|
48
51
|
var _f = useState(false), updatedText = _f[0], setUpdatedText = _f[1];
|
|
49
|
-
var
|
|
50
|
-
var _g = useState(
|
|
52
|
+
var selectedLabel = ((_b = options.find(function (o) { return o.value === value; })) === null || _b === void 0 ? void 0 : _b.label) || "";
|
|
53
|
+
var _g = useState(selectedLabel), text = _g[0], setText = _g[1];
|
|
51
54
|
var _h = useState(false), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
|
|
52
55
|
useEffect(function () {
|
|
53
56
|
if (value)
|
|
54
|
-
setText(
|
|
57
|
+
setText(selectedLabel);
|
|
55
58
|
else
|
|
56
59
|
setText("");
|
|
57
60
|
}, [value]);
|
|
@@ -60,7 +63,7 @@ var Autocomplete = function (_a) {
|
|
|
60
63
|
}, [text]);
|
|
61
64
|
useEffect(function () {
|
|
62
65
|
setUpdatedText(false);
|
|
63
|
-
setText(
|
|
66
|
+
setText(selectedLabel);
|
|
64
67
|
if (onToggle)
|
|
65
68
|
onToggle(isMenuOpen);
|
|
66
69
|
}, [isMenuOpen]);
|
|
@@ -75,10 +78,16 @@ var Autocomplete = function (_a) {
|
|
|
75
78
|
var inputIconUI = text ? (_jsx(ClearIcon, __assign({ clickable: true, dim: 24, centered: true, onClick: function (evt) {
|
|
76
79
|
evt.preventDefault();
|
|
77
80
|
evt.stopPropagation();
|
|
78
|
-
onChange(
|
|
79
|
-
} }, { children: clearIcon }), void 0)) : (_jsx(Div, __assign({ centered: true, dim: 24 }, { children:
|
|
80
|
-
return (_jsxs(Div, __assign({ w100: true }, props, { children: [_jsx(
|
|
81
|
+
onChange(undefined);
|
|
82
|
+
} }, { children: clearIcon }), void 0)) : (_jsx(Div, __assign({ centered: true, dim: 24 }, { children: icon || chevronDownIcon }), void 0));
|
|
83
|
+
return (_jsxs(Div, __assign({ w100: true }, props, { children: [_jsx(ClickableArea, __assign({ isInputDisabled: isInputDisabled, onClick: function () { return setIsMenuOpen(true); } }, { children: _jsx(TextInput, { onBlur: function () {
|
|
84
|
+
if (filteredOptions.length === 0) {
|
|
85
|
+
setText(selectedLabel);
|
|
86
|
+
setIsMenuOpen(false);
|
|
87
|
+
}
|
|
88
|
+
}, label: label, isDisabled: isInputDisabled, placeholder: placeholder, value: text, onChange: function (v) { return setText(v); }, icon: inputIconUI }, void 0) }), void 0), filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ isSelected: value === o.value, onClick: function () { return onSelect(o.value); } }, { children: o.label }), void 0) }, index)); }) }), void 0))] }), void 0));
|
|
81
89
|
};
|
|
90
|
+
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" }, void 0) }), void 0));
|
|
82
91
|
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" }, void 0), _jsx("path", { d: "M4 12.5161L12.5161 3.99998", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, void 0)] }), void 0));
|
|
83
92
|
export { Autocomplete };
|
|
84
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
93
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DivCSSProps } from "../../styled/utils";
|
|
3
3
|
export declare const HTMLInput: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export declare const TextInputIcon: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../styled/utils").CSSProps, never>;
|
|
4
5
|
declare type Props = {
|
|
5
6
|
label?: string;
|
|
6
7
|
icon?: any;
|
|
@@ -35,7 +35,7 @@ export var HTMLInput = styled.input(templateObject_3 || (templateObject_3 = __ma
|
|
|
35
35
|
}, function (props) {
|
|
36
36
|
return props.hasError && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-right: 50px;\n border: solid 2px ", ";\n "], ["\n padding-right: 50px;\n border: solid 2px ", ";\n "])), function (props) { return props.theme.colors.error; });
|
|
37
37
|
});
|
|
38
|
-
var
|
|
38
|
+
export var TextInputIcon = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n right: 11px;\n top: 0;\n height: 100%;\n"], ["\n position: absolute;\n right: 11px;\n top: 0;\n height: 100%;\n"])));
|
|
39
39
|
var TextInput = function (_a) {
|
|
40
40
|
var label = _a.label, _b = _a.icon, icon = _b === void 0 ? null : _b, _c = _a.placeholder, placeholder = _c === void 0 ? "" : _c, value = _a.value, _d = _a.type, type = _d === void 0 ? "text" : _d, onChange = _a.onChange, _e = _a.onBlur, onBlur = _e === void 0 ? null : _e, _f = _a.isDisabled, isDisabled = _f === void 0 ? false : _f, _g = _a.hasError, hasError = _g === void 0 ? false : _g, _h = _a.onFocus, onFocus = _h === void 0 ? null : _h, _j = _a.withDebounce, withDebounce = _j === void 0 ? true : _j, _k = _a.autoFocus, autoFocus = _k === void 0 ? false : _k, props = __rest(_a, ["label", "icon", "placeholder", "value", "type", "onChange", "onBlur", "isDisabled", "hasError", "onFocus", "withDebounce", "autoFocus"]);
|
|
41
41
|
var _l = useDebounce(value, onChange, withDebounce ? 0 : 300), _value = _l._value, set_Value = _l.set_Value;
|
|
@@ -48,7 +48,7 @@ var TextInput = function (_a) {
|
|
|
48
48
|
}, onBlur: function () {
|
|
49
49
|
if (onBlur)
|
|
50
50
|
onBlur(_value);
|
|
51
|
-
} }), void 0), _jsx(
|
|
51
|
+
} }), void 0), _jsx(TextInputIcon, __assign({ centered: true }, { children: hasError ? errorIcon : _icon }), void 0)] }), void 0)] }), void 0));
|
|
52
52
|
};
|
|
53
53
|
var PIcon = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), function (props) {
|
|
54
54
|
var c = props.theme.css;
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { EnvironmentType, OnSubmit, OnValidateBatch, OnValidateRecord } from "./types";
|
|
1
|
+
import { EnvironmentType, ImporterOptions, OnSubmit, OnValidateBatch, OnValidateRecord } from "./types";
|
|
2
2
|
declare class FuseImporter {
|
|
3
3
|
apiToken: string;
|
|
4
|
-
|
|
4
|
+
templateSlug: string;
|
|
5
5
|
env: EnvironmentType;
|
|
6
6
|
zIndex: number;
|
|
7
|
-
|
|
7
|
+
options: ImporterOptions;
|
|
8
|
+
constructor(apiToken: string, templateSlug: string, options?: ImporterOptions);
|
|
8
9
|
onValidateRecord: OnValidateRecord;
|
|
9
10
|
onValidateBatch: OnValidateBatch;
|
|
10
11
|
onSubmit: OnSubmit;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React from "react";
|
|
2
13
|
import ReactDOM from "react-dom";
|
|
3
14
|
import { Importer } from "./Importer";
|
|
4
15
|
import { fuseImporterId } from "./common";
|
|
5
16
|
var FuseImporter = /** @class */ (function () {
|
|
6
|
-
function FuseImporter(apiToken,
|
|
7
|
-
if (
|
|
8
|
-
if (zIndex === void 0) { zIndex = 1000; }
|
|
17
|
+
function FuseImporter(apiToken, templateSlug, options) {
|
|
18
|
+
if (options === void 0) { options = {}; }
|
|
9
19
|
this.apiToken = apiToken;
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.zIndex = zIndex;
|
|
20
|
+
this.templateSlug = templateSlug;
|
|
21
|
+
this.options = __assign({ env: "production", zIndex: 1000, batchValidationDelayMs: 500 }, options);
|
|
13
22
|
}
|
|
14
23
|
FuseImporter.prototype.close = function () {
|
|
15
24
|
var _a;
|
|
@@ -25,9 +34,8 @@ var FuseImporter = /** @class */ (function () {
|
|
|
25
34
|
document.body.appendChild(div);
|
|
26
35
|
ReactDOM.render(React.createElement(Importer, {
|
|
27
36
|
apiToken: this.apiToken,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
zIndex: this.zIndex,
|
|
37
|
+
templateSlug: this.templateSlug,
|
|
38
|
+
options: this.options,
|
|
31
39
|
onValidateRecord: this.onValidateRecord,
|
|
32
40
|
onValidateBatch: this.onValidateBatch,
|
|
33
41
|
onSubmit: this.onSubmit,
|
|
@@ -11,4 +11,6 @@ export declare const Div: import("styled-components").StyledComponent<"div", imp
|
|
|
11
11
|
export declare const Span: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, CSSProps, never>;
|
|
12
12
|
export declare const P: import("styled-components").StyledComponent<"p", import("styled-components").DefaultTheme, CSSProps, never>;
|
|
13
13
|
export declare type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
export declare type HTMLInputProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
14
15
|
export declare type DivCSSProps = DivProps & CSSProps;
|
|
16
|
+
export declare type HTMLInputCSSProps = HTMLInputProps & CSSProps;
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
declare const EnvironmentTypes: readonly ["local", "development", "production", "test"];
|
|
2
2
|
export declare type EnvironmentType = typeof EnvironmentTypes[number];
|
|
3
|
+
export declare type SpreadsheetOptions = {
|
|
4
|
+
batchValidationDelayMs?: number;
|
|
5
|
+
batchValidationSize?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type ImporterOptions = {
|
|
8
|
+
zIndex?: number;
|
|
9
|
+
env?: EnvironmentType;
|
|
10
|
+
} & SpreadsheetOptions;
|
|
3
11
|
export declare enum FieldTypes {
|
|
4
12
|
boolean = "boolean",
|
|
5
13
|
integer = "integer",
|
|
@@ -33,13 +41,17 @@ export declare type ValidationErrors = {
|
|
|
33
41
|
[k: string]: string;
|
|
34
42
|
};
|
|
35
43
|
export declare type OnValidateRecord = (record: Record) => Promise<ValidationErrors>;
|
|
36
|
-
export declare type
|
|
44
|
+
export declare type RowValidationError = {
|
|
45
|
+
rowId: string;
|
|
46
|
+
errors: ValidationErrors;
|
|
47
|
+
};
|
|
48
|
+
export declare type BatchValidationErrors = {
|
|
49
|
+
[rowId: string]: ValidationErrors;
|
|
50
|
+
};
|
|
51
|
+
export declare type OnValidateBatch = (batch: Record[]) => Promise<BatchValidationErrors>;
|
|
37
52
|
export declare type AppResponse = {
|
|
38
53
|
errors?: SpreadsheetValidationErrors;
|
|
39
54
|
message?: string;
|
|
40
55
|
};
|
|
41
56
|
export declare type OnSubmit = (reviewedData: Record[]) => Promise<AppResponse>;
|
|
42
|
-
export declare type BatchValidationErrors = {
|
|
43
|
-
[k: string]: ValidationErrors;
|
|
44
|
-
};
|
|
45
57
|
export {};
|