fuse-importer 0.23.7 → 0.23.8
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 +2 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +0 -1
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +2 -2
- package/lib/esm/Importer/PreviewModeBanner.js +1 -3
- package/lib/esm/Importer/Review/index.js +1 -0
- package/lib/esm/Importer/SpreadsheetReviewContextProvider.js +2 -2
- package/lib/esm/Importer/Stepper.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider.js +2 -0
- package/lib/esm/Importer/common/Spreadsheet/common/FieldHeader.js +1 -1
- package/lib/esm/Importer/common/Spreadsheet/common/fields/SpeadsheetAutocomplete.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/common/fields/SpeadsheetAutocomplete.js +2 -2
- package/lib/esm/Importer/common/Spreadsheet/common/fields/index.js +7 -2
- package/lib/esm/Importer/common/Spreadsheet/common/index.d.ts +5 -1
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +14 -4
- package/lib/esm/Importer/common/Spreadsheet/index.js +1 -1
- package/lib/esm/Importer/index.js +2 -2
- package/lib/esm/Importer/theme.d.ts +5 -4
- package/lib/esm/common/Table/TableView/index.js +1 -1
- package/lib/esm/common/Toast.d.ts +1 -1
- package/lib/esm/common/Toast.js +1 -1
- package/lib/esm/common/buttons.js +7 -3
- package/lib/esm/common/inputs/Autocomplete.d.ts +1 -1
- package/lib/esm/common/inputs/Autocomplete.js +9 -10
- package/lib/esm/common/inputs/TextInput.d.ts +6 -2
- package/lib/esm/common/inputs/TextInput.js +8 -4
- package/lib/esm/styled/theme/index.d.ts +13 -4
- package/lib/esm/styled/theme/index.js +2 -0
- package/lib/esm/styled/theme/textCss.d.ts +1 -0
- package/lib/esm/styled/theme/textCss.js +5 -4
- package/lib/esm/styled/themeType.d.ts +0 -2
- package/lib/esm/styled/themeType.js +1 -0
- package/lib/esm/types.d.ts +1 -0
- package/lib/main.js +1 -1
- package/package.json +7 -8
|
@@ -18,6 +18,7 @@ export declare type UploadedDataEnumFieldValues = {
|
|
|
18
18
|
export declare type TemplateHeader = {
|
|
19
19
|
label: string;
|
|
20
20
|
required: boolean;
|
|
21
|
+
unique: boolean;
|
|
21
22
|
column_type: string;
|
|
22
23
|
internal_key: string;
|
|
23
24
|
values: string[];
|
|
@@ -40,6 +41,7 @@ export declare type Column = {
|
|
|
40
41
|
label: string;
|
|
41
42
|
pattern: string;
|
|
42
43
|
required: boolean;
|
|
44
|
+
unique: boolean;
|
|
43
45
|
values: string[];
|
|
44
46
|
};
|
|
45
47
|
export declare type State = {
|
|
@@ -44,7 +44,6 @@ var HeaderMatcher = function () {
|
|
|
44
44
|
isMatched: !!templateHeaderMatchings[templateHeaderLabel],
|
|
45
45
|
}); })
|
|
46
46
|
.sort(function (a, b) { return (b.isMatched ? 1 : -1); }));
|
|
47
|
-
//sort data based on automatched items
|
|
48
47
|
var sortedData = dataSortingOrderRef.current.map(function (sorting) { return data[sorting.index]; });
|
|
49
48
|
var tableRowHeight = 100;
|
|
50
49
|
var tableHeight = getTableHeight({
|
|
@@ -27,7 +27,7 @@ export var tableColumns = [
|
|
|
27
27
|
newTemplateHeaderMatchings[ourColumns] = selected;
|
|
28
28
|
setTemplateHeaderMatchings(newTemplateHeaderMatchings);
|
|
29
29
|
};
|
|
30
|
-
return (_jsx(Autocomplete, { w: "92%", onChange: onChange, value: yourColumns, options: uploadedDataHeaders.map(function (h) { return ({
|
|
30
|
+
return (_jsx(Autocomplete, { w: "92%", onChange: onChange, value: yourColumns, id: "your-column-".concat(ourColumns), options: uploadedDataHeaders.map(function (h) { return ({
|
|
31
31
|
value: h,
|
|
32
32
|
label: h,
|
|
33
33
|
}); }) }));
|
|
@@ -41,7 +41,7 @@ export var tableColumns = [
|
|
|
41
41
|
var ourColumns = _a.ourColumns;
|
|
42
42
|
var templateHeaders = useImporterContext().templateHeaders;
|
|
43
43
|
var isRequired = (_b = templateHeaders.find(function (th) { return th.label === ourColumns; })) === null || _b === void 0 ? void 0 : _b.required;
|
|
44
|
-
return (_jsxs(Div, __assign({ body1: true }, { children: [ourColumns, isRequired ? "*" : ""] })));
|
|
44
|
+
return (_jsxs(Div, __assign({ body1: true, id: "our-column-".concat(ourColumns) }, { children: [ourColumns, isRequired ? "*" : ""] })));
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
{
|
|
@@ -12,9 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { theme } from "../styled/theme";
|
|
14
14
|
import { Div, Span } from "../styled/utils";
|
|
15
|
-
import { useImporterContext } from "./ImporterContextProvider";
|
|
16
15
|
export var PreviewModeBanner = function () {
|
|
17
|
-
|
|
18
|
-
return previewMode ? (_jsxs(Div, __assign({ bg: theme.colors.blue100, h: 80, alignCenter: true }, { children: [_jsx(Div, __assign({ ml: 33, mr: 8 }, { children: infoIcon })), _jsx(Span, __assign({ mr: 16 }, { children: "You’re currently in Preview mode." }))] }))) : null;
|
|
16
|
+
return (_jsxs(Div, __assign({ bg: theme.colors.blue100, h: 80, alignCenter: true }, { children: [_jsx(Div, __assign({ ml: 33, mr: 8 }, { children: infoIcon })), _jsx(Span, __assign({ mr: 16 }, { children: "You’re currently in Preview mode." }))] })));
|
|
19
17
|
};
|
|
20
18
|
var infoIcon = (_jsxs("svg", __assign({ width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("circle", { cx: "14", cy: "2.5", r: "2.5", fill: "#0EBEBE" }), _jsx("path", { d: "M15.5075 8H6L5 10.5L10 11L6.57474 18.9354C6.57474 18.9354 6.40657 20.1663 6.57474 20.9247C6.76276 21.7725 6.97074 22.2838 7.56727 22.9139C8.6672 24.0757 9.95115 24.1037 11.5374 23.9085C14.2577 23.5737 17 19.5 17 19.5L15.5075 17.9408C15.5075 17.9408 13.5223 19.93 12.5298 19.93C11.5373 19.93 11.5374 18.9354 11.5374 18.9354L15.5075 8Z", fill: "#0EBEBE" })] })));
|
|
@@ -70,6 +70,7 @@ var Review = function () {
|
|
|
70
70
|
name: templateHeader.internal_key,
|
|
71
71
|
type: FieldTypes[templateHeader.column_type] || FieldTypes.string,
|
|
72
72
|
isRequired: templateHeader.required,
|
|
73
|
+
isUnique: templateHeader.unique,
|
|
73
74
|
options: templateHeader.values,
|
|
74
75
|
pattern: templateHeader.pattern,
|
|
75
76
|
}); });
|
|
@@ -57,7 +57,7 @@ export var SpreadsheetReviewContextProvider = function (_a) {
|
|
|
57
57
|
var _c = useState(null), reviewedData = _c[0], setReviewedData = _c[1];
|
|
58
58
|
var _d = useState(null), submittedData = _d[0], setSubmittedData = _d[1];
|
|
59
59
|
var _e = useState(null), appResponse = _e[0], setAppResponse = _e[1];
|
|
60
|
-
var _f = useImporterContext(), templateSlug = _f.templateSlug, fuseApi = _f.fuseApi;
|
|
60
|
+
var _f = useImporterContext(), templateSlug = _f.templateSlug, fuseApi = _f.fuseApi, previewMode = _f.importerOptions.previewMode;
|
|
61
61
|
var getImportWasSuccessful = function (response) {
|
|
62
62
|
return !response.errors || !Object.keys(response.errors).length;
|
|
63
63
|
};
|
|
@@ -97,7 +97,7 @@ export var SpreadsheetReviewContextProvider = function (_a) {
|
|
|
97
97
|
applicationResponse = _a.sent();
|
|
98
98
|
setAppResponse(applicationResponse);
|
|
99
99
|
importWasSuccessful = getImportWasSuccessful(applicationResponse);
|
|
100
|
-
if (!importWasSuccessful) return [3 /*break*/, 3];
|
|
100
|
+
if (!(importWasSuccessful && !previewMode)) return [3 /*break*/, 3];
|
|
101
101
|
rowCount = reviewedData.length;
|
|
102
102
|
return [4 /*yield*/, trackImportedRowsCount(rowCount)];
|
|
103
103
|
case 2:
|
|
@@ -133,7 +133,7 @@ var Stepper = function (_a) {
|
|
|
133
133
|
var isReviewStep = currentStepIndex === 2;
|
|
134
134
|
var leftButtonUI = (_jsx(Div, __assign({ w: 100 }, { children: currentStepIndex > 0 && !appResponse && (_jsx(Button, __assign({ variant: "secondary", onClick: goBack }, { children: "Go back" }))) })));
|
|
135
135
|
var rightButtonUI = (_jsxs(Div, __assign({ w: 100 }, { children: [isMatchStep && (_jsx(Button, __assign({ variant: "primary", onClick: continueToNextStep }, { children: "Continue" }))), isReviewStep && (_jsx(Button, __assign({ variant: "primary", isDisabled: isSubmitDisabled, onClick: function () { return setIsSubmitModalOpen(true); } }, { children: "Submit" })))] })));
|
|
136
|
-
return (_jsxs(_Fragment, { children: [unmatchedHeadersModalUI, submitModalUI, _jsxs(StepperWrapper, __assign({ pRelative: true, alignCenter: true, w100: true, h: 96, centered: true }, { children: [logoURL && _jsx(Logo, { src: logoURL, alt: "" }), _jsxs(Content, __assign({ spaceBetween: true, w: contentWidth }, { children: [leftButtonUI, _jsx(Div, __assign({ alignCenter: true }, { children: stepsUI })), rightButtonUI] })), _jsx(CloseIcon, __assign({ centered: true, clickable: true, onClick: onClose }, { children: closeIconCondensed }))] }))] }));
|
|
136
|
+
return (_jsxs(_Fragment, { children: [unmatchedHeadersModalUI, submitModalUI, _jsxs(StepperWrapper, __assign({ pRelative: true, alignCenter: true, w100: true, h: 96, centered: true }, { children: [logoURL && _jsx(Logo, { src: logoURL, alt: "" }), _jsxs(Content, __assign({ spaceBetween: true, w: contentWidth }, { children: [leftButtonUI, _jsx(Div, __assign({ alignCenter: true }, { children: stepsUI })), rightButtonUI] })), _jsx(CloseIcon, __assign({ "data-test-id": "close-importer", centered: true, clickable: true, onClick: onClose }, { children: closeIconCondensed }))] }))] }));
|
|
137
137
|
};
|
|
138
138
|
var Content = styled(Div)(function (_a) {
|
|
139
139
|
var _b = _a.theme, colors = _b.colors, c = _b.css;
|
|
@@ -205,6 +205,7 @@ export var SpreadsheetContextProvider = function (_a) {
|
|
|
205
205
|
fields: fields,
|
|
206
206
|
batchValidationErrors: batchValidationErrors,
|
|
207
207
|
submittedData: submittedData,
|
|
208
|
+
data: data,
|
|
208
209
|
})[sortByFieldErrors];
|
|
209
210
|
};
|
|
210
211
|
var aHasErrors = recordHasErrors(a);
|
|
@@ -292,6 +293,7 @@ var useValidationState = function (_a) {
|
|
|
292
293
|
fields: fields,
|
|
293
294
|
batchValidationErrors: batchValidationErrors,
|
|
294
295
|
submittedData: submittedData,
|
|
296
|
+
data: data,
|
|
295
297
|
});
|
|
296
298
|
updateFieldErrorCount(recordErrors);
|
|
297
299
|
});
|
|
@@ -26,6 +26,6 @@ export var FieldHeader = function (_a) {
|
|
|
26
26
|
var field = _a.field, sortByFieldErrors = _a.sortByFieldErrors;
|
|
27
27
|
var columnErrorCounts = useSpreadsheetContext().columnErrorCounts;
|
|
28
28
|
var fieldErrorCount = columnErrorCounts[field.name];
|
|
29
|
-
return (_jsxs(Div, __assign({ p: "0 16px", spaceBetween: true, w100: true, alignCenter: true }, { children: [_jsxs(Div, __assign({ truncateText: true }, { children: [field.label, field.isRequired && "*"] })), fieldErrorCount && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ onClick: function () { return sortByFieldErrors(field.name); } }, { children: _jsx(Div, __assign({ centered: true }, { children: _jsx(Div, __assign({ w: 35, textAlignCenter: true, label3: true, truncateText: true }, { children: fieldErrorCount })) })) })) })))] })));
|
|
29
|
+
return (_jsxs(Div, __assign({ "data-test-id": "column-header-".concat(field.name), p: "0 16px", spaceBetween: true, w100: true, alignCenter: true }, { children: [_jsxs(Div, __assign({ truncateText: true }, { children: [field.label, field.isRequired && "*"] })), fieldErrorCount && (_jsx(TooltipProvider, __assign({ mr: 3, w: 35, tooltip: "Sort by ".concat(field.label, " errors") }, { children: _jsx(ErrorCount, __assign({ "data-test-id": "column-errors-count-".concat(field.name), onClick: function () { return sortByFieldErrors(field.name); } }, { children: _jsx(Div, __assign({ centered: true }, { children: _jsx(Div, __assign({ w: 35, textAlignCenter: true, label3: true, truncateText: true }, { children: fieldErrorCount })) })) })) })))] })));
|
|
30
30
|
};
|
|
31
31
|
var templateObject_1;
|
|
@@ -27,10 +27,10 @@ var Autocomplete = styled(AutocompleteBase)(templateObject_3 || (templateObject_
|
|
|
27
27
|
return p.hasError && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.error; });
|
|
28
28
|
}, TextInputIcon, SelectMenuDiv, SelectMenuScrollArea);
|
|
29
29
|
export var SpreadsheetAutocomplete = function (props) {
|
|
30
|
-
var name = props.name, record = props.record, options = props.options, fieldType = props.fieldType, _a = props.isInputDisabled, isInputDisabled = _a === void 0 ? false : _a;
|
|
30
|
+
var name = props.name, record = props.record, options = props.options, fieldType = props.fieldType, _a = props.isInputDisabled, isInputDisabled = _a === void 0 ? false : _a, id = props.id;
|
|
31
31
|
var _b = useSpreadsheetField(name, record, fieldType), value = _b.value, setValue = _b.setValue, validationError = _b.validationError;
|
|
32
32
|
var setIsScrollingEnabled = useSpreadsheetContext().setIsScrollingEnabled;
|
|
33
|
-
return (_jsx(SpreadsheetField, __assign({ validationError: validationError }, { children: _jsx(Autocomplete, { placement: "bottom", isInputDisabled: isInputDisabled, hasError: !!validationError, onToggle: function (isOpen) { return setIsScrollingEnabled(!isOpen); }, options: options, value: value, icon: chevronDownIcon, onChange: function (v) { return setValue(v); } }) })));
|
|
33
|
+
return (_jsx(SpreadsheetField, __assign({ validationError: validationError }, { children: _jsx(Autocomplete, { placement: "bottom", isInputDisabled: isInputDisabled, hasError: !!validationError, onToggle: function (isOpen) { return setIsScrollingEnabled(!isOpen); }, options: options, value: value, icon: chevronDownIcon, onChange: function (v) { return setValue(v); }, id: id }) })));
|
|
34
34
|
};
|
|
35
35
|
var chevronDownIcon = (_jsx("svg", __assign({ width: "10", height: "6", viewBox: "0 0 10 6", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M8.46289 1L4.98131 4.48159L1.49972 1", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
|
|
36
36
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -62,22 +62,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
62
62
|
import { useState, useCallback } from "react";
|
|
63
63
|
import { debounce } from "lodash";
|
|
64
64
|
import styled, { css } from "styled-components";
|
|
65
|
-
import { getRecordErrors, getRenderedRecordWithErrors, isFloat, isInteger, } from "..";
|
|
65
|
+
import { getRecordErrors, getRenderedRecordWithErrors, isFloat, isInteger, isTrue, isEmpty, } from "..";
|
|
66
66
|
import { TooltipProvider } from "../../../../../common/TooltipProvider";
|
|
67
67
|
import { Div } from "../../../../../styled/utils";
|
|
68
68
|
import { FieldTypes } from "../../../../../types";
|
|
69
69
|
import { useSpreadsheetReviewContext } from "../../../../SpreadsheetReviewContextProvider";
|
|
70
70
|
import { useSpreadsheetContext } from "../../SpreadsheetContextProvider";
|
|
71
71
|
export var parseValue = function (fieldType, value) {
|
|
72
|
+
if (isEmpty(value))
|
|
73
|
+
return value;
|
|
72
74
|
if (fieldType === FieldTypes.float)
|
|
73
75
|
return isFloat(value) ? parseFloat(value) : value;
|
|
74
76
|
if (fieldType === FieldTypes.integer)
|
|
75
77
|
return isInteger(value) ? parseInt(value) : value;
|
|
78
|
+
if (fieldType === FieldTypes.boolean)
|
|
79
|
+
return isTrue(value) ? true : false;
|
|
76
80
|
return value;
|
|
77
81
|
};
|
|
78
82
|
export var useValidationError = function (fieldName, record) {
|
|
79
83
|
var isSubmitting = useSpreadsheetReviewContext().isSubmitting;
|
|
80
|
-
var _a = useSpreadsheetContext(), fields = _a.fields, submittedData = _a.submittedData, batchValidationErrors = _a.batchValidationErrors;
|
|
84
|
+
var _a = useSpreadsheetContext(), fields = _a.fields, submittedData = _a.submittedData, batchValidationErrors = _a.batchValidationErrors, data = _a.data;
|
|
81
85
|
var validationError = null;
|
|
82
86
|
if (!isSubmitting) {
|
|
83
87
|
var recordErrors = getRecordErrors({
|
|
@@ -85,6 +89,7 @@ export var useValidationError = function (fieldName, record) {
|
|
|
85
89
|
fields: fields,
|
|
86
90
|
submittedData: submittedData,
|
|
87
91
|
batchValidationErrors: batchValidationErrors,
|
|
92
|
+
data: data,
|
|
88
93
|
});
|
|
89
94
|
validationError = recordErrors[fieldName];
|
|
90
95
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Field, Record, BatchValidationErrors } from "../../../../types";
|
|
2
2
|
export declare const spreadsheetRowHeightPx = 40;
|
|
3
3
|
export declare const spreadsheetHeaderHeightPx = 40;
|
|
4
|
+
export declare const isEmpty: (value: any) => boolean;
|
|
5
|
+
export declare const isEmail: (value: any) => boolean;
|
|
6
|
+
export declare const isUrl: (value: any) => boolean;
|
|
4
7
|
export declare const isTrue: (value: string) => boolean;
|
|
5
8
|
export declare const isInteger: (value: string) => boolean;
|
|
6
9
|
export declare const isFloat: (value: string) => boolean;
|
|
@@ -14,6 +17,7 @@ declare type GetRecordErrorsArgs = {
|
|
|
14
17
|
fields: Field[];
|
|
15
18
|
batchValidationErrors: BatchValidationErrors;
|
|
16
19
|
submittedData: Record[];
|
|
20
|
+
data: Record[];
|
|
17
21
|
};
|
|
18
|
-
export declare const getRecordErrors: ({ record, fields, batchValidationErrors, submittedData, }: GetRecordErrorsArgs) => {};
|
|
22
|
+
export declare const getRecordErrors: ({ record, fields, batchValidationErrors, submittedData, data, }: GetRecordErrorsArgs) => {};
|
|
19
23
|
export {};
|
|
@@ -14,17 +14,17 @@ import { FieldTypes, } from "../../../../types";
|
|
|
14
14
|
import { DateTime } from "luxon";
|
|
15
15
|
export var spreadsheetRowHeightPx = 40;
|
|
16
16
|
export var spreadsheetHeaderHeightPx = 40;
|
|
17
|
-
var isEmpty = function (value) {
|
|
17
|
+
export var isEmpty = function (value) {
|
|
18
18
|
return (value === undefined ||
|
|
19
19
|
value === null ||
|
|
20
20
|
(typeof value === "object" && Object.keys(value).length === 0) ||
|
|
21
21
|
(typeof value === "string" && value.trim().length === 0));
|
|
22
22
|
};
|
|
23
|
-
var isEmail = function (value) {
|
|
23
|
+
export var isEmail = function (value) {
|
|
24
24
|
var emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
25
25
|
return emailRegex.test(value);
|
|
26
26
|
};
|
|
27
|
-
var isUrl = function (value) {
|
|
27
|
+
export var isUrl = function (value) {
|
|
28
28
|
var urlRegex = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/g;
|
|
29
29
|
return urlRegex.test(value);
|
|
30
30
|
};
|
|
@@ -49,6 +49,10 @@ var validateDatePattern = function (field, fieldValue) {
|
|
|
49
49
|
return "".concat(field.label, " must match the pattern ").concat(field.pattern);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
var validateUnique = function (fieldValue, key, records) {
|
|
53
|
+
var existingRecords = records.filter(function (r) { return r[key] === fieldValue; });
|
|
54
|
+
return existingRecords.length < 2;
|
|
55
|
+
};
|
|
52
56
|
var validations = (_a = {},
|
|
53
57
|
_a[FieldTypes.email] = function (field, fieldValue) {
|
|
54
58
|
if (!isEmail(fieldValue)) {
|
|
@@ -84,7 +88,7 @@ var ignoreNullOrUndefinedKeyValues = function (obj) {
|
|
|
84
88
|
return result;
|
|
85
89
|
};
|
|
86
90
|
export var getRecordErrors = function (_a) {
|
|
87
|
-
var record = _a.record, fields = _a.fields, batchValidationErrors = _a.batchValidationErrors, submittedData = _a.submittedData;
|
|
91
|
+
var record = _a.record, fields = _a.fields, batchValidationErrors = _a.batchValidationErrors, submittedData = _a.submittedData, data = _a.data;
|
|
88
92
|
var submittedRecord = submittedData === null || submittedData === void 0 ? void 0 : submittedData.find(function (r) { return r._meta.id === record._meta.id; });
|
|
89
93
|
var recordHasData = !recordIsEmpty(record, fields);
|
|
90
94
|
if (recordHasData) {
|
|
@@ -96,6 +100,12 @@ export var getRecordErrors = function (_a) {
|
|
|
96
100
|
}
|
|
97
101
|
else if (!isEmpty(fieldValue) && validations[field.type]) {
|
|
98
102
|
newErrors[field.name] = validations[field.type](field, fieldValue);
|
|
103
|
+
if (field.isUnique && !newErrors[field.name]) {
|
|
104
|
+
var isFieldUnique = validateUnique(fieldValue, field.name, data);
|
|
105
|
+
if (!isFieldUnique) {
|
|
106
|
+
newErrors[field.name] = "".concat(field.label, " must be unique");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
99
109
|
}
|
|
100
110
|
return newErrors;
|
|
101
111
|
}, {});
|
|
@@ -91,7 +91,7 @@ var SpreadsheetData = function () {
|
|
|
91
91
|
Content: function (record) {
|
|
92
92
|
var Input = inputTypes[field.type];
|
|
93
93
|
var rowIndex = record.rowIndex, recordProp = __rest(record, ["rowIndex"]);
|
|
94
|
-
return (_jsx(Input, { fieldType: field.type, name: field.name, options: field.options, record: recordProp }));
|
|
94
|
+
return (_jsx(Input, { id: "".concat(field.name, "-").concat(rowIndex), fieldType: field.type, name: field.name, options: field.options, record: recordProp }));
|
|
95
95
|
},
|
|
96
96
|
}); });
|
|
97
97
|
}, [fields]);
|
|
@@ -64,12 +64,12 @@ var Importer = function (_a) {
|
|
|
64
64
|
};
|
|
65
65
|
var ImporterWithContext = function (_a) {
|
|
66
66
|
var onSubmit = _a.onSubmit;
|
|
67
|
-
var _b = useImporterContext(), inTrialMode = _b.inTrialMode, currentStepIndex = _b.currentStepIndex, matcherSubstep = _b.matcherSubstep, theme = _b.theme, logoURL = _b.logoURL, _c = _b.importerOptions, zIndex = _c.zIndex, loadingComponent = _c.loadingComponent;
|
|
67
|
+
var _b = useImporterContext(), inTrialMode = _b.inTrialMode, currentStepIndex = _b.currentStepIndex, matcherSubstep = _b.matcherSubstep, theme = _b.theme, logoURL = _b.logoURL, _c = _b.importerOptions, zIndex = _c.zIndex, loadingComponent = _c.loadingComponent, previewMode = _c.previewMode;
|
|
68
68
|
var layoutRef = useRef(null);
|
|
69
69
|
useEffect(function () {
|
|
70
70
|
layoutRef.current.scrollTo(0, 0);
|
|
71
71
|
}, [currentStepIndex, matcherSubstep]);
|
|
72
|
-
return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(Toast, {}), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), _jsx(SpreadsheetReviewContextProvider, __assign({ loadingComponent: loadingComponent, onSubmit: onSubmit }, { children: _jsxs(Layout, __assign({ zIndex: zIndex, ref: layoutRef }, { children: [_jsxs(Div, { children: [_jsx(PreviewModeBanner, {}), _jsx(TrialModeBanner, {}), _jsx(Stepper, { stepLabels: steps.map(function (step) { return step.label; }), logoURL: logoURL })] }), _jsx(Content, { children: steps[currentStepIndex].component }), inTrialMode && (_jsx(Content, { children: _jsx(Footer, {}) }))] })) }))] })));
|
|
72
|
+
return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(Toast, {}), _jsx(GlobalStyle, {}), _jsx(ImporterFonts, {}), _jsx(SpreadsheetReviewContextProvider, __assign({ loadingComponent: loadingComponent, onSubmit: onSubmit }, { children: _jsxs(Layout, __assign({ zIndex: zIndex, ref: layoutRef }, { children: [_jsxs(Div, { children: [previewMode && _jsx(PreviewModeBanner, {}), !previewMode && _jsx(TrialModeBanner, {}), _jsx(Stepper, { stepLabels: steps.map(function (step) { return step.label; }), logoURL: logoURL })] }), _jsx(Content, { children: steps[currentStepIndex].component }), inTrialMode && (_jsx(Content, { children: _jsx(Footer, {}) }))] })) }))] })));
|
|
73
73
|
};
|
|
74
74
|
export * from "./common/Spreadsheet";
|
|
75
75
|
export * from "./common/utils";
|
|
@@ -11,7 +11,7 @@ export declare type ImporterStylePreferences = {
|
|
|
11
11
|
export declare type Theme = typeof theme;
|
|
12
12
|
declare const getCustomTheme: (importerStylePreferences: ImporterStylePreferences) => {
|
|
13
13
|
theme: {
|
|
14
|
-
colors: {
|
|
14
|
+
readonly colors: {
|
|
15
15
|
backgroundInterface: string;
|
|
16
16
|
interactiveDisabled: string;
|
|
17
17
|
error: string;
|
|
@@ -93,7 +93,7 @@ declare const getCustomTheme: (importerStylePreferences: ImporterStylePreference
|
|
|
93
93
|
orange900: string;
|
|
94
94
|
orange1000: string;
|
|
95
95
|
};
|
|
96
|
-
textStyles: {
|
|
96
|
+
readonly textStyles: {
|
|
97
97
|
h1: import("styled-components").FlattenSimpleInterpolation;
|
|
98
98
|
h2: import("styled-components").FlattenSimpleInterpolation;
|
|
99
99
|
h3: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -113,7 +113,7 @@ declare const getCustomTheme: (importerStylePreferences: ImporterStylePreference
|
|
|
113
113
|
buttonTextSmall: import("styled-components").FlattenSimpleInterpolation;
|
|
114
114
|
link: import("styled-components").FlattenSimpleInterpolation;
|
|
115
115
|
};
|
|
116
|
-
css: {
|
|
116
|
+
readonly css: {
|
|
117
117
|
pt: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
118
118
|
pb: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
119
119
|
pl: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
@@ -181,6 +181,7 @@ declare const getCustomTheme: (importerStylePreferences: ImporterStylePreference
|
|
|
181
181
|
underline: import("styled-components").FlattenSimpleInterpolation;
|
|
182
182
|
textAlignCenter: import("styled-components").FlattenSimpleInterpolation;
|
|
183
183
|
textAlignRight: import("styled-components").FlattenSimpleInterpolation;
|
|
184
|
+
textAlignLeft: import("styled-components").FlattenSimpleInterpolation;
|
|
184
185
|
uppercase: import("styled-components").FlattenSimpleInterpolation;
|
|
185
186
|
capitalize: import("styled-components").FlattenSimpleInterpolation;
|
|
186
187
|
lowercase: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -215,7 +216,7 @@ declare const getCustomTheme: (importerStylePreferences: ImporterStylePreference
|
|
|
215
216
|
br: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
216
217
|
fadeIn: import("styled-components").FlattenSimpleInterpolation;
|
|
217
218
|
};
|
|
218
|
-
media: {
|
|
219
|
+
readonly media: {
|
|
219
220
|
desktop: string;
|
|
220
221
|
mobile: string;
|
|
221
222
|
};
|
|
@@ -101,7 +101,7 @@ export var TableView = React.memo(function (_a) {
|
|
|
101
101
|
highlightFirstRow: highlightFirstRow,
|
|
102
102
|
rowHeight: rowHeight,
|
|
103
103
|
}); }, [data, onRowClick, columns, highlightFirstRow, rowHeight]);
|
|
104
|
-
return (_jsxs(TableViewWrapper, __assign({}, { isLoading: isLoading }, { h: tableHeight }, props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
104
|
+
return (_jsxs(TableViewWrapper, __assign({ "data-test-id": "table-view-wrapper" }, { isLoading: isLoading }, { h: tableHeight }, props, { children: [tableHeadersUI, loadingUI, _jsx(AutoSizer, { children: function (_a) {
|
|
105
105
|
var width = _a.width, height = _a.height;
|
|
106
106
|
return (_jsx(Grid, __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 })));
|
|
107
107
|
} })] })));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ToastOptions, ToastType } from "react-hot-toast
|
|
2
|
+
import { ToastOptions, ToastType } from "react-hot-toast";
|
|
3
3
|
export declare const addToast: (msg: JSX.Element | string, type?: ToastType, toastOptions?: ToastOptions) => void;
|
|
4
4
|
declare const Toast: () => JSX.Element;
|
|
5
5
|
export { Toast };
|
package/lib/esm/common/Toast.js
CHANGED
|
@@ -14,7 +14,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
return __assign.apply(this, arguments);
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
import toast, { ToastBar, Toaster } from "react-hot-toast";
|
|
17
|
+
import toast, { ToastBar, Toaster, } from "react-hot-toast";
|
|
18
18
|
import styled from "styled-components";
|
|
19
19
|
import { defaultCheckIcon, greenCheckIcon, redXIcon } from "./icons";
|
|
20
20
|
import { colors } from "../styled/theme/colorPalette";
|
|
@@ -30,7 +30,9 @@ import { Div, HTMLButton } from "../styled/utils";
|
|
|
30
30
|
var types = ["primary", "secondary", "tertiary"];
|
|
31
31
|
var styles = {
|
|
32
32
|
primary: css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n background: ", ";\n\n border: solid 4px ", ";\n box-sizing: border-box;\n\n :hover {\n background: ", ";\n /* a3 at the end adds 0.64 opacity */\n box-shadow: 0px 0px 8px ", "a3;\n }\n :active {\n background: ", ";\n border: 4px solid ", ";\n }\n :focus {\n background: ", ";\n /* a3 at the end adds 0.64 opacity */\n box-shadow: 0px 0px 8px ", "a3;\n }\n ", "\n "], ["\n color: ", ";\n background: ", ";\n\n border: solid 4px ", ";\n box-sizing: border-box;\n\n :hover {\n background: ", ";\n /* a3 at the end adds 0.64 opacity */\n box-shadow: 0px 0px 8px ", "a3;\n }\n :active {\n background: ", ";\n border: 4px solid ", ";\n }\n :focus {\n background: ", ";\n /* a3 at the end adds 0.64 opacity */\n box-shadow: 0px 0px 8px ", "a3;\n }\n ", "\n "])), function (props) { return props.theme.colors.white; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink700; }, function (props) { return props.theme.colors.pink500; }, function (props) { return props.theme.colors.pink500; }, function (props) {
|
|
33
|
-
return props.isDisabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n box-shadow:
|
|
33
|
+
return props.isDisabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", " !important;\n box-shadow: none !important;\n border: none !important;\n cursor: not-allowed !important;\n "], ["\n background: ", " !important;\n box-shadow: none !important;\n border: none !important;\n cursor: not-allowed !important;\n "])), function (props) {
|
|
34
|
+
return props.theme.colors.interactiveDisabled;
|
|
35
|
+
});
|
|
34
36
|
}),
|
|
35
37
|
secondary: css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: ", ";\n box-sizing: border-box;\n border: solid 1px ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n :active {\n border: 2px solid ", ";\n background: ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n }\n :focus {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.24);\n }\n ", "\n "], ["\n background: ", ";\n box-sizing: border-box;\n border: solid 1px ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n :active {\n border: 2px solid ", ";\n background: ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n }\n :focus {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.24);\n }\n ", "\n "])), function (props) { return props.theme.colors.white; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.white; }, function (props) { return props.theme.colors.white; }, function (props) {
|
|
36
38
|
return props.isDisabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n border: 2px solid ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n "], ["\n border: 2px solid ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n }\n }\n "])), function (props) { return props.theme.colors.gray390; }, function (props) { return props.theme.colors.gray390; }, function (props) { return props.theme.colors.gray390; });
|
|
@@ -51,10 +53,12 @@ export var ButtonWrapper = styled(Div)(templateObject_10 || (templateObject_10 =
|
|
|
51
53
|
export var ButtonElementWrapper = styled(HTMLButton)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), commonButtonStyle);
|
|
52
54
|
export var Button = function (_a) {
|
|
53
55
|
var _b = _a.onClick, onClick = _b === void 0 ? null : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.variant, variant = _d === void 0 ? "primary" : _d, _e = _a.isSmall, isSmall = _e === void 0 ? false : _e, children = _a.children, _f = _a.isButtonElement, isButtonElement = _f === void 0 ? false : _f, props = __rest(_a, ["onClick", "isDisabled", "variant", "isSmall", "children", "isButtonElement"]);
|
|
54
|
-
return (_jsx(_Fragment, { children: isButtonElement ? (_jsx(ButtonElementWrapper, __assign({ w100: true, isSmall: isSmall, isDisabled: isDisabled, disabled: isDisabled, variant: variant, type: "submit" }, props, { children: children }))) : (_jsx(ButtonWrapper, __assign({ w100: true, isSmall: isSmall, onKeyDown: function (_a) {
|
|
56
|
+
return (_jsx(_Fragment, { children: isButtonElement ? (_jsx(ButtonElementWrapper, __assign({ w100: true, isSmall: isSmall, isDisabled: isDisabled, disabled: isDisabled, variant: variant, type: "submit" }, props, { children: children }))) : (_jsx(ButtonWrapper, __assign({ w100: true, isSmall: isSmall, onClick: isDisabled ? null : onClick, onKeyDown: function (_a) {
|
|
55
57
|
var code = _a.code;
|
|
56
|
-
if (code === "Space" || (code === "Enter" && onClick))
|
|
58
|
+
if ((code === "Space" || (code === "Enter" && onClick)) &&
|
|
59
|
+
!isDisabled) {
|
|
57
60
|
onClick();
|
|
61
|
+
}
|
|
58
62
|
}, tabIndex: 0 }, __assign({ variant: variant, isDisabled: isDisabled, onClick: onClick, disabled: isDisabled }, props), { children: _jsx(_Fragment, { children: children }) }))) }));
|
|
59
63
|
};
|
|
60
64
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
|
|
@@ -16,5 +16,5 @@ export declare type Props = {
|
|
|
16
16
|
placement?: Placement;
|
|
17
17
|
icon?: JSX.Element;
|
|
18
18
|
} & DivCSSProps;
|
|
19
|
-
declare const Autocomplete: ({ label, isInputDisabled, placeholder, value, icon, onChange, placement, options, onToggle, ...props }: Props) => JSX.Element;
|
|
19
|
+
declare const Autocomplete: ({ label, isInputDisabled, placeholder, value, icon, onChange, placement, options, onToggle, id, ...props }: Props) => JSX.Element;
|
|
20
20
|
export { Autocomplete };
|
|
@@ -46,12 +46,11 @@ var ClickableArea = styled(Div)(function (_a) {
|
|
|
46
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
47
|
});
|
|
48
48
|
var Autocomplete = function (_a) {
|
|
49
|
-
var _b;
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var _g = useState(
|
|
54
|
-
var _h = useState(false), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
|
|
49
|
+
var _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isInputDisabled, isInputDisabled = _c === void 0 ? false : _c, _d = _a.placeholder, placeholder = _d === void 0 ? "Select option..." : _d, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, id = _a.id, props = __rest(_a, ["label", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle", "id"]);
|
|
50
|
+
var _e = useState(false), updatedText = _e[0], setUpdatedText = _e[1];
|
|
51
|
+
var selectedLabel = useMemo(function () { var _a; return ((_a = options.find(function (o) { return o.value === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
|
|
52
|
+
var _f = useState(selectedLabel), text = _f[0], setText = _f[1];
|
|
53
|
+
var _g = useState(false), isMenuOpen = _g[0], setIsMenuOpen = _g[1];
|
|
55
54
|
useEffect(function () {
|
|
56
55
|
if (value)
|
|
57
56
|
setText(selectedLabel);
|
|
@@ -78,18 +77,18 @@ var Autocomplete = function (_a) {
|
|
|
78
77
|
return o.label.toLowerCase().includes(text.toLowerCase());
|
|
79
78
|
})
|
|
80
79
|
: options;
|
|
81
|
-
}, [updatedText, options]);
|
|
82
|
-
var inputIconUI = text ? (_jsx(ClearIcon, __assign({ clickable: true, dim: 24, centered: true, onClick: function (evt) {
|
|
80
|
+
}, [updatedText, text, options]);
|
|
81
|
+
var inputIconUI = text ? (_jsx(ClearIcon, __assign({ clickable: true, dim: 24, centered: true, id: id ? "".concat(id, "-clear") : null, onClick: function (evt) {
|
|
83
82
|
evt.preventDefault();
|
|
84
83
|
evt.stopPropagation();
|
|
85
84
|
onChange(undefined);
|
|
86
85
|
} }, { children: clearIcon }))) : (_jsx(Div, __assign({ centered: true, dim: 24 }, { children: icon || chevronDownIcon })));
|
|
87
|
-
return (_jsxs(Div, __assign({ w100: true }, props, { children: [_jsx(ClickableArea, __assign({ isInputDisabled: isInputDisabled, onClick: function () { return setIsMenuOpen(true); } }, { children: _jsx(TextInput, { onBlur: function () {
|
|
86
|
+
return (_jsxs(Div, __assign({ w100: true }, props, { children: [_jsx(ClickableArea, __assign({ isInputDisabled: isInputDisabled, onClick: function () { return setIsMenuOpen(true); } }, { children: _jsx(TextInput, { id: id, onBlur: function () {
|
|
88
87
|
if (filteredOptions.length === 0) {
|
|
89
88
|
setText(selectedLabel);
|
|
90
89
|
setIsMenuOpen(false);
|
|
91
90
|
}
|
|
92
|
-
}, label: label, isDisabled: isInputDisabled, placeholder: placeholder, value: text, onChange: function (v) { return setText(v); }, icon: inputIconUI }) })), 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 })) }, index)); }) })))] })));
|
|
91
|
+
}, label: label, isDisabled: isInputDisabled, placeholder: placeholder, value: text, onChange: function (v) { return setText(v); }, icon: inputIconUI }) })), 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({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === o.value, onClick: function () { return onSelect(o.value); } }, { children: o.label })) }, index)); }) })))] })));
|
|
93
92
|
};
|
|
94
93
|
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" }) })));
|
|
95
94
|
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" })] })));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DivCSSProps } from "../../styled/utils";
|
|
3
|
-
export declare const HTMLInput: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {
|
|
3
|
+
export declare const HTMLInput: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {
|
|
4
|
+
padding?: string;
|
|
5
|
+
}, never>;
|
|
4
6
|
export declare const TextInputIcon: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../styled/utils").CSSProps, never>;
|
|
5
7
|
declare type Props = {
|
|
6
8
|
label?: string;
|
|
@@ -16,6 +18,8 @@ declare type Props = {
|
|
|
16
18
|
withDebounce?: boolean;
|
|
17
19
|
autoFocus?: boolean;
|
|
18
20
|
id?: string;
|
|
21
|
+
padding?: string;
|
|
22
|
+
labelTooltip?: JSX.Element | null;
|
|
19
23
|
} & DivCSSProps;
|
|
20
|
-
declare const TextInput: ({ label, icon, placeholder, value, type, onChange, onBlur, isDisabled, hasError, onFocus, withDebounce, autoFocus, id, ...props }: Props) => JSX.Element;
|
|
24
|
+
declare const TextInput: ({ label, icon, labelTooltip, placeholder, value, type, onChange, onBlur, isDisabled, hasError, onFocus, withDebounce, autoFocus, id, padding, ...props }: Props) => JSX.Element;
|
|
21
25
|
export { TextInput };
|
|
@@ -30,19 +30,22 @@ import styled, { css } from "styled-components";
|
|
|
30
30
|
import { FormInputLabel } from "..";
|
|
31
31
|
import { useDebounce } from "../../hooks";
|
|
32
32
|
import { Div } from "../../styled/utils";
|
|
33
|
-
export var HTMLInput = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n padding:
|
|
33
|
+
export var HTMLInput = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n padding: ", ";\n height: 68px;\n outline: none;\n\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: 8px;\n width: 100%;\n\n ::-webkit-outer-spin-button,\n ::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n /* Firefox */\n -moz-appearance: textfield;\n\n ", ";\n\n ::placeholder {\n color: ", ";\n }\n\n :focus {\n border: 2px solid ", ";\n\n /* 3d at the end adds .24 opacity (using 8 digit hex)*/\n box-shadow: 0px 0px 8px ", "3d;\n }\n\n ", "\n ", "\n"], ["\n position: relative;\n padding: ", ";\n height: 68px;\n outline: none;\n\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: 8px;\n width: 100%;\n\n ::-webkit-outer-spin-button,\n ::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n /* Firefox */\n -moz-appearance: textfield;\n\n ", ";\n\n ::placeholder {\n color: ", ";\n }\n\n :focus {\n border: 2px solid ", ";\n\n /* 3d at the end adds .24 opacity (using 8 digit hex)*/\n box-shadow: 0px 0px 8px ", "3d;\n }\n\n ", "\n ", "\n"])), function (_a) {
|
|
34
|
+
var padding = _a.padding;
|
|
35
|
+
return (padding ? padding : "20px 16px");
|
|
36
|
+
}, function (props) { return props.theme.colors.gray300; }, function (props) { return props.theme.css.body1; }, function (props) { return props.theme.colors.placeholder; }, function (props) { return props.theme.colors.blue500; }, function (props) { return props.theme.colors.blue500; }, function (props) {
|
|
34
37
|
return props.isDisabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n cursor: not-allowed;\n opacity: 0.7;\n pointer-events: none;\n "], ["\n cursor: not-allowed;\n opacity: 0.7;\n pointer-events: none;\n "])));
|
|
35
38
|
}, function (props) {
|
|
36
39
|
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
40
|
});
|
|
38
41
|
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
42
|
var TextInput = function (_a) {
|
|
40
|
-
var label = _a.label, _b = _a.icon, icon = _b === void 0 ? null : _b, _c = _a.placeholder, placeholder =
|
|
41
|
-
var
|
|
43
|
+
var label = _a.label, _b = _a.icon, icon = _b === void 0 ? null : _b, _c = _a.labelTooltip, labelTooltip = _c === void 0 ? null : _c, _d = _a.placeholder, placeholder = _d === void 0 ? "" : _d, value = _a.value, _e = _a.type, type = _e === void 0 ? "text" : _e, onChange = _a.onChange, _f = _a.onBlur, onBlur = _f === void 0 ? null : _f, _g = _a.isDisabled, isDisabled = _g === void 0 ? false : _g, _h = _a.hasError, hasError = _h === void 0 ? false : _h, _j = _a.onFocus, onFocus = _j === void 0 ? null : _j, _k = _a.withDebounce, withDebounce = _k === void 0 ? true : _k, _l = _a.autoFocus, autoFocus = _l === void 0 ? false : _l, id = _a.id, padding = _a.padding, props = __rest(_a, ["label", "icon", "labelTooltip", "placeholder", "value", "type", "onChange", "onBlur", "isDisabled", "hasError", "onFocus", "withDebounce", "autoFocus", "id", "padding"]);
|
|
44
|
+
var _m = useDebounce(value, onChange, withDebounce ? 0 : 300), _value = _m._value, set_Value = _m.set_Value;
|
|
42
45
|
var res = usePasswordVisibleIcon(type);
|
|
43
46
|
var passwordVisibleIcon = res.passwordVisibleIcon, isPasswordVisible = res.isPasswordVisible;
|
|
44
47
|
var _icon = passwordVisibleIcon || icon;
|
|
45
|
-
return (_jsxs(Div, __assign({ w100: true }, props, { children: [label && (_jsx(FormInputLabel, __assign({ isDisabled: isDisabled, mb: 8, htmlFor: id }, { children: label }))), _jsxs(Div, __assign({ pRelative: true }, { children: [_jsx(HTMLInput, __assign({}, {
|
|
48
|
+
return (_jsxs(Div, __assign({ w100: true }, props, { children: [label && (_jsx(FormInputLabel, __assign({ isDisabled: isDisabled, mb: 8, htmlFor: id }, { children: _jsxs(Div, __assign({ dflex: true }, { children: [_jsx(Div, __assign({ centered: true }, { children: label })), _jsx(Div, __assign({ ml: 4 }, { children: labelTooltip }))] })) }))), _jsxs(Div, __assign({ pRelative: true }, { children: [_jsx(HTMLInput, __assign({}, {
|
|
46
49
|
placeholder: placeholder,
|
|
47
50
|
isDisabled: isDisabled,
|
|
48
51
|
onFocus: onFocus,
|
|
@@ -50,6 +53,7 @@ var TextInput = function (_a) {
|
|
|
50
53
|
autoFocus: autoFocus,
|
|
51
54
|
disabled: isDisabled,
|
|
52
55
|
id: id,
|
|
56
|
+
padding: padding,
|
|
53
57
|
}, { type: isPasswordVisible ? "text" : type, value: _value || "", onChange: function (_a) {
|
|
54
58
|
var value = _a.target.value;
|
|
55
59
|
return set_Value(value);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "styled-components";
|
|
1
2
|
import { colors } from "./colorPalette";
|
|
2
3
|
export declare const getCssValue: (v: any) => string;
|
|
3
4
|
export { colors };
|
|
@@ -69,6 +70,7 @@ export declare const appCss: {
|
|
|
69
70
|
underline: import("styled-components").FlattenSimpleInterpolation;
|
|
70
71
|
textAlignCenter: import("styled-components").FlattenSimpleInterpolation;
|
|
71
72
|
textAlignRight: import("styled-components").FlattenSimpleInterpolation;
|
|
73
|
+
textAlignLeft: import("styled-components").FlattenSimpleInterpolation;
|
|
72
74
|
uppercase: import("styled-components").FlattenSimpleInterpolation;
|
|
73
75
|
capitalize: import("styled-components").FlattenSimpleInterpolation;
|
|
74
76
|
lowercase: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -104,7 +106,7 @@ export declare const appCss: {
|
|
|
104
106
|
fadeIn: import("styled-components").FlattenSimpleInterpolation;
|
|
105
107
|
};
|
|
106
108
|
export declare const theme: {
|
|
107
|
-
colors: {
|
|
109
|
+
readonly colors: {
|
|
108
110
|
backgroundInterface: string;
|
|
109
111
|
interactiveDisabled: string;
|
|
110
112
|
error: string;
|
|
@@ -186,7 +188,7 @@ export declare const theme: {
|
|
|
186
188
|
orange900: string;
|
|
187
189
|
orange1000: string;
|
|
188
190
|
};
|
|
189
|
-
textStyles: {
|
|
191
|
+
readonly textStyles: {
|
|
190
192
|
h1: import("styled-components").FlattenSimpleInterpolation;
|
|
191
193
|
h2: import("styled-components").FlattenSimpleInterpolation;
|
|
192
194
|
h3: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -206,7 +208,7 @@ export declare const theme: {
|
|
|
206
208
|
buttonTextSmall: import("styled-components").FlattenSimpleInterpolation;
|
|
207
209
|
link: import("styled-components").FlattenSimpleInterpolation;
|
|
208
210
|
};
|
|
209
|
-
css: {
|
|
211
|
+
readonly css: {
|
|
210
212
|
pt: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
211
213
|
pb: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
212
214
|
pl: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
@@ -274,6 +276,7 @@ export declare const theme: {
|
|
|
274
276
|
underline: import("styled-components").FlattenSimpleInterpolation;
|
|
275
277
|
textAlignCenter: import("styled-components").FlattenSimpleInterpolation;
|
|
276
278
|
textAlignRight: import("styled-components").FlattenSimpleInterpolation;
|
|
279
|
+
textAlignLeft: import("styled-components").FlattenSimpleInterpolation;
|
|
277
280
|
uppercase: import("styled-components").FlattenSimpleInterpolation;
|
|
278
281
|
capitalize: import("styled-components").FlattenSimpleInterpolation;
|
|
279
282
|
lowercase: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -308,8 +311,14 @@ export declare const theme: {
|
|
|
308
311
|
br: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
|
|
309
312
|
fadeIn: import("styled-components").FlattenSimpleInterpolation;
|
|
310
313
|
};
|
|
311
|
-
media: {
|
|
314
|
+
readonly media: {
|
|
312
315
|
desktop: string;
|
|
313
316
|
mobile: string;
|
|
314
317
|
};
|
|
315
318
|
};
|
|
319
|
+
export declare type Theme = typeof theme;
|
|
320
|
+
declare module "styled-components" {
|
|
321
|
+
interface DefaultTheme extends Theme {
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export default theme;
|
|
@@ -9,6 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
import "styled-components";
|
|
12
13
|
import { colors } from "./colorPalette";
|
|
13
14
|
import { debugCss } from "./debugCss";
|
|
14
15
|
import { fontCss } from "./fontCss";
|
|
@@ -29,3 +30,4 @@ export var theme = {
|
|
|
29
30
|
css: appCss,
|
|
30
31
|
media: mediaQueries,
|
|
31
32
|
};
|
|
33
|
+
export default theme;
|
|
@@ -5,6 +5,7 @@ export declare const textCss: {
|
|
|
5
5
|
underline: import("styled-components").FlattenSimpleInterpolation;
|
|
6
6
|
textAlignCenter: import("styled-components").FlattenSimpleInterpolation;
|
|
7
7
|
textAlignRight: import("styled-components").FlattenSimpleInterpolation;
|
|
8
|
+
textAlignLeft: import("styled-components").FlattenSimpleInterpolation;
|
|
8
9
|
uppercase: import("styled-components").FlattenSimpleInterpolation;
|
|
9
10
|
capitalize: import("styled-components").FlattenSimpleInterpolation;
|
|
10
11
|
lowercase: import("styled-components").FlattenSimpleInterpolation;
|