fuse-importer 0.0.5-testing → 0.0.7-testing

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +1 -1
  2. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.d.ts +2 -0
  3. package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +5 -4
  4. package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +2 -2
  5. package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.d.ts +1 -0
  6. package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +8 -3
  7. package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.d.ts +3 -1
  8. package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +38 -11
  9. package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +11 -5
  10. package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +21 -9
  11. package/lib/esm/Importer/common/Spreadsheet/hooks.js +1 -10
  12. package/lib/esm/Importer/common/Spreadsheet/transformation/index.d.ts +2 -2
  13. package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +33 -11
  14. package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.d.ts +7 -3
  15. package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +136 -38
  16. package/lib/esm/Importer/common/Spreadsheet/validation/validators.d.ts +1 -1
  17. package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +6 -1
  18. package/lib/esm/Importer/data/index.d.ts +2 -2
  19. package/lib/esm/Importer/data/index.js +12 -10
  20. package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +2 -1
  21. package/lib/esm/common/Table/TableActions/TableActions.js +3 -2
  22. package/lib/esm/common/Table/TableActions/TableActions.styles.d.ts +1 -0
  23. package/lib/esm/common/Table/TableActions/TableActions.styles.js +4 -3
  24. package/lib/esm/common/Table/TableActions/TransformedRecordsCount.d.ts +1 -0
  25. package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +71 -0
  26. package/lib/esm/common/Table/TableActions/icons.d.ts +1 -0
  27. package/lib/esm/common/Table/TableActions/icons.js +1 -0
  28. package/lib/esm/common/Table/TableView/TableRows/TableRow.js +1 -1
  29. package/lib/esm/common/columnsTransformations.d.ts +1 -0
  30. package/lib/esm/common/columnsTransformations.js +12 -10
  31. package/lib/esm/common/columnsValidations.js +261 -5
  32. package/lib/esm/locales/de.d.ts +5 -0
  33. package/lib/esm/locales/de.js +5 -0
  34. package/lib/esm/locales/en.d.ts +5 -0
  35. package/lib/esm/locales/en.js +5 -0
  36. package/lib/esm/locales/es.d.ts +5 -0
  37. package/lib/esm/locales/es.js +5 -0
  38. package/lib/esm/locales/fr.d.ts +5 -0
  39. package/lib/esm/locales/fr.js +5 -0
  40. package/lib/esm/types.d.ts +7 -0
  41. package/lib/main.js +17 -17
  42. package/package.json +1 -1
@@ -10,79 +10,171 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { DateTime } from "luxon";
13
+ var isTransformationNeeded = function (fieldValue, transformedValue) { return ({
14
+ transformationWasNeeded: fieldValue !== transformedValue,
15
+ original: fieldValue,
16
+ transformed: fieldValue === transformedValue ? null : transformedValue,
17
+ }); };
18
+ var isNotANumber = function (fieldValue) {
19
+ return fieldValue === null || fieldValue === undefined || isNaN(fieldValue);
20
+ };
21
+ var isNotAString = function (fieldValue) {
22
+ return !fieldValue || typeof fieldValue !== "string" || fieldValue.trim() === "";
23
+ };
13
24
  var stringFieldTransformations = {
14
25
  sentence_case: function (fieldValue) {
15
26
  var _a, _b;
16
- if (typeof fieldValue !== "string")
17
- return fieldValue;
18
- return (((_b = (_a = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase()) === null || _a === void 0 ? void 0 : _a.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
19
- (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.slice(1).toLowerCase()));
27
+ if (isNotAString(fieldValue))
28
+ return {
29
+ transformationWasNeeded: false,
30
+ original: fieldValue,
31
+ transformed: null,
32
+ };
33
+ var transformedValue = ((_b = (_a = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase()) === null || _a === void 0 ? void 0 : _a.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
34
+ (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.slice(1).toLowerCase());
35
+ return isTransformationNeeded(fieldValue, transformedValue);
20
36
  },
21
37
  capitalize: function (fieldValue) {
22
- var _a;
23
- if (typeof fieldValue !== "string")
24
- return fieldValue;
25
- return ((_a = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.charAt(0)) === null || _a === void 0 ? void 0 : _a.toUpperCase()) + (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.slice(1));
38
+ if (isNotAString(fieldValue)) {
39
+ return {
40
+ transformationWasNeeded: false,
41
+ original: fieldValue,
42
+ transformed: null,
43
+ };
44
+ }
45
+ var transformedValue = fieldValue
46
+ .split(" ")
47
+ .map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); })
48
+ .join(" ");
49
+ return isTransformationNeeded(fieldValue, transformedValue);
26
50
  },
27
51
  uppercase: function (fieldValue) {
28
- if (typeof fieldValue !== "string")
29
- return fieldValue;
30
- return fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toUpperCase();
52
+ if (isNotAString(fieldValue))
53
+ return {
54
+ transformationWasNeeded: false,
55
+ original: fieldValue,
56
+ transformed: null,
57
+ };
58
+ var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toUpperCase();
59
+ return isTransformationNeeded(fieldValue, transformedValue);
31
60
  },
32
61
  lowercase: function (fieldValue) {
33
- if (typeof fieldValue !== "string")
34
- return fieldValue;
35
- return fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase();
62
+ if (isNotAString(fieldValue))
63
+ return {
64
+ transformationWasNeeded: false,
65
+ original: fieldValue,
66
+ transformed: null,
67
+ };
68
+ var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.toLowerCase();
69
+ return isTransformationNeeded(fieldValue, transformedValue);
36
70
  },
37
71
  trim_whitespace: function (fieldValue) {
38
72
  if (typeof fieldValue !== "string")
39
- return fieldValue;
40
- return fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.trim();
73
+ return {
74
+ transformationWasNeeded: false,
75
+ original: fieldValue,
76
+ transformed: null,
77
+ };
78
+ var transformedValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.trim();
79
+ return isTransformationNeeded(fieldValue, transformedValue);
41
80
  },
42
81
  };
43
82
  var datesDateTimesAndTimesTransformations = {
44
83
  autoformat: function (fieldValue, _, fieldOptions) {
45
- var JSDate = new Date(fieldValue);
46
- if (!fieldValue || isNaN(JSDate.getTime())) {
47
- return fieldValue;
84
+ var cleanFieldValue = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.replace(/"/g, "");
85
+ var normalizedFieldValue = cleanFieldValue === null || cleanFieldValue === void 0 ? void 0 : cleanFieldValue.replace(/-/g, "/");
86
+ var isUnixTimestamp = /^\d+$/.test(normalizedFieldValue);
87
+ var JSDate = isUnixTimestamp
88
+ ? new Date(Number(normalizedFieldValue))
89
+ : new Date(normalizedFieldValue);
90
+ var pattern = fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.pattern;
91
+ var defaultObj = {
92
+ transformationWasNeeded: false,
93
+ original: fieldValue,
94
+ transformed: null,
95
+ };
96
+ if (!fieldValue || !pattern || isNotANumber(JSDate.getTime())) {
97
+ return defaultObj;
48
98
  }
49
99
  var luxonDate = DateTime.fromJSDate(JSDate);
50
- return luxonDate.toFormat(fieldOptions.pattern);
100
+ if (!luxonDate.isValid) {
101
+ return defaultObj;
102
+ }
103
+ var transformedValue = luxonDate === null || luxonDate === void 0 ? void 0 : luxonDate.toFormat(fieldOptions.pattern);
104
+ return isTransformationNeeded(fieldValue, transformedValue);
51
105
  },
52
106
  };
53
107
  var urlTransformations = {
54
108
  prefix: function (fieldValue, transformation) {
55
109
  var _a;
56
110
  var prefixValue = (_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.prefix;
57
- if (!prefixValue)
58
- return fieldValue;
59
- return "".concat(prefixValue).concat(fieldValue);
111
+ var fieldValueHasPrefix = fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.startsWith(prefixValue);
112
+ if (isNotAString(prefixValue) ||
113
+ isNotAString(fieldValue) ||
114
+ fieldValueHasPrefix)
115
+ return {
116
+ transformationWasNeeded: false,
117
+ original: fieldValue,
118
+ transformed: null,
119
+ };
120
+ var transformedValue = "".concat(prefixValue).concat(fieldValue);
121
+ return isTransformationNeeded(fieldValue, transformedValue);
60
122
  },
61
123
  };
62
124
  var floatTransformations = {
63
125
  number_of_decimals: function (fieldValue, transformation) {
64
126
  var _a;
65
127
  var numberOfDecimalsValue = Number((_a = transformation === null || transformation === void 0 ? void 0 : transformation.options) === null || _a === void 0 ? void 0 : _a.number_of_decimals);
66
- if (isNaN(numberOfDecimalsValue) || isNaN(fieldValue))
67
- return fieldValue;
68
- return Number(fieldValue.toFixed(numberOfDecimalsValue));
128
+ if (isNotANumber(numberOfDecimalsValue) || isNotANumber(fieldValue)) {
129
+ return {
130
+ transformationWasNeeded: false,
131
+ original: fieldValue,
132
+ transformed: null,
133
+ };
134
+ }
135
+ var transformedValue = parseFloat(Number(fieldValue).toFixed(numberOfDecimalsValue));
136
+ return isTransformationNeeded(fieldValue, transformedValue);
69
137
  },
70
138
  };
71
139
  var integerTransformations = {
72
140
  round: function (fieldValue) {
73
- if (isNaN(fieldValue))
74
- return fieldValue;
75
- return Math.round(fieldValue);
141
+ if (fieldValue === "" || isNotANumber(fieldValue)) {
142
+ return {
143
+ transformationWasNeeded: false,
144
+ original: fieldValue,
145
+ transformed: null,
146
+ };
147
+ }
148
+ var typeofFieldValue = typeof fieldValue;
149
+ var roundedValue = Math.round(fieldValue);
150
+ var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(roundedValue) : roundedValue;
151
+ return isTransformationNeeded(fieldValue, valueWithCorrectType);
76
152
  },
77
153
  floor: function (fieldValue) {
78
- if (isNaN(fieldValue))
79
- return fieldValue;
80
- return Math.floor(fieldValue);
154
+ if (fieldValue === "" || isNotANumber(fieldValue)) {
155
+ return {
156
+ transformationWasNeeded: false,
157
+ original: fieldValue,
158
+ transformed: null,
159
+ };
160
+ }
161
+ var typeofFieldValue = typeof fieldValue;
162
+ var flooredValue = Math.floor(fieldValue);
163
+ var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(flooredValue) : flooredValue;
164
+ return isTransformationNeeded(fieldValue, valueWithCorrectType);
81
165
  },
82
166
  ceiling: function (fieldValue) {
83
- if (isNaN(fieldValue))
84
- return fieldValue;
85
- return Math.ceil(fieldValue);
167
+ if (fieldValue === "" || isNotANumber(fieldValue)) {
168
+ return {
169
+ transformationWasNeeded: false,
170
+ original: fieldValue,
171
+ transformed: null,
172
+ };
173
+ }
174
+ var typeofFieldValue = typeof fieldValue;
175
+ var ceilingValue = Math.ceil(fieldValue);
176
+ var valueWithCorrectType = typeofFieldValue === "string" ? "".concat(ceilingValue) : ceilingValue;
177
+ return isTransformationNeeded(fieldValue, valueWithCorrectType);
86
178
  },
87
179
  };
88
180
  var enumTransformations = {
@@ -91,16 +183,22 @@ var enumTransformations = {
91
183
  return option.toLowerCase();
92
184
  });
93
185
  if (!fieldValue || options.length === 0)
94
- return fieldValue;
186
+ return {
187
+ transformationWasNeeded: false,
188
+ original: fieldValue,
189
+ transformed: null,
190
+ };
95
191
  var parsedRecord = String(fieldValue).toLowerCase();
96
192
  var trueOptionIndex = options.findIndex(function (option) { return option === "true" || option === "1"; });
97
193
  var falseOptionIndex = options.findIndex(function (option) { return option === "false" || option === "0"; });
98
194
  if (trueOptionIndex !== -1 && falseOptionIndex !== -1) {
99
- return parsedRecord === options[trueOptionIndex]
195
+ var transformedValue_1 = parsedRecord === options[trueOptionIndex]
100
196
  ? fieldOptions.options[trueOptionIndex]
101
197
  : fieldOptions.options[falseOptionIndex];
198
+ return isTransformationNeeded(fieldValue, transformedValue_1);
102
199
  }
103
- return fieldOptions.options[0];
200
+ var transformedValue = fieldOptions.options[0];
201
+ return isTransformationNeeded(fieldValue, transformedValue);
104
202
  },
105
203
  };
106
204
  export var fieldTransformations = __assign(__assign(__assign(__assign(__assign(__assign({}, stringFieldTransformations), datesDateTimesAndTimesTransformations), urlTransformations), floatTransformations), integerTransformations), enumTransformations);
@@ -1,5 +1,5 @@
1
1
  import { Field, FieldValidation, Record } from "../../../../types";
2
- export type FieldValidator = (field: Field, fieldValue: any, validation?: FieldValidation, data?: Record[]) => null | string;
2
+ export type FieldValidator = (field: Field, fieldValue: any, validation?: FieldValidation, data?: Record[], customErrorMessage?: string) => null | string;
3
3
  export type FieldValidations = Partial<{
4
4
  [key: string]: FieldValidator;
5
5
  }>;
@@ -85,7 +85,12 @@ export var fieldValidations = {
85
85
  if (!isNullOrUndefined(field.pattern) &&
86
86
  !isNullOrUndefined(fieldValue) &&
87
87
  !DateTime.fromFormat(fieldValue, field.pattern).isValid) {
88
- return "".concat(field.label, " must match the pattern ").concat(field.pattern);
88
+ var randomDate = DateTime.fromISO("1990-01-15T14:35:55.150");
89
+ var transformedValue = randomDate === null || randomDate === void 0 ? void 0 : randomDate.toFormat(field.pattern);
90
+ var defaultMessage = "".concat(field.label, " must match the pattern ").concat(field.pattern);
91
+ return transformedValue
92
+ ? "Must be formatted as \"".concat(field.pattern, "\" (e.g. ").concat(transformedValue, ")")
93
+ : defaultMessage;
89
94
  }
90
95
  },
91
96
  unique_case_sensitive: function (field, fieldValue, validator, data) {
@@ -1,4 +1,4 @@
1
- import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader } from "../../types";
1
+ import { Field, FieldTypes, FormatRecord, Record, RecordDataSet, TemplateHeader, TransformedRecord } from "../../types";
2
2
  import { EnumFieldValueMatchings, HeaderMatchings } from "../contexts/ImporterContextProvider";
3
3
  export declare const addEmptyRows: (data: Record[], fields: Field[]) => (Record | {
4
4
  _meta: {
@@ -6,7 +6,7 @@ export declare const addEmptyRows: (data: Record[], fields: Field[]) => (Record
6
6
  rowIndex: number;
7
7
  };
8
8
  })[];
9
- export declare const addMeta: (record: any, index: number, uploadedRow?: any) => Record;
9
+ export declare const addMeta: (record: any, index: number, uploadedRow?: any, transformedRow?: TransformedRecord) => Record;
10
10
  export declare const recordListToDataSet: (data: Record[], fields: Field[]) => RecordDataSet;
11
11
  type transformToRecordsArgs = {
12
12
  templateHeaderMatchings: HeaderMatchings;
@@ -37,20 +37,29 @@ export var addEmptyRows = function (data, fields) {
37
37
  } })); });
38
38
  return __spreadArray(__spreadArray([], data, true), newData, true);
39
39
  };
40
- export var addMeta = function (record, index, uploadedRow) {
40
+ export var addMeta = function (record, index, uploadedRow, transformedRow) {
41
41
  var _a;
42
42
  if (uploadedRow === void 0) { uploadedRow = null; }
43
+ if (transformedRow === void 0) { transformedRow = null; }
43
44
  var rId = getRowId(index);
44
45
  var meta = (_a = record._meta) !== null && _a !== void 0 ? _a : {};
45
- return __assign(__assign({}, record), { _meta: __assign(__assign({}, meta), { id: rId, rowIndex: index, touched: false, uploadedRow: uploadedRow }) });
46
+ return __assign(__assign({}, record), { _meta: __assign(__assign({}, meta), { id: rId, rowIndex: index, touched: false, uploadedRow: uploadedRow, transformedRow: transformedRow }) });
46
47
  };
47
48
  export var recordListToDataSet = function (data, fields) {
49
+ var fieldWithTransformations = fields.filter(function (field) { var _a; return ((_a = field === null || field === void 0 ? void 0 : field.transformations) === null || _a === void 0 ? void 0 : _a.length) > 0; });
48
50
  var initialData = data;
49
51
  if (data.length < MINIMUM_ROW_COUNT) {
50
52
  initialData = addEmptyRows(data, fields);
51
53
  }
52
54
  return initialData.reduce(function (dataSet, record, i) {
53
- var recordWithMeta = addMeta(record, i);
55
+ var transformedRecord = null;
56
+ if (fieldWithTransformations.length > 0) {
57
+ transformedRecord = transformRecord({
58
+ record: record,
59
+ fields: fieldWithTransformations,
60
+ });
61
+ }
62
+ var recordWithMeta = addMeta(record, i, undefined, transformedRecord);
54
63
  dataSet[recordWithMeta._meta.id] = recordWithMeta;
55
64
  return dataSet;
56
65
  }, {});
@@ -129,13 +138,6 @@ export var getTemplateFields = function (_a) {
129
138
  export var getReviewDataSet = function (_a) {
130
139
  var _b;
131
140
  var records = _a.records, fields = _a.fields;
132
- for (var _i = 0, records_1 = records; _i < records_1.length; _i++) {
133
- var record = records_1[_i];
134
- transformRecord({
135
- record: record,
136
- fields: fields,
137
- });
138
- }
139
141
  var baseInitialDataSet = recordListToDataSet(addEmptyRows(records, fields), fields);
140
142
  var highestRowIndex = 0;
141
143
  Object.keys(baseInitialDataSet).forEach(function (key) {
@@ -42,5 +42,6 @@ export var FilterByErrors = function () {
42
42
  : isMenuOpened
43
43
  ? search_or_select
44
44
  : prefix;
45
- return (_jsx(S.StyledAutocomplete, { placement: "bottom", placeholder: inputText, onToggle: function (v) { return setIsMenuOpened(v); }, onChange: onChange, value: selectedErrorToFilter, options: errorArray, isDisabled: errorArray.length === 0, isInputDisabled: errorArray.length === 0, inputWidth: inputWidth, "data-testid": "ta-filter-by-errors", prefix: inputText }));
45
+ var isDisabled = errorArray.length === 0;
46
+ return (_jsx(S.StyledAutocomplete, { placement: "bottom", placeholder: inputText, onToggle: function (v) { return !isDisabled && setIsMenuOpened(v); }, onChange: onChange, value: selectedErrorToFilter, options: errorArray, isDisabled: isDisabled, isInputDisabled: isDisabled, inputWidth: inputWidth, "data-testid": "ta-filter-by-errors", prefix: inputText }));
46
47
  };
@@ -25,10 +25,11 @@ import { defaultTableActionsHeightPx } from "./common";
25
25
  import { DeleteSelectedRows } from "./DeleteSelectedRows";
26
26
  import { SearchRows } from "./SearchRows";
27
27
  import { ExportData } from "./ExportData";
28
- import { ButtonActionsContainer, TableActionsContainer, TableActionsContent, } from "./TableActions.styles";
28
+ import * as S from "./TableActions.styles";
29
29
  import { FilterByErrors } from "./FilterByErrors/FilterByErrors";
30
30
  import { RowFilters } from "./RowFilters";
31
+ import { TransformedRecordsCount } from "./TransformedRecordsCount";
31
32
  export var TableActions = function (_a) {
32
33
  var _b = _a.tableActionsHeight, tableActionsHeight = _b === void 0 ? defaultTableActionsHeightPx : _b, props = __rest(_a, ["tableActionsHeight"]);
33
- return (_jsx(TableActionsContainer, __assign({ height: tableActionsHeight }, props, { children: _jsxs(TableActionsContent, { children: [_jsx(SearchRows, {}), _jsx(RowFilters, {}), _jsx(FilterByErrors, {}), _jsxs(ButtonActionsContainer, { children: [_jsx(DeleteSelectedRows, {}), _jsx(ExportData, {})] })] }) })));
34
+ return (_jsxs(S.TableActionsContainer, __assign({ height: tableActionsHeight }, props, { children: [_jsxs(S.TableActionsContent, { children: [_jsx(SearchRows, {}), _jsx(RowFilters, {}), _jsx(FilterByErrors, {}), _jsxs(S.ButtonActionsContainer, { children: [_jsx(DeleteSelectedRows, {}), _jsx(ExportData, {})] })] }), _jsx(S.TableActionsInformations, { children: _jsx(TransformedRecordsCount, {}) })] })));
34
35
  };
@@ -2,4 +2,5 @@ import { TableActionsContainerProps } from "./TableActions";
2
2
  export declare const TableActionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps & TableActionsContainerProps, never>;
3
3
  export declare const ButtonActionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
4
4
  export declare const TableActionsContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
5
+ export declare const TableActionsInformations: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../../styled/utils").CSSProps, never>;
5
6
  export declare const ActionButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
@@ -4,7 +4,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import styled from "styled-components";
6
6
  import { Div } from "../../../styled/utils";
7
- 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 padding: 8px 32px;\n width: 100%;\n\n * {\n box-sizing: content-box;\n }\n"], ["\n align-items: center;\n background: ", ";\n border-top: 1px solid ", ";\n display: flex;\n padding: 8px 32px;\n width: 100%;\n\n * {\n box-sizing: content-box;\n }\n"])), function (_a) {
7
+ 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 justify-content: space-between;\n padding: 8px 32px;\n width: 100%;\n\n * {\n box-sizing: content-box;\n }\n"], ["\n align-items: center;\n background: ", ";\n border-top: 1px solid ", ";\n display: flex;\n justify-content: space-between;\n padding: 8px 32px;\n width: 100%;\n\n * {\n box-sizing: content-box;\n }\n"])), function (_a) {
8
8
  var theme = _a.theme;
9
9
  return theme.colors.white;
10
10
  }, function (_a) {
@@ -13,5 +13,6 @@ export var TableActionsContainer = styled(Div)(templateObject_1 || (templateObje
13
13
  });
14
14
  export var ButtonActionsContainer = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 8px;\n"], ["\n align-items: center;\n display: flex;\n gap: 8px;\n"])));
15
15
  export var TableActionsContent = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n"], ["\n align-items: center;\n display: flex;\n gap: 16px;\n"])));
16
- export var ActionButton = styled.button(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\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: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"])));
17
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
16
+ export var TableActionsInformations = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n gap: 16px;\n"], ["\n align-items: center;\n display: flex;\n gap: 16px;\n"])));
17
+ export var ActionButton = styled.button(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n align-items: center;\n background: transparent;\n border-radius: 4px;\n border: none;\n cursor: pointer;\n display: flex;\n height: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\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: 36px;\n justify-content: center;\n padding: 0px;\n width: 36px;\n\n :disabled {\n opacity: 0.6;\n\n :hover {\n background-color: transparent !important;\n cursor: not-allowed;\n }\n }\n"])));
18
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -0,0 +1 @@
1
+ export declare const TransformedRecordsCount: () => JSX.Element;
@@ -0,0 +1,71 @@
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, Fragment as _Fragment } from "react/jsx-runtime";
17
+ import { useEffect, useMemo, useRef } from "react";
18
+ import { useTranslation } from "react-i18next";
19
+ import styled from "styled-components";
20
+ import { useSpreadsheetContext } from "../../../Importer";
21
+ import { Div, colors } from "../../../styled";
22
+ import { CheckIcon } from "./icons";
23
+ import { Button } from "../../../common/buttons";
24
+ var formatToLocaleString = function (number) {
25
+ return number.toLocaleString(undefined, {
26
+ minimumFractionDigits: 0,
27
+ maximumFractionDigits: 0,
28
+ });
29
+ };
30
+ var RecordsCountContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n z-index: 2;\n\n * {\n box-sizing: border-box;\n }\n"], ["\n position: relative;\n z-index: 2;\n\n * {\n box-sizing: border-box;\n }\n"])));
31
+ var Counter = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border-radius: 35px;\n display: flex;\n padding: 0px 18px;\n user-select: none;\n"], ["\n align-items: center;\n background: ", ";\n border-radius: 35px;\n display: flex;\n padding: 0px 18px;\n user-select: none;\n"])), colors.blue100);
32
+ var TooltipContainer = styled(Div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", ";\n border-radius: 8px;\n box-shadow: 0px 3.53px 63.58px 0px #b7a6a640;\n display: flex;\n flex-direction: column;\n gap: 18px;\n padding: 16px 32px 24px 24px;\n position: absolute;\n right: 0px;\n top: 66px;\n width: clamp(150px, 379px, 379px);\n\n &::before {\n border-color: transparent transparent #ffffff transparent;\n border-radius: 4px;\n border-style: solid;\n border-width: 0 14.5px 24px 14.5px;\n content: \"\";\n height: 0;\n position: absolute;\n right: -4px;\n top: -6px;\n transform: rotate(120deg);\n width: 0;\n }\n"], ["\n background: ", ";\n border-radius: 8px;\n box-shadow: 0px 3.53px 63.58px 0px #b7a6a640;\n display: flex;\n flex-direction: column;\n gap: 18px;\n padding: 16px 32px 24px 24px;\n position: absolute;\n right: 0px;\n top: 66px;\n width: clamp(150px, 379px, 379px);\n\n &::before {\n border-color: transparent transparent #ffffff transparent;\n border-radius: 4px;\n border-style: solid;\n border-width: 0 14.5px 24px 14.5px;\n content: \"\";\n height: 0;\n position: absolute;\n right: -4px;\n top: -6px;\n transform: rotate(120deg);\n width: 0;\n }\n"])), colors.white);
33
+ var ExampleCode = styled(Div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border-radius: 4px;\n display: flex;\n justify-content: space-between;\n padding: 4px;\n"], ["\n align-items: center;\n background: ", ";\n border-radius: 4px;\n display: flex;\n justify-content: space-between;\n padding: 4px;\n"])), colors.blue100);
34
+ var StyledButton = styled(Button)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n align-self: flex-end;\n height: 36px;\n padding: 0px;\n width: 61px;\n"], ["\n align-self: flex-end;\n height: 36px;\n padding: 0px;\n width: 61px;\n"])));
35
+ var Tooltip = function (_a) {
36
+ var recordsCount = _a.recordsCount, onClose = _a.onClose;
37
+ var t = useTranslation("review").t;
38
+ return (_jsxs(TooltipContainer, __assign({ "data-cy": "transformations-tooltip" }, { children: [_jsx(Div, { children: _jsx(CheckIcon, {}) }), _jsx(Div, __assign({ subtitle: true }, { children: t("table_actions.transformed_records.auto_corrections_amount", {
39
+ amount: formatToLocaleString(recordsCount),
40
+ }) })), _jsxs(Div, { children: [_jsx(Div, __assign({ mb: 5, label1: true, style: { color: colors.gray700 } }, { children: t("table_actions.transformed_records.example") })), _jsxs(ExampleCode, { children: [_jsx(Div, __assign({ body1: true }, { children: "$37.00" })), _jsx(Div, __assign({ body1: true, style: { textDecoration: "line-through" } }, { children: "$36.8" }))] })] }), _jsx(StyledButton, __assign({ buttonTextSmall: true, uppercase: true, onClick: onClose }, { children: "OK" }))] })));
41
+ };
42
+ export var TransformedRecordsCount = function () {
43
+ var _a = useSpreadsheetContext(), data = _a.data, isTransformTooltipOpened = _a.isTransformTooltipOpened, setIsTransformTooltipOpened = _a.setIsTransformTooltipOpened;
44
+ var t = useTranslation("review").t;
45
+ var tooltipWasAlreadyOpened = useRef(false);
46
+ var transformedRecordsCount = useMemo(function () {
47
+ var _a;
48
+ var counter = 0;
49
+ for (var i = 0; i < data.length; i++) {
50
+ var currentData = data[i];
51
+ var transformedObj = (_a = currentData === null || currentData === void 0 ? void 0 : currentData._meta) === null || _a === void 0 ? void 0 : _a.transformedRow;
52
+ if (transformedObj) {
53
+ counter += Object.keys(transformedObj).length;
54
+ }
55
+ }
56
+ return counter;
57
+ }, [data]);
58
+ useEffect(function () {
59
+ if (tooltipWasAlreadyOpened.current)
60
+ return;
61
+ if (transformedRecordsCount > 0 && !isTransformTooltipOpened) {
62
+ setIsTransformTooltipOpened(true);
63
+ tooltipWasAlreadyOpened.current = true;
64
+ }
65
+ }, [transformedRecordsCount]);
66
+ var handleCloseTooltip = function () {
67
+ setIsTransformTooltipOpened(false);
68
+ };
69
+ return (_jsx(_Fragment, { children: isTransformTooltipOpened && transformedRecordsCount ? (_jsxs(RecordsCountContainer, { children: [_jsxs(Counter, __assign({ body1: true }, { children: [_jsxs(Div, __assign({ bold: true, mr: 4, "data-cy": "transformations-counter" }, { children: [formatToLocaleString(transformedRecordsCount), " "] })), t("table_actions.transformed_records.auto_corrections_done")] })), isTransformTooltipOpened && (_jsx(Tooltip, { recordsCount: transformedRecordsCount, onClose: handleCloseTooltip }))] })) : null }));
70
+ };
71
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -2,3 +2,4 @@ export declare const DeleteIcon: () => JSX.Element;
2
2
  export declare const ConfirmationDeleteIcon: JSX.Element;
3
3
  export declare const SearchIcon: () => JSX.Element;
4
4
  export declare const DownloadIcon: () => JSX.Element;
5
+ export declare const CheckIcon: () => JSX.Element;
@@ -14,3 +14,4 @@ export var DeleteIcon = function () { return (_jsxs("svg", __assign({ width: "22
14
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
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" })] }))); };
16
16
  export var DownloadIcon = function () { return (_jsxs("svg", __assign({ width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M10.0834 18C9.66675 16.75 9.66675 15.5 9.66675 14.6303C9.66675 11.7319 12.2621 8.83337 15.4637 8.83337C17.6094 8.83337 19.4828 9.99914 20.4852 11.7319H21.2607C23.6619 11.7319 25.9167 13.4167 25.9167 15.5C25.9167 16.3334 25.9167 17.1667 25.5001 18", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M14.1807 23.2764L17.5834 26.5416L20.9862 23.2764", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M17.5833 25.6827L17.5833 16.4375", stroke: "#262626", strokeWidth: "2", strokeLinecap: "round" })] }))); };
17
+ export var CheckIcon = function () { return (_jsxs("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", width: "53", height: "53", viewBox: "0 0 53 53", fill: "none" }, { children: [_jsx("rect", { width: "53", height: "53", fill: "white" }), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M40.6023 5.38665C41.3381 4.56281 42.6024 4.49142 43.4263 5.22719L51.5083 12.4453C52.3321 13.181 52.4035 14.4454 51.6677 15.2692L23.539 46.7647C22.8032 47.5885 21.5389 47.6599 20.7151 46.9242L12.6331 39.7061C11.8092 38.9703 11.7378 37.706 12.4736 36.8822L40.6023 5.38665Z", fill: "url(#paint0_linear_643_341)" }) })), _jsx("g", __assign({ style: { mixBlendMode: "darken" } }, { children: _jsx("rect", { x: "32.0707", y: "37.1587", width: "14.836", height: "29.7113", rx: "2", transform: "rotate(131.582 32.0707 37.1587)", fill: "url(#paint1_linear_643_341)" }) })), _jsxs("defs", { children: [_jsxs("linearGradient", __assign({ id: "paint0_linear_643_341", x1: "15.4625", y1: "39.0861", x2: "31.139", y2: "48.4231", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#D0A617" }), _jsx("stop", { offset: "1", stopColor: "#FEE18F" })] })), _jsxs("linearGradient", __assign({ id: "paint1_linear_643_341", x1: "39.4887", y1: "37.1587", x2: "29.9147", y2: "74.1394", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#6BEEFF" }), _jsx("stop", { offset: "1", stopColor: "#08CABE" })] }))] })] }))); };
@@ -51,7 +51,7 @@ export var TableRow = function (_a) {
51
51
  var isLastColumn = indexJ === columns.length - 1;
52
52
  return (_jsx(Cell, __assign({ row: row, onClick: onRowClick && !column.preventRowClick
53
53
  ? function () { return onRowClick(row); }
54
- : null, isLast: isLastColumn, className: isLastColumn ? "last-column" : "", w: columnWidthPercentage }, { children: Content ? (_jsx(Content, __assign({}, row, { rowIndex: indexI }))) : (_jsx(Div, __assign({ truncateText: true }, { children: row[column.dataAccessor] || "-" }))) }), resolvedKey));
54
+ : null, isLast: isLastColumn, className: isLastColumn ? "last-column" : "", w: columnWidthPercentage }, { children: Content ? (_jsx(Content, __assign({}, row, { columnWidth: columnWidthPercentage, rowIndex: indexI }))) : (_jsx(Div, __assign({ truncateText: true }, { children: row[column.dataAccessor] || "-" }))) }), resolvedKey));
55
55
  }) })));
56
56
  };
57
57
  var templateObject_1, templateObject_2, templateObject_3;
@@ -8,6 +8,7 @@ export type Transformation = {
8
8
  value: TransformationTypes;
9
9
  label: string;
10
10
  options?: TransformationOption[];
11
+ isDefaultTransformation?: boolean;
11
12
  };
12
13
  export declare const transformationsByColumnType: {
13
14
  [key: string]: Transformation[];
@@ -1,29 +1,30 @@
1
1
  var commonDateAndTimeTransformations = [
2
2
  {
3
3
  value: "autoformat",
4
- label: "Autoformat",
4
+ label: "Autoformat (e.g. 02-13-2020 -> 02/13/2020",
5
+ isDefaultTransformation: true,
5
6
  },
6
7
  ];
7
8
  var stringTransformations = [
8
9
  {
9
10
  value: "sentence_case",
10
- label: "Sentence Case",
11
+ label: "Sentence Case (e.g. hello world -> Hello world)",
11
12
  },
12
13
  {
13
14
  value: "capitalize",
14
- label: "Capitalize",
15
+ label: "Capitalize (e.g. hello world -> Hello World)",
15
16
  },
16
17
  {
17
18
  value: "uppercase",
18
- label: "Uppercase",
19
+ label: "Uppercase (e.g. hello world -> HELLO WORLD)",
19
20
  },
20
21
  {
21
22
  value: "lowercase",
22
- label: "Lowercase",
23
+ label: "Lowercase (e.g. Hello World -> hello world)",
23
24
  },
24
25
  {
25
26
  value: "trim_whitespace",
26
- label: "Trim Whitespace",
27
+ label: "Trim Whitespace (e.g. ' hello world ' -> 'hello world')",
27
28
  },
28
29
  ];
29
30
  var urlTransformations = [
@@ -55,21 +56,22 @@ var floatTransformations = [
55
56
  var integerTransformations = [
56
57
  {
57
58
  value: "round",
58
- label: "Round",
59
+ label: "Round (e.g. 3.19 -> 3)",
59
60
  },
60
61
  {
61
62
  value: "floor",
62
- label: "Floor",
63
+ label: "Floor (e.g. 3.99 -> 3)",
63
64
  },
64
65
  {
65
66
  value: "ceiling",
66
- label: "Ceiling",
67
+ label: "Ceiling (e.g. 3.01 -> 4)",
67
68
  },
68
69
  ];
69
70
  var enumTransformations = [
70
71
  {
71
72
  value: "autodetect",
72
- label: "Autodetect",
73
+ label: "Autodetect (e.g. 0/1 -> true/false)",
74
+ isDefaultTransformation: true,
73
75
  },
74
76
  ];
75
77
  export var transformationsByColumnType = {