fuse-importer 0.25.4 → 0.25.6
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/ImporterWithContext.js +2 -2
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +2 -4
- package/lib/esm/Importer/Review/ReviewContextProvider.js +4 -14
- package/lib/esm/Importer/Review/ReviewWithContext.js +2 -2
- package/lib/esm/Importer/Stepper/index.js +4 -1
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +2 -1
- package/lib/esm/Importer/Uploader/HeadersPreview.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.d.ts +9 -4
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +30 -5
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +6 -3
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +79 -13
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/hooks.d.ts +2 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +61 -0
- package/lib/esm/Importer/common/Spreadsheet/index.d.ts +2 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.d.ts +8 -2
- package/lib/esm/Importer/common/Spreadsheet/styles.js +10 -5
- package/lib/esm/Importer/contexts/ImporterContextProvider.d.ts +9 -2
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +29 -9
- package/lib/esm/Importer/data/index.d.ts +4 -1
- package/lib/esm/Importer/data/index.js +6 -2
- package/lib/esm/common/ConfirmationModal.d.ts +10 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.d.ts +6 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +65 -0
- package/lib/esm/common/Table/TableActions/SearchRows.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +70 -0
- package/lib/esm/common/Table/TableActions/TableActions.d.ts +10 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +45 -0
- package/lib/esm/common/Table/TableActions/common.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/icons.d.ts +3 -0
- package/lib/esm/common/Table/TableActions/icons.js +15 -0
- package/lib/esm/common/Table/TableActions/index.d.ts +1 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableView/TableCells.js +5 -1
- package/lib/esm/common/Table/TableView/TableRow.d.ts +2 -1
- package/lib/esm/common/Table/TableView/TableRow.js +3 -3
- package/lib/esm/common/Table/TableView/index.d.ts +2 -1
- package/lib/esm/common/Table/TableView/index.js +6 -5
- package/lib/esm/common/buttons.d.ts +1 -1
- package/lib/esm/common/buttons.js +10 -7
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/inputs/Checkbox.d.ts +3 -1
- package/lib/esm/common/inputs/Checkbox.js +15 -12
- package/lib/esm/locales/de.d.ts +2 -0
- package/lib/esm/locales/de.js +3 -1
- package/lib/esm/locales/en.d.ts +2 -0
- package/lib/esm/locales/en.js +3 -1
- package/lib/esm/locales/es.d.ts +2 -0
- package/lib/esm/locales/es.js +3 -1
- package/lib/esm/locales/fr.d.ts +2 -0
- package/lib/esm/locales/fr.js +3 -1
- package/lib/main.js +11 -11
- package/package.json +1 -1
|
@@ -2,10 +2,15 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
import styled from "styled-components";
|
|
5
|
+
import styled, { css } from "styled-components";
|
|
6
6
|
import { TableView as TableViewBase, TableViewCellContainer, TableViewRow, } from "../../../common/Table/TableView";
|
|
7
7
|
import { Div } from "../../../styled/utils";
|
|
8
|
-
export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n width: 100%;\n"])));
|
|
9
|
-
export var SpreadSheetWrapper = styled(Div)(
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export var SpreadSheetData = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n max-height: 675px;\n width: 100%;\n"], ["\n display: flex;\n justify-content: center;\n max-height: 675px;\n width: 100%;\n"])));
|
|
9
|
+
export var SpreadSheetWrapper = styled(Div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"], ["\n border: solid 1px ", ";\n background: ", ";\n overflow: hidden !important;\n flex-grow: 1;\n\n ", "\n"])), function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.colors.white; }, function (_a) {
|
|
10
|
+
var canShowCheckboxOnHover = _a.canShowCheckboxOnHover, shouldShowOnlyCheckbox = _a.shouldShowOnlyCheckbox;
|
|
11
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "], ["\n .spreadsheet-row-container {\n ", "\n\n ", "\n }\n "])), shouldShowOnlyCheckbox && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "], ["\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n "]))), !shouldShowOnlyCheckbox &&
|
|
12
|
+
canShowCheckboxOnHover && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "], ["\n &:hover {\n .row-numbers-cell {\n visibility: hidden;\n }\n\n .checkbox-cell {\n visibility: visible;\n }\n }\n "]))));
|
|
13
|
+
});
|
|
14
|
+
export var SpreadSheetContainer = styled(Div)(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
|
|
15
|
+
export var TableView = styled(TableViewBase)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"], ["\n width: 100%;\n border: none;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n overflow: hidden;\n background-color: ", ";\n ", " {\n border-bottom: none;\n height: 40px;\n }\n ", " {\n padding: 0;\n border-right: 1px solid ", ";\n }\n"])), function (p) { return p.theme.colors.gray50; }, TableViewRow, TableViewCellContainer, function (p) { return p.theme.colors.gray300; });
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -14,6 +14,10 @@ export type EnumFieldValueMatchings = {
|
|
|
14
14
|
export type UploadedDataEnumFieldValues = {
|
|
15
15
|
[templateHeaderLabel: string]: string[];
|
|
16
16
|
};
|
|
17
|
+
export type SelectedRow = {
|
|
18
|
+
tableRow: number;
|
|
19
|
+
dataRowIndex: number;
|
|
20
|
+
};
|
|
17
21
|
export type State = {
|
|
18
22
|
currentStepIndex: number;
|
|
19
23
|
templateError: string | null;
|
|
@@ -44,8 +48,11 @@ export type State = {
|
|
|
44
48
|
formatRecord: FormatRecord;
|
|
45
49
|
onValidateRecord?: OnValidateRecord;
|
|
46
50
|
setMatcherSubstep: React.Dispatch<number>;
|
|
47
|
-
selectedRows:
|
|
48
|
-
setSelectedRows: React.Dispatch<React.SetStateAction<
|
|
51
|
+
selectedRows: string[];
|
|
52
|
+
setSelectedRows: React.Dispatch<React.SetStateAction<string[]>>;
|
|
53
|
+
isUsingManualImport: React.MutableRefObject<boolean>;
|
|
54
|
+
resetImporterWhenUsingManualImport: () => void;
|
|
55
|
+
manualDataImportSelected: () => void;
|
|
49
56
|
};
|
|
50
57
|
export type Props = {
|
|
51
58
|
templateSlug: string;
|
|
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
49
|
import Fuse from "fuse.js";
|
|
50
|
-
import { createContext, useContext, useEffect, useMemo, useState, } from "react";
|
|
50
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
51
51
|
import { FieldTypes, } from "../../types";
|
|
52
52
|
import { FuseApi } from "../common/FuseApi";
|
|
53
53
|
import { getCustomTheme, theme } from "../common/theme";
|
|
@@ -75,16 +75,24 @@ export var ImporterContextProvider = function (_a) {
|
|
|
75
75
|
var _m = useState(null), enumFieldValueMatchings = _m[0], setEnumFieldValueMatchings = _m[1];
|
|
76
76
|
var _o = useState(null), uploadedDataEnumFieldValues = _o[0], setUploadedDataEnumFieldValues = _o[1];
|
|
77
77
|
var _p = useState([]), selectedRows = _p[0], setSelectedRows = _p[1];
|
|
78
|
+
var isUsingManualImport = useRef(false);
|
|
78
79
|
var fuseApi = useMemo(function () { return new FuseApi(options.env, apiToken); }, [
|
|
79
80
|
options.env,
|
|
80
81
|
apiToken,
|
|
81
82
|
]);
|
|
82
83
|
var uploadedDataHeaders = useMemo(function () {
|
|
83
84
|
var _a;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
if (!uploadedData)
|
|
86
|
+
return null;
|
|
87
|
+
if (isUsingManualImport.current) {
|
|
88
|
+
return templateHeaders.reduce(function (acc, curr) {
|
|
89
|
+
acc.push(curr.internal_key);
|
|
90
|
+
return acc;
|
|
91
|
+
}, []);
|
|
92
|
+
}
|
|
93
|
+
return (_a = uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
|
|
94
|
+
return typeof ud === "number" ? ud.toString() : ud;
|
|
95
|
+
});
|
|
88
96
|
}, [uploadedData]);
|
|
89
97
|
useEffect(function () {
|
|
90
98
|
if (!templateHeaderMatchings)
|
|
@@ -113,12 +121,8 @@ export var ImporterContextProvider = function (_a) {
|
|
|
113
121
|
useEffect(function () {
|
|
114
122
|
if (uploadedData) {
|
|
115
123
|
setHeadersFromDataset();
|
|
116
|
-
selectAllRows();
|
|
117
124
|
}
|
|
118
125
|
}, [uploadedData]);
|
|
119
|
-
var selectAllRows = function () {
|
|
120
|
-
setSelectedRows(uploadedData.map(function (_, index) { return index; }));
|
|
121
|
-
};
|
|
122
126
|
useEffect(function () {
|
|
123
127
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
124
128
|
var _a, organization_1, columns, importer_style_preferences, integrations_1, preview_first_time, columnsOrderedByPosition, error_1, errorMsg;
|
|
@@ -154,6 +158,19 @@ export var ImporterContextProvider = function (_a) {
|
|
|
154
158
|
setUploadedData(null);
|
|
155
159
|
setTemplateHeaderMatchings(null);
|
|
156
160
|
};
|
|
161
|
+
var resetImporterWhenUsingManualImport = function () {
|
|
162
|
+
setCurrentStepIndex(0);
|
|
163
|
+
isUsingManualImport.current = false;
|
|
164
|
+
resetImport();
|
|
165
|
+
};
|
|
166
|
+
var manualDataImportSelected = function () {
|
|
167
|
+
if (templateHeaders) {
|
|
168
|
+
isUsingManualImport.current = true;
|
|
169
|
+
setUploadedData([]);
|
|
170
|
+
setTemplateHeaderMatchings({});
|
|
171
|
+
setCurrentStepIndex(2);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
157
174
|
var setHeadersFromDataset = function () {
|
|
158
175
|
var _templateHeaderMatchings = {};
|
|
159
176
|
var fuse = new Fuse(uploadedDataHeaders, fusejsOptions);
|
|
@@ -197,6 +214,9 @@ export var ImporterContextProvider = function (_a) {
|
|
|
197
214
|
onSubmit: onSubmit,
|
|
198
215
|
selectedRows: selectedRows,
|
|
199
216
|
setSelectedRows: setSelectedRows,
|
|
217
|
+
isUsingManualImport: isUsingManualImport,
|
|
218
|
+
resetImporterWhenUsingManualImport: resetImporterWhenUsingManualImport,
|
|
219
|
+
manualDataImportSelected: manualDataImportSelected,
|
|
200
220
|
};
|
|
201
221
|
return (_jsx(ImporterContext.Provider, __assign({ value: value }, { children: children })));
|
|
202
222
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader } from "../../types";
|
|
2
2
|
import { EnumFieldValueMatchings, HeaderMatchings } from "../contexts/ImporterContextProvider";
|
|
3
|
+
export declare const addEmptyRows: (data: Record[], fields: Field[]) => Record[];
|
|
3
4
|
export declare const addMeta: (record: any, index: number) => Record;
|
|
4
5
|
export declare const recordListToDataSet: (data: Record[], fields: Field[]) => RecordDataSet;
|
|
5
6
|
type transformToRecordsArgs = {
|
|
@@ -23,6 +24,8 @@ export declare const getPreviewDataSet: ({ uploadedData, }: {
|
|
|
23
24
|
};
|
|
24
25
|
export declare const getReviewDataSet: ({ templateHeaderMatchings, enumFieldValueMatchings, templateHeaders, uploadedDataHeaders, uploadedData, formatRecord, }: transformToRecordsArgs) => {
|
|
25
26
|
fields: Field[];
|
|
26
|
-
initialDataSet:
|
|
27
|
+
initialDataSet: {
|
|
28
|
+
[x: string]: Record;
|
|
29
|
+
};
|
|
27
30
|
};
|
|
28
31
|
export {};
|
|
@@ -16,7 +16,7 @@ var getRowId = function (index) {
|
|
|
16
16
|
var uniqueTimestamp = new Date().getTime();
|
|
17
17
|
return "r".concat(index, "-").concat(uniqueTimestamp);
|
|
18
18
|
};
|
|
19
|
-
var addEmptyRows = function (data, fields) {
|
|
19
|
+
export var addEmptyRows = function (data, fields) {
|
|
20
20
|
var emptyRecord = fields.reduce(function (obj, f) {
|
|
21
21
|
var _a;
|
|
22
22
|
return (__assign(__assign({}, obj), (_a = {}, _a[f.name] = null, _a)));
|
|
@@ -110,6 +110,7 @@ export var getPreviewDataSet = function (_a) {
|
|
|
110
110
|
return { fields: fields, initialDataSet: getInitialDataSet() };
|
|
111
111
|
};
|
|
112
112
|
export var getReviewDataSet = function (_a) {
|
|
113
|
+
var _b;
|
|
113
114
|
var templateHeaderMatchings = _a.templateHeaderMatchings, enumFieldValueMatchings = _a.enumFieldValueMatchings, templateHeaders = _a.templateHeaders, uploadedDataHeaders = _a.uploadedDataHeaders, uploadedData = _a.uploadedData, formatRecord = _a.formatRecord;
|
|
114
115
|
var fields = templateHeaders.map(function (templateHeader) { return ({
|
|
115
116
|
label: templateHeader.label,
|
|
@@ -128,6 +129,9 @@ export var getReviewDataSet = function (_a) {
|
|
|
128
129
|
uploadedData: uploadedData,
|
|
129
130
|
formatRecord: formatRecord,
|
|
130
131
|
});
|
|
131
|
-
var
|
|
132
|
+
var baseInitialDataSet = recordListToDataSet(addEmptyRows(records, fields), fields);
|
|
133
|
+
var highestRowIndex = Math.max.apply(Math, Object.values(records).map(function (obj) { return obj._meta.rowIndex; }));
|
|
134
|
+
var emptyRowAtBottom = addMeta({}, highestRowIndex + 1);
|
|
135
|
+
var initialDataSet = __assign(__assign({}, baseInitialDataSet), (_b = {}, _b[emptyRowAtBottom._meta.id] = emptyRowAtBottom, _b));
|
|
132
136
|
return { fields: fields, initialDataSet: initialDataSet };
|
|
133
137
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const ConfirmationModal: ({ isOpen, handleClose, onSubmit, title, description, buttonText, icon, hasCancelButton, }: {
|
|
2
|
+
isOpen: any;
|
|
3
|
+
handleClose: any;
|
|
4
|
+
onSubmit: any;
|
|
5
|
+
title: any;
|
|
6
|
+
description: any;
|
|
7
|
+
buttonText: any;
|
|
8
|
+
icon?: any;
|
|
9
|
+
hasCancelButton?: boolean;
|
|
10
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { colors, Div, Modal, Button } from "../";
|
|
14
|
+
export var ConfirmationModal = function (_a) {
|
|
15
|
+
var isOpen = _a.isOpen, handleClose = _a.handleClose, onSubmit = _a.onSubmit, title = _a.title, description = _a.description, buttonText = _a.buttonText, _b = _a.icon, icon = _b === void 0 ? null : _b, _c = _a.hasCancelButton, hasCancelButton = _c === void 0 ? true : _c;
|
|
16
|
+
var headerUI = (_jsxs(Div, { children: [icon && (_jsx(Div, __assign({ centered: true, mb: 20 }, { children: icon }))), _jsx(Div, __assign({ mb: 16 }, { children: _jsx(Div, __assign({ h5: true, dflex: true, centered: true }, { children: title })) }))] }));
|
|
17
|
+
var bodyUI = (_jsxs(_Fragment, { children: [_jsx(Div, __assign({ c: colors.gray800, body1: true, flexColumn: true, centered: true }, { children: description })), _jsxs(Div, __assign({ mt: 40, dflex: true, centered: true }, { children: [hasCancelButton && (_jsx(Button, __assign({ variant: "secondary", mr: 16, w: 104, onClick: handleClose }, { children: "Cancel" }))), _jsx(Button, __assign({ w: 135, onClick: onSubmit }, { children: buttonText }))] }))] }));
|
|
18
|
+
return (_jsx(_Fragment, { children: _jsx(Modal, __assign({ isOpen: isOpen, onClose: handleClose }, { children: _jsxs(Div, __assign({ p: "48px 56px" }, { children: [headerUI, bodyUI] })) })) }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface DeleteSelectedRowsProps {
|
|
2
|
+
testId?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const ActionButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
+
export declare const DeleteSelectedRows: ({ testId, }: DeleteSelectedRowsProps) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import styled from "styled-components";
|
|
19
|
+
import { TooltipProvider } from "../../../common/TooltipProvider";
|
|
20
|
+
import { ConfirmationModal } from "../../../common/ConfirmationModal";
|
|
21
|
+
import { useSpreadsheetContext } from "../../../Importer";
|
|
22
|
+
import { useImporterContext } from "../../../Importer/contexts/ImporterContextProvider";
|
|
23
|
+
import { DeleteIcon, ConfirmationDeleteIcon } from "./icons";
|
|
24
|
+
import { addToast } from "../../../common/Toast";
|
|
25
|
+
import { Div } from "../../../styled/utils";
|
|
26
|
+
var StyledTooltipProvider = styled(TooltipProvider)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: fit-content;\n"], ["\n width: fit-content;\n"])));
|
|
27
|
+
export var ActionButton = styled.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 40px;\n justify-content: center;\n width: 40px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"], ["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 40px;\n justify-content: center;\n width: 40px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"])));
|
|
28
|
+
var filterByRecordsThatContainsValues = function (mainObject) {
|
|
29
|
+
return mainObject.filter(function (obj) {
|
|
30
|
+
for (var key in obj) {
|
|
31
|
+
if (key !== "_meta" && obj[key] !== null && obj[key] !== undefined) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export var DeleteSelectedRows = function (_a) {
|
|
39
|
+
var _b = _a.testId, testId = _b === void 0 ? "ta-delete-rows" : _b;
|
|
40
|
+
var _c = useState(false), isConfirmationModalOpen = _c[0], setIsConfirmationModalOpen = _c[1];
|
|
41
|
+
var _d = useSpreadsheetContext(), data = _d.data, filteredInputValue = _d.filteredInputValue, deleteRecords = _d.deleteRecords, selectedRows = _d.selectedRows, setSelectedRows = _d.setSelectedRows, setFilteredInputValue = _d.setFilteredInputValue;
|
|
42
|
+
var _e = useImporterContext(), setCurrentStepIndex = _e.setCurrentStepIndex, isUsingManualImport = _e.isUsingManualImport;
|
|
43
|
+
var toggleModalVisibility = function () {
|
|
44
|
+
setIsConfirmationModalOpen(function (oldValue) { return !oldValue; });
|
|
45
|
+
};
|
|
46
|
+
var handleDeleteRecord = function () {
|
|
47
|
+
setSelectedRows([]);
|
|
48
|
+
toggleModalVisibility();
|
|
49
|
+
setFilteredInputValue("");
|
|
50
|
+
var validData = filterByRecordsThatContainsValues(data);
|
|
51
|
+
// If user is deleting every row, but not using the manual import option
|
|
52
|
+
if (!isUsingManualImport.current &&
|
|
53
|
+
!filteredInputValue &&
|
|
54
|
+
selectedRows.length === validData.length) {
|
|
55
|
+
setCurrentStepIndex(0);
|
|
56
|
+
return addToast("You have deleted all the rows. You will be redirect to the upload step.", "success");
|
|
57
|
+
}
|
|
58
|
+
deleteRecords(selectedRows);
|
|
59
|
+
};
|
|
60
|
+
var DescriptionUI = function () { return (_jsx(_Fragment, { children: _jsxs(Div, { children: ["Are you sure you want to delete ", selectedRows.length, " row", selectedRows.length > 1 ? "s" : "", "?"] }) })); };
|
|
61
|
+
var confirmationModalUI = (_jsx(ConfirmationModal, { isOpen: isConfirmationModalOpen, handleClose: toggleModalVisibility, title: "Delete Selected Row".concat(selectedRows.length > 1 ? "s" : ""), description: _jsx(DescriptionUI, {}), onSubmit: handleDeleteRecord, buttonText: "Yes, delete", icon: ConfirmationDeleteIcon }));
|
|
62
|
+
var isDeleteButtonDisabled = selectedRows.length <= 0;
|
|
63
|
+
return (_jsxs(_Fragment, { children: [confirmationModalUI, _jsx(StyledTooltipProvider, __assign({ tooltip: isDeleteButtonDisabled ? "Select rows to delete" : "Delete Row", placement: "right", flip: false, centered: true, "data-testid": testId }, { children: _jsx(ActionButton, __assign({ onClick: toggleModalVisibility, disabled: isDeleteButtonDisabled }, { children: _jsx(DeleteIcon, {}) })) }))] }));
|
|
64
|
+
};
|
|
65
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import styled, { css } from "styled-components";
|
|
18
|
+
import { useSpreadsheetContext } from "../../../Importer";
|
|
19
|
+
import { SearchIcon } from "./icons";
|
|
20
|
+
import { useDebounce } from "../../../hooks";
|
|
21
|
+
import { useRef, useState } from "react";
|
|
22
|
+
import { colors } from "../../../styled/theme/colorPalette";
|
|
23
|
+
import { textStyles } from "../../../styled/theme/textStyles";
|
|
24
|
+
import { TooltipProvider } from "../../../common/TooltipProvider";
|
|
25
|
+
var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n border-radius: 4px;\n cursor: pointer;\n display: flex;\n gap: 8px;\n height: 24px;\n overflow: hidden;\n padding: 8px;\n transition: width 0.25s ease-in-out;\n width: ", ";\n"], ["\n background: ", ";\n border-radius: 4px;\n cursor: pointer;\n display: flex;\n gap: 8px;\n height: 24px;\n overflow: hidden;\n padding: 8px;\n transition: width 0.25s ease-in-out;\n width: ", ";\n"])), function (_a) {
|
|
26
|
+
var isOpen = _a.isOpen;
|
|
27
|
+
return (isOpen ? colors.orange50 : "none");
|
|
28
|
+
}, function (_a) {
|
|
29
|
+
var isOpen = _a.isOpen;
|
|
30
|
+
return (isOpen ? "332px" : "24px");
|
|
31
|
+
});
|
|
32
|
+
var IconWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 24px;\n width: 24px;\n"], ["\n height: 24px;\n width: 24px;\n"])));
|
|
33
|
+
var Input = styled.input(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n background: none;\n border: none;\n color: ", ";\n outline: none;\n width: 100%;\n\n ", ";\n"], ["\n ", ";\n background: none;\n border: none;\n color: ", ";\n outline: none;\n width: 100%;\n\n ", ";\n"])), textStyles.body3, colors.gray700, function (_a) {
|
|
34
|
+
var isOpen = _a.isOpen;
|
|
35
|
+
return !isOpen && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: -9999px;\n "], ["\n position: absolute;\n top: -9999px;\n "])));
|
|
36
|
+
});
|
|
37
|
+
var SearchInput = function (_a) {
|
|
38
|
+
var testId = _a.testId, value = _a.value, onChange = _a.onChange;
|
|
39
|
+
var _b = useDebounce(value, onChange, 300), _value = _b._value, set_Value = _b.set_Value;
|
|
40
|
+
var inputRef = useRef(null);
|
|
41
|
+
var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
|
42
|
+
var handleInputChange = function (_a) {
|
|
43
|
+
var target = _a.target;
|
|
44
|
+
set_Value(target.value);
|
|
45
|
+
};
|
|
46
|
+
var handleInputOnBlur = function () {
|
|
47
|
+
if (!_value) {
|
|
48
|
+
setIsOpen(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var handleWrapperClick = function () {
|
|
52
|
+
var _a;
|
|
53
|
+
if (!isOpen) {
|
|
54
|
+
setIsOpen(true);
|
|
55
|
+
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
56
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return (_jsx(TooltipProvider, __assign({ tooltip: !isOpen ? "Search something" : "", placement: "right", flip: false, centered: true, "data-testid": testId }, { children: _jsxs(Wrapper, __assign({ isOpen: isOpen, onClick: handleWrapperClick }, { children: [_jsx(IconWrapper, { children: _jsx(SearchIcon, {}) }), _jsx(Input, { isOpen: isOpen, ref: inputRef, value: _value, onChange: handleInputChange, onBlur: handleInputOnBlur, type: "text", placeholder: "Search something..." })] })) })));
|
|
61
|
+
};
|
|
62
|
+
export var SearchRows = function (_a) {
|
|
63
|
+
var _b = _a.testId, testId = _b === void 0 ? "ta-search-rows" : _b;
|
|
64
|
+
var _c = useSpreadsheetContext(), filteredInputValue = _c.filteredInputValue, setFilteredInputValue = _c.setFilteredInputValue;
|
|
65
|
+
var handleChangeInputValue = function (value) {
|
|
66
|
+
setFilteredInputValue(value);
|
|
67
|
+
};
|
|
68
|
+
return (_jsx(SearchInput, { testId: testId, value: filteredInputValue, onChange: handleChangeInputValue }));
|
|
69
|
+
};
|
|
70
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type TableActionsContainerProps = {
|
|
2
|
+
height: number;
|
|
3
|
+
};
|
|
4
|
+
type TableActionsProps = {
|
|
5
|
+
tableActionsHeight?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const TableActionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableActionsContainerProps, never>;
|
|
8
|
+
export declare const TableActionsContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
|
|
9
|
+
export declare const TableActions: ({ tableActionsHeight, ...props }: TableActionsProps) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import styled from "styled-components";
|
|
29
|
+
import { Div } from "../../../styled/utils";
|
|
30
|
+
import { defaultTableActionsHeightPx } from "./common";
|
|
31
|
+
import { DeleteSelectedRows } from "./DeleteSelectedRows";
|
|
32
|
+
import { SearchRows } from "./SearchRows";
|
|
33
|
+
export var TableActionsContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border-top: 1px solid ", ";\n display: flex;\n overflow: hidden;\n padding: 8px 32px;\n"], ["\n align-items: center;\n background: ", ";\n border-top: 1px solid ", ";\n display: flex;\n overflow: hidden;\n padding: 8px 32px;\n"])), function (_a) {
|
|
34
|
+
var theme = _a.theme;
|
|
35
|
+
return theme.colors.white;
|
|
36
|
+
}, function (_a) {
|
|
37
|
+
var theme = _a.theme;
|
|
38
|
+
return theme.colors.gray300;
|
|
39
|
+
});
|
|
40
|
+
export var TableActionsContent = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])));
|
|
41
|
+
export var TableActions = function (_a) {
|
|
42
|
+
var _b = _a.tableActionsHeight, tableActionsHeight = _b === void 0 ? defaultTableActionsHeightPx : _b, props = __rest(_a, ["tableActionsHeight"]);
|
|
43
|
+
return (_jsx(TableActionsContainer, __assign({ height: tableActionsHeight }, props, { children: _jsxs(TableActionsContent, __assign({ dflex: true }, { children: [_jsx(SearchRows, {}), _jsx(DeleteSelectedRows, {})] })) })));
|
|
44
|
+
};
|
|
45
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultTableActionsHeightPx = 60;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var defaultTableActionsHeightPx = 60;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export var DeleteIcon = function () { return (_jsxs("svg", __assign({ width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M3.5 5.16675H18.5L17.9875 15.4164C17.8545 18.0775 15.6581 20.1667 12.9938 20.1667H9.00625C6.34188 20.1667 4.14554 18.0775 4.01248 15.4164L3.5 5.16675Z", stroke: "#262626", strokeWidth: "2" }), _jsx("path", { d: "M6.83331 5.16675V4.83341C6.83331 3.17656 8.17646 1.83341 9.83331 1.83341H12.1666C13.8235 1.83341 15.1666 3.17656 15.1666 4.83341V5.16675", stroke: "#262626", strokeWidth: "2" }), _jsx("path", { d: "M1.83331 5.16675H20.1666", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round" }), _jsx("path", { d: "M13.5 10.1667V14.3334", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round" }), _jsx("path", { d: "M8.5 10.1667V14.3334", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round" })] }))); };
|
|
14
|
+
export var ConfirmationDeleteIcon = (_jsxs("svg", __assign({ width: "68", height: "68", viewBox: "0 0 68 68", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("rect", { width: "68", height: "68", fill: "white" }), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M8.79639 4.52687C8.79639 3.70291 9.73698 3.23251 10.3962 3.72676L33.7964 21.2699C33.9246 21.3661 34.0001 21.517 34.0001 21.6772L34.0001 46.015C34.0001 46.4345 33.5212 46.674 33.1856 46.4224L9.59669 28.7376C9.0929 28.3599 8.79639 27.7671 8.79639 27.1374L8.79639 4.52687Z", fill: "url(#paint0_linear_2363_5281)" }) })), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M8.7959 63.1264C8.7959 63.9504 9.73649 64.4208 10.3957 63.9266L33.7959 46.3834C33.9241 46.2873 33.9996 46.1363 33.9996 45.9761L33.9996 21.6383C33.9996 21.2188 33.5207 20.9794 33.1851 21.231L9.5962 38.9157C9.09241 39.2934 8.7959 39.8863 8.7959 40.5159L8.7959 63.1264Z", fill: "url(#paint1_linear_2363_5281)" }) })), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M59.2039 4.87257C59.2039 4.04862 58.2633 3.57821 57.604 4.07246L34.1528 21.6539C34.0567 21.726 34.0002 21.839 34.0002 21.9591L34.0002 46.6159C34.0002 46.9302 34.359 47.1097 34.6104 46.9211L58.4036 29.0833C58.9073 28.7056 59.2039 28.1128 59.2039 27.4831L59.2039 4.87257Z", fill: "url(#paint2_linear_2363_5281)" }) })), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M59.2041 63.4722C59.2041 64.2961 58.2635 64.7665 57.6043 64.2723L34.1531 46.6908C34.057 46.6188 34.0004 46.5057 34.0004 46.3856L34.0004 21.7288C34.0004 21.4145 34.3592 21.2351 34.6107 21.4236L58.4038 39.2614C58.9076 39.6391 59.2041 40.232 59.2041 40.8616L59.2041 63.4722Z", fill: "url(#paint3_linear_2363_5281)" }) })), _jsxs("defs", { children: [_jsxs("linearGradient", __assign({ id: "paint0_linear_2363_5281", x1: "28.828", y1: "2.27186", x2: "10.8931", y2: "6.63443", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#FF710A" }), _jsx("stop", { offset: "1", stopColor: "#FD9827" })] })), _jsxs("linearGradient", __assign({ id: "paint1_linear_2363_5281", x1: "28.8275", y1: "65.3815", x2: "10.8926", y2: "61.0189", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#FF710A" }), _jsx("stop", { offset: "1", stopColor: "#FD9827" })] })), _jsxs("linearGradient", __assign({ id: "paint2_linear_2363_5281", x1: "41.7498", y1: "25.1258", x2: "70.7926", y2: "29.9741", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#EDD172" }), _jsx("stop", { offset: "1", stopColor: "#D0A617" })] })), _jsxs("linearGradient", __assign({ id: "paint3_linear_2363_5281", x1: "41.7501", y1: "43.2189", x2: "70.7929", y2: "38.3706", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#EDD172" }), _jsx("stop", { offset: "1", stopColor: "#D0A617" })] }))] })] })));
|
|
15
|
+
export var SearchIcon = function () { return (_jsxs("svg", __assign({ width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M11 20C15.9706 20 20 15.9706 20 11C20 6.02944 15.9706 2 11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20Z", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M21 21L18 18", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }))); };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TableActions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TableActions";
|
|
@@ -16,11 +16,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 "../../../Importer";
|
|
19
20
|
var Cell = React.memo(function (_a) {
|
|
21
|
+
var _b;
|
|
20
22
|
var data = _a.data, rowIndex = _a.rowIndex, style = _a.style;
|
|
21
23
|
var items = data.items, onRowClick = data.onRowClick, columns = data.columns, highlightFirstRow = data.highlightFirstRow, rowHeight = data.rowHeight, getItemKey = data.getItemKey;
|
|
22
24
|
var item = items[rowIndex];
|
|
23
|
-
|
|
25
|
+
var selectedRows = useSpreadsheetContext().selectedRows;
|
|
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
|
+
return (_jsx(Div, __assign({ style: style }, { children: _jsx(TableRow, { columns: columns, onRowClick: onRowClick, highlightFirstRow: highlightFirstRow, h: rowHeight, row: item, indexI: rowIndex, isLast: rowIndex === items.length - 1, pRelative: true, getItemKey: getItemKey, isRowSelected: isRowSelected || false }) })));
|
|
24
28
|
}, areEqual);
|
|
25
29
|
var DraggableCell = React.memo(function (_a) {
|
|
26
30
|
var data = _a.data, rowIndex = _a.rowIndex, baseStyle = _a.style;
|
|
@@ -12,6 +12,7 @@ type Props = Pick<TableViewProps, "columns" | "onRowClick" | "highlightFirstRow"
|
|
|
12
12
|
indexI: number;
|
|
13
13
|
isLast?: boolean;
|
|
14
14
|
getItemKey?: (row: any) => string;
|
|
15
|
+
isRowSelected?: boolean;
|
|
15
16
|
} & DivCSSProps;
|
|
16
|
-
export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey, ...props }: Props) => JSX.Element;
|
|
17
|
+
export declare const TableRow: ({ row, indexI, columns, isLast, highlightFirstRow, onRowClick, getItemKey, isRowSelected, ...props }: Props) => JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -37,11 +37,11 @@ export var Cell = React.memo(function (props) {
|
|
|
37
37
|
export var TableViewRow = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: white;\n ", "\n ", "\n"], ["\n background-color: white;\n ", "\n ", "\n"])), function (p) {
|
|
38
38
|
return !p.isLast && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: inset 0 -1px 0 ", ";\n "], ["\n box-shadow: inset 0 -1px 0 ", ";\n "])), function (p) { return p.theme.colors.gray300; });
|
|
39
39
|
}, function (p) {
|
|
40
|
-
return p.isHighlighted && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n "], ["\n background: ", ";\n box-shadow: inset 0 0 0 3px ", ";\n "])), p.theme.colors.blue100, p.theme.colors.blue500);
|
|
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, props = __rest(_a, ["row", "indexI", "columns", "isLast", "highlightFirstRow", "onRowClick", "getItemKey"]);
|
|
44
|
-
var isHighlighted = indexI === 0 && highlightFirstRow;
|
|
43
|
+
var row = _a.row, indexI = _a.indexI, columns = _a.columns, isLast = _a.isLast, highlightFirstRow = _a.highlightFirstRow, onRowClick = _a.onRowClick, getItemKey = _a.getItemKey, _b = _a.isRowSelected, isRowSelected = _b === void 0 ? false : _b, props = __rest(_a, ["row", "indexI", "columns", "isLast", "highlightFirstRow", "onRowClick", "getItemKey", "isRowSelected"]);
|
|
44
|
+
var isHighlighted = (indexI === 0 && highlightFirstRow) || isRowSelected;
|
|
45
45
|
return (_jsx(TableViewRow, __assign({ "data-test-id": "row-".concat(indexI), dflex: true }, { isHighlighted: isHighlighted, isLast: isLast }, props, { children: columns.map(function (column, indexJ) {
|
|
46
46
|
var Content = column.Content;
|
|
47
47
|
var key = getItemKey ? getItemKey(row) : "".concat(indexI);
|
|
@@ -38,5 +38,6 @@ export type TableViewProps = {
|
|
|
38
38
|
onRowClick?: (row: any) => void;
|
|
39
39
|
getItemKey?: (row: any) => string;
|
|
40
40
|
shouldBeDraggable?: boolean;
|
|
41
|
+
isInsideImporter?: boolean;
|
|
41
42
|
} & DivCSSProps;
|
|
42
|
-
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, ...props }: TableViewProps) => JSX.Element>;
|
|
43
|
+
export declare const TableView: React.MemoExoticComponent<({ data, columns, pageSize, onRowClick, sortBy, isLoading, highlightFirstRow, setSortBy, rowWidth, onSectionRendered, tableHeadersHeight, rowHeight, h, onTableScroll, getItemKey, shouldBeDraggable, isInsideImporter, ...props }: TableViewProps) => JSX.Element>;
|
|
@@ -38,11 +38,12 @@ import { Cell, DraggableCell } from "./TableCells";
|
|
|
38
38
|
export * from "./common";
|
|
39
39
|
export * from "./TableHeaders";
|
|
40
40
|
export * from "./TableRow";
|
|
41
|
-
export var TableViewWrapper = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n border-radius: 8px;\n border: solid 1px ", ";\n overflow: hidden;\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 // fix scrollbar layout issues on windows/macos\n .ReactVirtualized__Grid {\n ", ";\n }\n"], ["\n ", "\n border-radius: 8px;\n border: solid 1px ", ";\n overflow: hidden;\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 // fix scrollbar layout issues on windows/macos\n .ReactVirtualized__Grid {\n ", ";\n }\n"])), function (p) {
|
|
41
|
+
export var TableViewWrapper = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n border-radius: 8px;\n border: solid 1px ", ";\n max-width: calc(100vw - 50px);\n overflow: hidden;\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 // fix scrollbar layout issues on windows/macos\n .ReactVirtualized__Grid {\n ", ";\n }\n"], ["\n ", "\n border-radius: 8px;\n border: solid 1px ", ";\n max-width: calc(100vw - 50px);\n overflow: hidden;\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 // fix scrollbar layout issues on windows/macos\n .ReactVirtualized__Grid {\n ", ";\n }\n"])), function (p) {
|
|
42
42
|
return p.isLoading && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0.5;\n "], ["\n opacity: 0.5;\n "])));
|
|
43
43
|
}, function (p) { return p.theme.colors.gray300; }, function (p) { return p.theme.css.scrollbarDark; });
|
|
44
44
|
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"])));
|
|
45
45
|
var tableHeaderId = "tableHeaderId";
|
|
46
|
+
var StyledGrid = styled(Grid)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n\n -ms-overflow-style: none;\n overflow: -moz-scrollbars-none;\n scrollbar-width: none;\n"], ["\n ::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n\n -ms-overflow-style: none;\n overflow: -moz-scrollbars-none;\n scrollbar-width: none;\n"])));
|
|
46
47
|
var buildGridStyles = function (rowWidth) {
|
|
47
48
|
/* using style={{ willChange: "unset" }} is important for having items
|
|
48
49
|
like backdrops with position fixed inside of the table working as
|
|
@@ -58,7 +59,7 @@ var buildGridStyles = function (rowWidth) {
|
|
|
58
59
|
return gridStyles;
|
|
59
60
|
};
|
|
60
61
|
export var TableView = React.memo(function (_a) {
|
|
61
|
-
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, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidth", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "shouldBeDraggable"]);
|
|
62
|
+
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.isInsideImporter, isInsideImporter = _p === void 0 ? false : _p, props = __rest(_a, ["data", "columns", "pageSize", "onRowClick", "sortBy", "isLoading", "highlightFirstRow", "setSortBy", "rowWidth", "onSectionRendered", "tableHeadersHeight", "rowHeight", "h", "onTableScroll", "getItemKey", "shouldBeDraggable", "isInsideImporter"]);
|
|
62
63
|
/*
|
|
63
64
|
multiply the rowWidth by 0.95 to let the user know they can scroll
|
|
64
65
|
horizontally (will display partial column on the right)
|
|
@@ -97,9 +98,9 @@ export var TableView = React.memo(function (_a) {
|
|
|
97
98
|
rowHeight: rowHeight,
|
|
98
99
|
getItemKey: getItemKey,
|
|
99
100
|
}); }, [data, onRowClick, columns, highlightFirstRow, rowHeight]);
|
|
100
|
-
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading, h: tableHeight }, props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
101
|
+
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper", isLoading: isLoading }, (!isInsideImporter ? { h: tableHeight } : {}), props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
101
102
|
var width = _a.width, height = _a.height;
|
|
102
|
-
return (_jsxs(_Fragment, { children: [shouldBeDraggable && (_jsx(SortableContext, __assign({ items: data, strategy: verticalListSortingStrategy }, { children: _jsx(
|
|
103
|
+
return (_jsxs(_Fragment, { children: [shouldBeDraggable && (_jsx(SortableContext, __assign({ items: data, strategy: verticalListSortingStrategy }, { children: _jsx(StyledGrid, __assign({ style: buildGridStyles(_rowWidth), width: width, columnCount: 1, itemData: itemData, onItemsRendered: onItemsRendered, onScroll: onScroll, columnWidth: Math.floor(width * _rowWidth), height: height - tableHeadersHeight, rowHeight: rowHeight, rowCount: data.length }, { children: DraggableCell })) }))), !shouldBeDraggable && (_jsx(StyledGrid, __assign({ style: buildGridStyles(_rowWidth), width: width, columnCount: 1, itemData: itemData, onItemsRendered: onItemsRendered, onScroll: onScroll, columnWidth: Math.floor(width * _rowWidth), height: height - tableHeadersHeight, rowHeight: rowHeight, rowCount: data.length }, { children: Cell })))] }));
|
|
103
104
|
} })] })));
|
|
104
105
|
}, areEqual);
|
|
105
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
106
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProps } from "../styled/utils";
|
|
2
|
-
declare const types: readonly ["primary", "secondary", "tertiary"];
|
|
2
|
+
declare const types: readonly ["primary", "secondary", "tertiary", "link"];
|
|
3
3
|
export type ButtonTypes = typeof types[number];
|
|
4
4
|
export type BtnProps = {
|
|
5
5
|
onClick?: () => void;
|