fuse-importer 0.0.1-staging → 0.0.1-testing

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.
Files changed (36) hide show
  1. package/lib/esm/Importer/ImporterWithContext.js +1 -1
  2. package/lib/esm/Importer/Review/ReviewContextProvider.js +4 -11
  3. package/lib/esm/Importer/Uploader/HeadersPreview.js +16 -8
  4. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +9 -20
  5. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +2 -2
  6. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +44 -15
  7. package/lib/esm/Importer/common/Spreadsheet/common/types.d.ts +2 -2
  8. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.d.ts +2 -1
  9. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +13 -4
  10. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +1 -2
  11. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +18 -13
  12. package/lib/esm/Importer/common/Spreadsheet/index.js +1 -1
  13. package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +1 -1
  14. package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +2 -0
  15. package/lib/esm/Importer/contexts/ImporterContextProvider.js +24 -20
  16. package/lib/esm/Importer/data/index.d.ts +1 -0
  17. package/lib/esm/Importer/data/index.js +7 -12
  18. package/lib/esm/common/Table/TableActions/RowFilters.js +4 -1
  19. package/lib/esm/common/Table/TableView/TableRows/TableRow.d.ts +2 -2
  20. package/lib/esm/common/Table/TableView/TableRows/TableRow.js +4 -4
  21. package/lib/esm/common/Table/TableView/TableRows/index.js +7 -4
  22. package/lib/esm/common/Table/TableView/index.d.ts +1 -1
  23. package/lib/esm/common/Table/TableView/index.js +11 -4
  24. package/lib/esm/common/Table/TableView/types.d.ts +1 -1
  25. package/lib/esm/common/inputs/Autocomplete.js +1 -1
  26. package/lib/esm/common/inputs/Checkbox.js +1 -1
  27. package/lib/esm/index.d.ts +1 -1
  28. package/lib/esm/index.js +38 -27
  29. package/lib/esm/locales/de.js +1 -1
  30. package/lib/esm/locales/en.js +1 -1
  31. package/lib/esm/locales/es.js +1 -1
  32. package/lib/esm/locales/fr.js +1 -1
  33. package/lib/esm/types.d.ts +5 -8
  34. package/package.json +3 -4
  35. package/lib/main.js +0 -172
  36. package/lib/main.js.LICENSE.txt +0 -61
@@ -7,7 +7,7 @@ type TableViewRowProps = {
7
7
  isLast: boolean;
8
8
  };
9
9
  export declare const TableViewRow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../../styled/utils").CSSProps & TableViewRowProps, never>;
10
- type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"> & {
10
+ type Props = Pick<TableViewProps, "columns" | "onRowClick"> & {
11
11
  row: any;
12
12
  rowWidth: number;
13
13
  indexI: number;
@@ -15,5 +15,5 @@ type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"
15
15
  getItemKey?: (row: any) => string;
16
16
  isRowSelected?: boolean;
17
17
  } & DivCSSProps;
18
- export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey, rowWidth, isRowSelected, ...props }: Props) => JSX.Element;
18
+ export declare const TableRow: ({ row, indexI, columns, isLast, onRowClick, getItemKey, rowWidth, isRowSelected, ...props }: Props) => JSX.Element;
19
19
  export {};
@@ -40,11 +40,11 @@ export var TableViewRow = styled(Div)(templateObject_3 || (templateObject_3 = __
40
40
  return p.isHighlighted && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "], ["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n\n .input-content {\n background: transparent;\n border: none;\n box-shadow: none;\n\n &,\n input {\n color: ", ";\n }\n }\n "])), p.theme.colors.blue100, p.theme.colors.blue500, p.theme.colors.gray1000);
41
41
  });
42
42
  export var TableRow = function (_a) {
43
- var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, highlightFirstRow = _a.highlightFirstRow, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, rowWidth = _a.rowWidth, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "highlightFirstRow", "onRowClick", "getItemKey", "rowWidth", "isRowSelected"]);
44
- var isHighlighted = (indexI === 0 && highlightFirstRow) || isRowSelected;
45
- return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
43
+ var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, rowWidth = _a.rowWidth, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "onRowClick", "getItemKey", "rowWidth", "isRowSelected"]);
44
+ var isHighlighted = isRowSelected;
45
+ var key = getItemKey ? getItemKey(row) : "".concat(indexI);
46
+ return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), id: "row-id-".concat(key), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
46
47
  var Content = column.Content;
47
- var key = getItemKey ? getItemKey(row) : "".concat(indexI);
48
48
  var resolvedKey = "column-".concat(indexJ, "-row-").concat(key);
49
49
  var columnWidthPercentages = getColumnWidthsPx(columns, rowWidth);
50
50
  var columnWidthPercentage = columnWidthPercentages[indexJ];
@@ -10,17 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { CSS } from "@dnd-kit/utilities";
14
13
  import { useSortable } from "@dnd-kit/sortable";
14
+ import { CSS } from "@dnd-kit/utilities";
15
15
  import { Div } from "../../../../styled/utils";
16
- import { TableRow } from "./TableRow";
17
16
  import React from "react";
18
17
  import { areEqual } from "react-window";
19
18
  import { useSpreadsheetContext } from "../../../../Importer";
19
+ import { TableRow } from "./TableRow";
20
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, rowWidth = data.rowWidth, isDraggable = data.isDraggable, 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, 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);
@@ -28,7 +28,10 @@ var Row = React.memo(function (_a) {
28
28
  var containerProps = { style: style };
29
29
  if (isDraggable)
30
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 }) })));
31
+ return (_jsx(Container, __assign({}, containerProps, { children: _jsx(TableRow, { rowWidth: rowWidth, columns: columns, onRowClick: onRowClick, h: rowHeight, row: item, indexI: rowIndex, isLast: rowIndex === items.length - 1, pRelative: true, getItemKey: getItemKey, isRowSelected: isRowSelected || false, className: rowIndex <
32
+ items.findIndex(function (item) { var _a; return ((_a = item === null || item === void 0 ? void 0 : item._meta) === null || _a === void 0 ? void 0 : _a.id) === (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0]); })
33
+ ? "before-selected-row"
34
+ : "" }) })));
32
35
  }, areEqual);
33
36
  var DraggableRow = React.memo(function (_a) {
34
37
  var item = _a.item, baseStyle = _a.style, children = _a.children;
@@ -8,4 +8,4 @@ type TableViewWrapperProps = {
8
8
  checkboxColumnWidth?: number;
9
9
  };
10
10
  export declare const TableViewWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableViewWrapperProps, never>;
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>;
11
+ export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, setSortBy, rowWidthScalingFactor, onSectionRendered, tableHeadersHeight, rowHeight, h, onScrollToBottom, onTableScroll, getItemKey, isDraggable, checkboxColumnWidth, isFiltering, ...props }: TableViewProps) => JSX.Element>;
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  };
27
27
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
28
28
  import { SortableContext, verticalListSortingStrategy, } from "@dnd-kit/sortable";
29
- import React, { Fragment, useCallback, useRef } from "react";
29
+ import React, { Fragment, useCallback, useRef, } from "react";
30
30
  import AutoSizer from "react-virtualized-auto-sizer";
31
31
  import { FixedSizeGrid as Grid, areEqual } from "react-window";
32
32
  import styled, { css } from "styled-components";
@@ -66,7 +66,8 @@ var buildGridStyles = function (rowWidthScalingFactor) {
66
66
  return gridStyles;
67
67
  };
68
68
  export var TableView = React.memo(function (_a) {
69
- 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"]);
69
+ var _b;
70
+ 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.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.onScrollToBottom, onScrollToBottom = _l === void 0 ? null : _l, _m = _a.onTableScroll, onTableScroll = _m === void 0 ? null : _m, _o = _a.getItemKey, getItemKey = _o === void 0 ? null : _o, _p = _a.isDraggable, isDraggable = _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", "setSortBy", "rowWidthScalingFactor", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onScrollToBottom", "onTableScroll", "getItemKey", "isDraggable", "checkboxColumnWidth", "isFiltering"]);
70
71
  var headerContainerRef = useRef();
71
72
  var onScroll = function (_a) {
72
73
  var scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
@@ -84,6 +85,10 @@ export var TableView = React.memo(function (_a) {
84
85
  };
85
86
  var onItemsRendered = useCallback(function (_a) {
86
87
  var rowStartIndex = _a.overscanRowStartIndex, rowStopIndex = _a.overscanRowStopIndex;
88
+ if (rowStopIndex >= data.length - 10) {
89
+ if (onScrollToBottom)
90
+ onScrollToBottom();
91
+ }
87
92
  if (onSectionRendered) {
88
93
  onSectionRendered({
89
94
  rowStartIndex: rowStartIndex,
@@ -95,9 +100,12 @@ export var TableView = React.memo(function (_a) {
95
100
  var tableHeight = pageSize
96
101
  ? pageSize * rowHeight + tableHeadersHeight
97
102
  : h;
103
+ var virtualizedGridRef = useRef(null);
104
+ console.log({ gridHeight: (_b = virtualizedGridRef === null || virtualizedGridRef === void 0 ? void 0 : virtualizedGridRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight });
98
105
  var canRenderTableHeaders = isFiltering ? true : data.length > 0;
99
- 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) {
106
+ return (_jsxs(TableViewWrapper, __assign({ ref: virtualizedGridRef, "data-test-id": "table-view-wrapper", isLoading: isLoading, checkboxColumnWidth: checkboxColumnWidth, h: tableHeight }, props, { children: [isLoading && loadingUI, _jsx(AutoSizer, { children: function (_a) {
100
107
  var autosizerWidth = _a.width, autosizerHeight = _a.height;
108
+ console.log({ autosizerHeight: autosizerHeight });
101
109
  // using Math.floor to avoid floating point errors with the grid and table cell widths
102
110
  var rowWidth = Math.floor(autosizerWidth * rowWidthScalingFactor);
103
111
  var gridProps = {
@@ -107,7 +115,6 @@ export var TableView = React.memo(function (_a) {
107
115
  rowWidth: rowWidth,
108
116
  onRowClick: onRowClick,
109
117
  columns: columns,
110
- highlightFirstRow: highlightFirstRow,
111
118
  rowHeight: rowHeight,
112
119
  getItemKey: getItemKey,
113
120
  },
@@ -22,12 +22,12 @@ export type TableViewProps = {
22
22
  setSortBy?: React.Dispatch<React.SetStateAction<SortBy>>;
23
23
  isLoading?: boolean;
24
24
  pageSize?: number;
25
- highlightFirstRow?: boolean;
26
25
  rowWidthScalingFactor?: number;
27
26
  rowHeight?: number;
28
27
  tableHeadersHeight?: number;
29
28
  onSectionRendered?: (section: TableSection) => void;
30
29
  onTableScroll?: (scrollTop: number) => void;
30
+ onScrollToBottom?: () => void;
31
31
  onRowClick?: (row: any) => void;
32
32
  getItemKey?: (row: any) => string;
33
33
  isDraggable?: boolean;
@@ -102,7 +102,7 @@ var Autocomplete = function (_a) {
102
102
  if (!isTyping && prefix)
103
103
  setIsTyping(true);
104
104
  setText(v);
105
- }, 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)); }) })))] })));
105
+ }, 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, __assign({ "data-test-id": "autocomplete-menu-item" }, { 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)); }) })))] })));
106
106
  };
107
107
  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" }) })));
108
108
  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" })] })));
@@ -45,7 +45,7 @@ var Checkbox = function (_a) {
45
45
  var newValue = !isChecked || isIndeterminate;
46
46
  onChange(newValue);
47
47
  };
48
- return (_jsx(Container, __assign({}, __assign({ isChecked: isChecked, isDisabled: isDisabled, isIndeterminate: isIndeterminate, onClick: handleOnChange }, props), { children: isIndeterminate ? (_jsx(IndeterminateIcon, {})) : (_jsx(Div, __assign({ centered: true }, { children: isChecked && (icon || checkIcon) }))) })));
48
+ return (_jsx(Container, __assign({}, __assign({ isChecked: isChecked, isDisabled: isDisabled, isIndeterminate: isIndeterminate, onClick: handleOnChange }, props), { "data-test-id": "checkbox" }, { children: isIndeterminate ? (_jsx(IndeterminateIcon, {})) : (_jsx(Div, __assign({ centered: true }, { children: isChecked && (icon || checkIcon) }))) })));
49
49
  };
50
50
  var checkIcon = (_jsx("svg", __assign({ width: "14", height: "10", viewBox: "0 0 14 10", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M1.10254 4.74355L5.2051 8.84612L12.8974 1.15381", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
51
51
  var IndeterminateIcon = function () { return (_jsx("svg", __assign({ width: "14", height: "2", viewBox: "0 0 14 2", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M1 1H13", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }) }))); };
@@ -16,7 +16,7 @@ declare class FuseImporter {
16
16
  private windowScrollPosition;
17
17
  close(): void;
18
18
  show(): Promise<void>;
19
- addColumn<T extends FieldTypesAsUnion>({ options, ...requiredProps }: ColumnRequiredProps<T>): void;
19
+ addColumn<T extends FieldTypesAsUnion>(columnData: ColumnRequiredProps<T>): void;
20
20
  private renderImporterComponent;
21
21
  private createDivComponent;
22
22
  private createIframe;
package/lib/esm/index.js CHANGED
@@ -45,17 +45,6 @@ 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
- var __rest = (this && this.__rest) || function (s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- };
59
48
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
49
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
50
  if (ar || !(i in from)) {
@@ -75,6 +64,7 @@ import * as locales from "./locales";
75
64
  import { StyleSheetManager } from "styled-components";
76
65
  import { fontsURL } from "./styled/fontsURL";
77
66
  import { addLinkToHead, getDefaultValidations } from "./utils";
67
+ import Localbase from "localbase";
78
68
  var FuseImporter = /** @class */ (function () {
79
69
  function FuseImporter(apiToken, templateSlug, options) {
80
70
  if (options === void 0) { options = {}; }
@@ -84,6 +74,28 @@ var FuseImporter = /** @class */ (function () {
84
74
  x: 0,
85
75
  y: 0,
86
76
  };
77
+ var db = new Localbase("myDatabase");
78
+ var item = {
79
+ id: 1,
80
+ name: "My item",
81
+ description: "This is my item",
82
+ };
83
+ db.collection("items")
84
+ .add(item, "id")
85
+ .then(function () {
86
+ console.log("Item added");
87
+ })
88
+ .catch(function (err) {
89
+ console.error("Failed to add item: ", err);
90
+ });
91
+ db.collection("items")
92
+ .get()
93
+ .then(function (items) {
94
+ console.log(items);
95
+ })
96
+ .catch(function (err) {
97
+ console.error("Failed to get items: ", err);
98
+ });
87
99
  this.apiToken = apiToken;
88
100
  this.templateSlug = templateSlug;
89
101
  this.options = __assign({ env: "production", zIndex: 1000, batchValidationDelayMs: 500 }, options);
@@ -131,23 +143,22 @@ var FuseImporter = /** @class */ (function () {
131
143
  });
132
144
  });
133
145
  };
134
- FuseImporter.prototype.addColumn = function (_a) {
135
- var _b;
136
- var options = _a.options, requiredProps = __rest(_a, ["options"]);
137
- validateColumn(__assign(__assign({}, options), requiredProps));
138
- var validations = __spreadArray(__spreadArray([], getDefaultValidations(requiredProps.column_type), true), ((options === null || options === void 0 ? void 0 : options.validations) || []), true);
139
- var transformations = (_b = options === null || options === void 0 ? void 0 : options.transformations) !== null && _b !== void 0 ? _b : [];
146
+ FuseImporter.prototype.addColumn = function (columnData) {
147
+ var column_type = columnData.column_type, internal_key = columnData.internal_key, label = columnData.label, required = columnData.required, pattern = columnData.pattern, position = columnData.position, transformations = columnData.transformations, unique = columnData.unique, validations = columnData.validations, values = columnData.values;
148
+ validateColumn(columnData);
149
+ var treatedValidations = __spreadArray(__spreadArray([], getDefaultValidations(column_type), true), (validations || []), true);
150
+ var treatedTransformations = transformations !== null && transformations !== void 0 ? transformations : [];
140
151
  var column = {
141
- column_type: requiredProps.column_type,
142
- internal_key: requiredProps.internal_key,
143
- label: requiredProps.label,
144
- required: requiredProps.required,
145
- pattern: (options === null || options === void 0 ? void 0 : options.pattern) || null,
146
- position: (options === null || options === void 0 ? void 0 : options.position) || null,
147
- unique: (options === null || options === void 0 ? void 0 : options.unique) || false,
148
- values: requiredProps.column_type === "enum" ? (options === null || options === void 0 ? void 0 : options.values) || [] : [],
149
- validations: validations,
150
- transformations: transformations,
152
+ column_type: column_type,
153
+ internal_key: internal_key,
154
+ label: label,
155
+ required: required,
156
+ pattern: pattern || null,
157
+ position: position || null,
158
+ unique: unique || false,
159
+ values: column_type === "enum" ? values || [] : [],
160
+ validations: treatedValidations,
161
+ transformations: treatedTransformations,
151
162
  };
152
163
  this.dynamicColumns.push(column);
153
164
  };
@@ -11,7 +11,7 @@ export default {
11
11
  },
12
12
  upload: {
13
13
  headers_preview: {
14
- title: "Überprüfen Sie Ihre Spaltenüberschriften",
14
+ title: "Wählen Sie eine Kopfzeile aus",
15
15
  description: "Die Datei muss Spaltenüberschriften enthalten, um fortzufahren.",
16
16
  cancel: "Nein, Datei erneut hochladen",
17
17
  continue: "Ja, Weiter",
@@ -11,7 +11,7 @@ export default {
11
11
  },
12
12
  upload: {
13
13
  headers_preview: {
14
- title: "Verify Your Column Headers",
14
+ title: "Select a Header Row",
15
15
  description: "File must contain column headers to proceed.",
16
16
  cancel: "Re-upload file",
17
17
  continue: "Continue",
@@ -11,7 +11,7 @@ export default {
11
11
  },
12
12
  upload: {
13
13
  headers_preview: {
14
- title: "Verifica tus encabezados de columna",
14
+ title: "Seleccione una fila de encabezado",
15
15
  description: "El archivo debe contener encabezados de columna para continuar.",
16
16
  cancel: "No, vuelva a cargar el archivo",
17
17
  continue: "Sí, continuar",
@@ -11,7 +11,7 @@ export default {
11
11
  },
12
12
  upload: {
13
13
  headers_preview: {
14
- title: "Vérifiez vos en-têtes de colonne",
14
+ title: "Sélectionnez une ligne d'en-tête",
15
15
  description: "Le fichier doit contenir des en-têtes de colonne pour continuer.",
16
16
  cancel: "Non, re-télécharger le fichier",
17
17
  continue: "Oui, continuer",
@@ -5,7 +5,7 @@ export type SpreadsheetOptions = {
5
5
  batchValidationDelayMs?: number;
6
6
  batchValidationSize?: number;
7
7
  showCheckboxColumn?: boolean;
8
- firstRowIsHeader?: boolean;
8
+ withSingleRowSelect?: boolean;
9
9
  };
10
10
  export type ImporterOptions = {
11
11
  zIndex?: number;
@@ -141,13 +141,14 @@ export type Field = {
141
141
  validations?: FieldValidation[];
142
142
  transformations?: FieldTransformation[];
143
143
  };
144
- export type ColumnRequiredProps<T extends FieldTypesAsUnion> = {
144
+ export type ColumnRequiredProps<T extends FieldTypesAsUnion> = Partial<Pick<TemplateHeader, "unique" | "position" | "pattern">> & {
145
145
  internal_key: string;
146
146
  label: string;
147
147
  column_type: T;
148
148
  required: boolean;
149
- options?: ColumnOptions<T>;
150
- };
149
+ validations?: ColumnValidations<T>[];
150
+ transformations?: ColumnTransformations<T>[];
151
+ } & (T extends "enum" ? EnumOptions : T extends "time" ? TimeOptions : OtherOptions);
151
152
  export type ValidationTypesRules<T extends FieldTypesAsUnion> = T extends "integer" ? IntegerValidationRule : T extends "float" ? FloatValidationRule : T extends "string" ? StringValidationRule : T extends "email" ? EmailValidationRule : T extends "enum" ? EnumValidationRule : T extends "url" ? UrlValidationRule : T extends "boolean" ? BooleanValidationRule : T extends "date" ? DateValidationRule : T extends "datetime" ? DateTimeValidationRule : T extends "time" ? TimeValidationRule : never;
152
153
  export type TransformationTypesRules<T extends FieldTypesAsUnion> = T extends "integer" ? IntegerTransformationRule : T extends "float" ? FloatTransformationRule : T extends "string" ? StringTransformationRule : T extends "enum" ? EnumTransformationRule : T extends "url" ? UrlTransformationRule : T extends "date" | "datetime" | "time" ? DateDateTimesAndTimesTransformationRule : never;
153
154
  export type ValidationTypeOptions<T extends ValidationTypesRules<FieldTypesAsUnion>> = T extends "cannot_contain" | "contain" | "regex" ? {
@@ -186,10 +187,6 @@ type TimeOptions = {
186
187
  type OtherOptions = {
187
188
  values?: never;
188
189
  };
189
- export type ColumnOptions<T extends FieldTypesAsUnion> = Partial<Pick<TemplateHeader, "unique" | "position" | "pattern">> & {
190
- validations?: ColumnValidations<T>[];
191
- transformations?: ColumnTransformations<T>[];
192
- } & (T extends "enum" ? EnumOptions : T extends "time" ? TimeOptions : OtherOptions);
193
190
  type StringValidationRule = "cannot_contain" | "contain" | "max_length" | "min_length" | "length_exactly" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
194
191
  type StringTransformationRule = "sentence_case" | "capitalize" | "uppercase" | "lowercase" | "trim_whitespace";
195
192
  type IntegerValidationRule = "less_than" | "greater_than" | "even" | "odd" | "unique_case_sensitive" | "unique_case_insensitive" | "regex";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fuse-importer",
3
3
  "private": false,
4
- "version": "0.0.1-staging",
4
+ "version": "0.0.1-testing",
5
5
  "description": "Flatirons Fuse is a customizable and powerful CSV Importer that works with all front-end languages",
6
6
  "browserslist": {
7
7
  "production": [
@@ -45,6 +45,7 @@
45
45
  "color": "^4.2.3",
46
46
  "fuse.js": "^6.5.3",
47
47
  "i18next": "^22.4.13",
48
+ "localbase": "^0.7.5",
48
49
  "luxon": "^2.2.0",
49
50
  "openai": "^3.2.1",
50
51
  "qs": "^6.10.1",
@@ -70,8 +71,6 @@
70
71
  "@types/testing-library__jest-dom": "^5.14.5",
71
72
  "@types/testing-library__react": "^10.2.0",
72
73
  "dotenv": "^16.0.3",
73
- "react": "^17.x",
74
- "react-dom": "^17.x",
75
74
  "html-webpack-plugin": "^5.5.0",
76
75
  "jest": "^28.1.3",
77
76
  "terser-webpack-plugin": "^5.1.2",
@@ -93,4 +92,4 @@
93
92
  "src/*",
94
93
  "**/node_modules"
95
94
  ]
96
- }
95
+ }