fuse-importer 0.0.8-testing → 0.1.1-testing
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/ImporterWithContext.js +63 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +68 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +58 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.js +21 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +23 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +61 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +55 -0
- package/lib/esm/Importer/Matcher/common/icons/index.js +14 -0
- package/lib/esm/Importer/Matcher/common/index.js +39 -0
- package/lib/esm/Importer/Matcher/common/types.js +9 -0
- package/lib/esm/Importer/Matcher/index.js +22 -0
- package/lib/esm/Importer/PreviewFirstTime.js +81 -0
- package/lib/esm/Importer/PreviewModeBanner.js +19 -0
- package/lib/esm/Importer/Review/AppResponseModal.js +35 -0
- package/lib/esm/Importer/Review/ReviewContextProvider.js +318 -0
- package/lib/esm/Importer/Review/ReviewWithContext.js +33 -0
- package/lib/esm/Importer/Review/index.js +4 -0
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +24 -0
- package/lib/esm/Importer/Stepper/Step.js +19 -0
- package/lib/esm/Importer/Stepper/StepIndex.js +27 -0
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +24 -0
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +31 -0
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +33 -0
- package/lib/esm/Importer/Stepper/common/icons.js +18 -0
- package/lib/esm/Importer/Stepper/index.js +118 -0
- package/lib/esm/Importer/TrialModeBanner.js +22 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/DragAndDropImporter.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +123 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/ImporterSectionHeader.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +44 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.js +14 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +45 -0
- package/lib/esm/Importer/Uploader/HeaderButtons.js +28 -0
- package/lib/esm/Importer/Uploader/HeadersPreview.js +44 -0
- package/lib/esm/Importer/Uploader/UploaderContextProvider.js +27 -0
- package/lib/esm/Importer/Uploader/index.js +13 -0
- package/lib/esm/Importer/common/AppLoading.js +24 -0
- package/lib/esm/Importer/common/Footer.js +17 -0
- package/lib/esm/Importer/common/FuseApi.js +48 -0
- package/lib/esm/Importer/common/GlobalStyle.js +7 -0
- package/lib/esm/Importer/common/ImporterFonts.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +56 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +176 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +66 -0
- package/lib/esm/Importer/common/Spreadsheet/components/GlobalStyle.js +9 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +110 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +186 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +55 -0
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +19 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +43 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +74 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.d.ts +2 -1
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +114 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.d.ts +11 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/utils.js +29 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/Boolean.js +18 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.js +30 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/FloatInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/IntegerInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/StringInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +20 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +245 -0
- package/lib/esm/Importer/common/Spreadsheet/index.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/styles.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +47 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +236 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +202 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +181 -0
- package/lib/esm/Importer/common/icons/index.js +18 -0
- package/lib/esm/Importer/common/index.js +13 -0
- package/lib/esm/Importer/common/theme.js +19 -0
- package/lib/esm/Importer/common/utils.js +100 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +247 -0
- package/lib/esm/Importer/data/index.js +172 -0
- package/lib/esm/Importer/index.js +28 -0
- package/lib/esm/api/index.js +93 -0
- package/lib/esm/api/responseHandlers.js +49 -0
- package/lib/esm/common/AppLoadingContextProvider/AppLoadingUI.js +26 -0
- package/lib/esm/common/AppLoadingContextProvider/index.js +25 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Modal.js +31 -0
- package/lib/esm/common/Spinner.js +41 -0
- package/lib/esm/common/Table/Pagination/icons.js +42 -0
- package/lib/esm/common/Table/Pagination/index.js +32 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +50 -0
- package/lib/esm/common/Table/TableActions/ExportData.js +23 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +47 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +72 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +35 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +18 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +83 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/hooks.js +41 -0
- package/lib/esm/common/Table/TableActions/icons.js +17 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableDataProvider.js +127 -0
- package/lib/esm/common/Table/TableView/TableHeaders.js +69 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +57 -0
- package/lib/esm/common/Table/TableView/TableRows/index.js +48 -0
- package/lib/esm/common/Table/TableView/common/index.js +37 -0
- package/lib/esm/common/Table/TableView/index.js +132 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/icons.js +15 -0
- package/lib/esm/common/Table/index.js +140 -0
- package/lib/esm/common/Table/useReorderRows.js +83 -0
- package/lib/esm/common/Toast.js +69 -0
- package/lib/esm/common/TooltipProvider.js +57 -0
- package/lib/esm/common/buttons.js +97 -0
- package/lib/esm/common/columnsTransformations.js +94 -0
- package/lib/esm/common/columnsValidations.d.ts +1 -27
- package/lib/esm/common/columnsValidations.js +401 -0
- package/lib/esm/common/datePatterns.d.ts +26 -0
- package/lib/esm/common/datePatterns.js +327 -0
- package/lib/esm/common/icons/index.js +30 -0
- package/lib/esm/common/index.d.ts +1 -0
- package/lib/esm/common/index.js +46 -0
- package/lib/esm/common/inputs/Autocomplete.js +110 -0
- package/lib/esm/common/inputs/Checkbox.js +53 -0
- package/lib/esm/common/inputs/SelectMenu.js +74 -0
- package/lib/esm/common/inputs/TextInput.js +89 -0
- package/lib/esm/common/inputs/index.js +5 -0
- package/lib/esm/common/inputs/tooltip.js +38 -0
- package/lib/esm/common/logo.js +13 -0
- package/lib/esm/hooks/index.d.ts +1 -0
- package/lib/esm/hooks/index.js +16 -0
- package/lib/esm/index.js +218 -0
- package/lib/esm/locales/de.js +126 -0
- package/lib/esm/locales/en.js +126 -0
- package/lib/esm/locales/es.js +126 -0
- package/lib/esm/locales/fr.js +126 -0
- package/lib/esm/locales/index.js +4 -0
- package/lib/esm/styled/fontsURL.js +27 -0
- package/lib/esm/styled/index.js +3 -0
- package/lib/esm/styled/theme/animations.js +9 -0
- package/lib/esm/styled/theme/colorPalette.js +109 -0
- package/lib/esm/styled/theme/debugCss.js +16 -0
- package/lib/esm/styled/theme/dimensionsCss.js +20 -0
- package/lib/esm/styled/theme/fontCss.js +17 -0
- package/lib/esm/styled/theme/globalCss.js +26 -0
- package/lib/esm/styled/theme/index.js +33 -0
- package/lib/esm/styled/theme/layoutCss.js +26 -0
- package/lib/esm/styled/theme/mediaQueries.js +4 -0
- package/lib/esm/styled/theme/positionCss.js +27 -0
- package/lib/esm/styled/theme/textCss.js +18 -0
- package/lib/esm/styled/theme/textStyles.js +27 -0
- package/lib/esm/styled/themeType.js +6 -0
- package/lib/esm/styled/utils.js +17 -0
- package/lib/esm/types.d.ts +7 -6
- package/lib/esm/types.js +65 -0
- package/lib/esm/utils/hooks/useWindowSize.js +23 -0
- package/lib/esm/utils/hooks.js +1 -0
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +41 -0
- package/lib/main.js +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
|
+
import { get } from "lodash";
|
|
29
|
+
import styled, { css } from "styled-components";
|
|
30
|
+
import { Div, HTMLButton } from "../styled/utils";
|
|
31
|
+
var types = ["primary", "secondary", "tertiary", "link"];
|
|
32
|
+
var getBgColor = function (props) {
|
|
33
|
+
return get(props, "backgroundColor", get(props.theme, "colors.pink500"));
|
|
34
|
+
};
|
|
35
|
+
var getBorderColor = function (props) {
|
|
36
|
+
return get(props, "backgroundColor", get(props.theme, "colors.pink700"));
|
|
37
|
+
};
|
|
38
|
+
var getSvgFillColorForNormalState = function (props) {
|
|
39
|
+
return get(props, "svgNormalFillColorOverride", get(props.theme, "colors.black"));
|
|
40
|
+
};
|
|
41
|
+
var getSvgFillColorForActiveState = function (props) {
|
|
42
|
+
return get(props, "svgActiveFillColorOverride", get(props.theme, "colors.white"));
|
|
43
|
+
};
|
|
44
|
+
var getSvgFillColorForDisabledState = function (props) {
|
|
45
|
+
return get(props, "svgDisabledFillColorOverride", get(props.theme, "colors.gray390"));
|
|
46
|
+
};
|
|
47
|
+
var getSvgStrokeColorForNormalState = function (props) {
|
|
48
|
+
return get(props, "svgNormalStrokeColorOverride", get(props.theme, "colors.black"));
|
|
49
|
+
};
|
|
50
|
+
var getSvgStrokeColorForActiveState = function (props) {
|
|
51
|
+
return get(props, "svgActiveStrokeColorOverride", get(props.theme, "colors.white"));
|
|
52
|
+
};
|
|
53
|
+
var getSvgStrokeColorForDisabledState = function (props) {
|
|
54
|
+
return get(props, "svgDisabledStrokeColorOverride", get(props.theme, "colors.black"));
|
|
55
|
+
};
|
|
56
|
+
var withoutBrandingCSS = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n text-decoration: underline;\n"], ["\n text-decoration: underline;\n"])));
|
|
57
|
+
var withBrandingCSS = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n :hover {\n background: transparent;\n text-decoration: underline;\n }\n"], ["\n :hover {\n background: transparent;\n text-decoration: underline;\n }\n"])));
|
|
58
|
+
var styles = {
|
|
59
|
+
primary: css(templateObject_4 || (templateObject_4 = __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; }, getBgColor, getBgColor, getBgColor, getBgColor, getBgColor, getBorderColor, getBgColor, getBgColor, function (props) {
|
|
60
|
+
return props.isDisabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", " !important;\n opacity: 0.4;\n box-shadow: none !important;\n border: none !important;\n cursor: not-allowed !important;\n "], ["\n background: ", " !important;\n opacity: 0.4;\n box-shadow: none !important;\n border: none !important;\n cursor: not-allowed !important;\n "])), getBgColor);
|
|
61
|
+
}),
|
|
62
|
+
secondary: css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", ";\n box-sizing: border-box;\n border: solid 1px ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n stroke: ", ";\n }\n }\n :active {\n border: 1px solid ", ";\n background: ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n stroke: ", ";\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 stroke: ", ";\n }\n }\n :active {\n border: 1px solid ", ";\n background: ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n stroke: ", ";\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; }, getSvgFillColorForNormalState, getSvgStrokeColorForNormalState, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.white; }, getSvgFillColorForActiveState, getSvgStrokeColorForActiveState, function (props) {
|
|
63
|
+
return props.isDisabled && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border: 2px solid ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n stroke: ", ";\n }\n }\n "], ["\n border: 2px solid ", ";\n color: ", ";\n & > svg {\n & > path {\n fill: ", ";\n stroke: ", ";\n }\n }\n "])), function (props) { return props.theme.colors.gray390; }, function (props) { return props.theme.colors.gray390; }, getSvgFillColorForDisabledState, getSvgStrokeColorForDisabledState);
|
|
64
|
+
}),
|
|
65
|
+
tertiary: css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background: transparent;\n border: solid 1px transparent;\n color: ", ";\n :hover {\n background: ", ";\n }\n :active {\n background: ", ";\n color: ", ";\n }\n ", "\n "], ["\n background: transparent;\n border: solid 1px transparent;\n color: ", ";\n :hover {\n background: ", ";\n }\n :active {\n background: ", ";\n color: ", ";\n }\n ", "\n "])), function (props) { return props.theme.colors.text; }, function (props) { return props.theme.colors.white50; }, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.white; }, function (props) {
|
|
66
|
+
return props.isDisabled && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (props) { return props.theme.colors.gray300; });
|
|
67
|
+
}),
|
|
68
|
+
link: css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: transparent;\n border: solid 1px transparent;\n color: ", ";\n\n :hover {\n background: ", ";\n }\n\n ", "\n\n ", "\n\n :active {\n background: ", ";\n color: ", ";\n }\n "], ["\n background: transparent;\n border: solid 1px transparent;\n color: ", ";\n\n :hover {\n background: ", ";\n }\n\n ", "\n\n ", "\n\n :active {\n background: ", ";\n color: ", ";\n }\n "])), function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.white50; }, function (props) {
|
|
69
|
+
return props.isDisabled && css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (props) { return props.theme.colors.gray300; });
|
|
70
|
+
}, function (_a) {
|
|
71
|
+
var theme = _a.theme;
|
|
72
|
+
return theme.colors.black === "black"
|
|
73
|
+
? withoutBrandingCSS
|
|
74
|
+
: withBrandingCSS;
|
|
75
|
+
}, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.white; }),
|
|
76
|
+
};
|
|
77
|
+
var commonButtonStyle = css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n padding: 12px 24px;\n user-select: none;\n width: fit-content;\n\n ", "\n\n border: solid 1px black;\n border-radius: 4px;\n\n font-family: DM Sans;\n\n :focus {\n outline: none;\n }\n :hover {\n cursor: pointer;\n }\n\n ", "\n ", ";\n\n ", ";\n"], ["\n padding: 12px 24px;\n user-select: none;\n width: fit-content;\n\n ", "\n\n border: solid 1px black;\n border-radius: 4px;\n\n font-family: DM Sans;\n\n :focus {\n outline: none;\n }\n :hover {\n cursor: pointer;\n }\n\n ", "\n ", ";\n\n ", ";\n"])), function (props) {
|
|
78
|
+
return props.isSmall && css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n padding: 6px 20px;\n "], ["\n padding: 6px 20px;\n "])));
|
|
79
|
+
}, function (props) {
|
|
80
|
+
return props.isDisabled && css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n pointer-events: none;\n "], ["\n pointer-events: none;\n "])));
|
|
81
|
+
}, function (props) {
|
|
82
|
+
var c = props.theme.css;
|
|
83
|
+
return [c.centered, c.buttonText];
|
|
84
|
+
}, function (props) { return styles[props.variant || "primary"]; });
|
|
85
|
+
export var ButtonWrapper = styled(Div)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), commonButtonStyle);
|
|
86
|
+
export var ButtonElementWrapper = styled(HTMLButton)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), commonButtonStyle);
|
|
87
|
+
export var Button = function (_a) {
|
|
88
|
+
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"]);
|
|
89
|
+
return (_jsx(_Fragment, { children: isButtonElement ? (_jsx(ButtonElementWrapper, __assign({ isSmall: isSmall, isDisabled: isDisabled, disabled: isDisabled, variant: variant, type: "submit" }, props, { children: children }))) : (_jsx(ButtonWrapper, __assign({ role: "button", w: "fit-content", p: 12, isSmall: isSmall, onClick: isDisabled ? null : onClick, onKeyDown: function (_a) {
|
|
90
|
+
var code = _a.code;
|
|
91
|
+
if ((code === "Space" || (code === "Enter" && onClick)) &&
|
|
92
|
+
!isDisabled) {
|
|
93
|
+
onClick();
|
|
94
|
+
}
|
|
95
|
+
}, tabIndex: 0 }, __assign({ variant: variant, isDisabled: isDisabled, onClick: onClick, disabled: isDisabled }, props), { children: _jsx(_Fragment, { children: children }) }))) }));
|
|
96
|
+
};
|
|
97
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var commonDateAndTimeTransformations = [
|
|
2
|
+
{
|
|
3
|
+
value: "autoformat",
|
|
4
|
+
label: "Autoformat (e.g. 02-13-2020 -> 02/13/2020",
|
|
5
|
+
isDefaultTransformation: true,
|
|
6
|
+
},
|
|
7
|
+
];
|
|
8
|
+
var stringTransformations = [
|
|
9
|
+
{
|
|
10
|
+
value: "sentence_case",
|
|
11
|
+
label: "Sentence Case (e.g. hello world -> Hello world)",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
value: "capitalize",
|
|
15
|
+
label: "Capitalize (e.g. hello world -> Hello World)",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "uppercase",
|
|
19
|
+
label: "Uppercase (e.g. hello world -> HELLO WORLD)",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "lowercase",
|
|
23
|
+
label: "Lowercase (e.g. Hello World -> hello world)",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: "trim_whitespace",
|
|
27
|
+
label: "Trim Whitespace (e.g. ' hello world ' -> 'hello world')",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
var urlTransformations = [
|
|
31
|
+
{
|
|
32
|
+
value: "prefix",
|
|
33
|
+
label: "Prefix",
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
key: "prefix",
|
|
37
|
+
type: "text",
|
|
38
|
+
tooltip: "Add Prefix (e.g., 'example.com' becomes 'https://example.com')",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
var floatTransformations = [
|
|
44
|
+
{
|
|
45
|
+
value: "number_of_decimals",
|
|
46
|
+
label: "Number of Decimals",
|
|
47
|
+
options: [
|
|
48
|
+
{
|
|
49
|
+
key: "number_of_decimals",
|
|
50
|
+
type: "number",
|
|
51
|
+
tooltip: "Set Number of Decimals (e.g., '10.567' becomes '10.57' with 2 decimals)",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
var integerTransformations = [
|
|
57
|
+
{
|
|
58
|
+
value: "round",
|
|
59
|
+
label: "Round (e.g. 3.19 -> 3)",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: "floor",
|
|
63
|
+
label: "Floor (e.g. 3.99 -> 3)",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: "ceiling",
|
|
67
|
+
label: "Ceiling (e.g. 3.01 -> 4)",
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
var enumTransformations = [
|
|
71
|
+
{
|
|
72
|
+
value: "autodetect",
|
|
73
|
+
label: "Autodetect (e.g. 0/1 -> true/false)",
|
|
74
|
+
isDefaultTransformation: true,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
export var transformationsByColumnType = {
|
|
78
|
+
string: stringTransformations,
|
|
79
|
+
integer: integerTransformations,
|
|
80
|
+
float: floatTransformations,
|
|
81
|
+
enum: enumTransformations,
|
|
82
|
+
url: urlTransformations,
|
|
83
|
+
date: commonDateAndTimeTransformations,
|
|
84
|
+
datetime: commonDateAndTimeTransformations,
|
|
85
|
+
time: commonDateAndTimeTransformations,
|
|
86
|
+
};
|
|
87
|
+
// the final object will look like this:
|
|
88
|
+
// { autodetect: { value: "autodetect", label: "Autodetect" }, ... }
|
|
89
|
+
export var transformationsByType = Object.values(transformationsByColumnType)
|
|
90
|
+
.reduce(function (acc, arr) { return acc.concat(arr); }, [])
|
|
91
|
+
.reduce(function (result, p) {
|
|
92
|
+
result[p.value] = p;
|
|
93
|
+
return result;
|
|
94
|
+
}, {});
|
|
@@ -15,31 +15,5 @@ export declare const validationsByColumnType: {
|
|
|
15
15
|
};
|
|
16
16
|
export declare const validationsByType: {};
|
|
17
17
|
export declare const availableColumnTypes: string[];
|
|
18
|
-
export declare const datePatterns: {
|
|
19
|
-
value: string;
|
|
20
|
-
label: string;
|
|
21
|
-
}[];
|
|
22
|
-
export declare const dateTimePatterns: {
|
|
23
|
-
value: string;
|
|
24
|
-
label: string;
|
|
25
|
-
}[];
|
|
26
|
-
export declare const timePatterns: {
|
|
27
|
-
value: string;
|
|
28
|
-
label: string;
|
|
29
|
-
}[];
|
|
30
|
-
export declare const allowedPatterns: {
|
|
31
|
-
date: {
|
|
32
|
-
value: string;
|
|
33
|
-
label: string;
|
|
34
|
-
}[];
|
|
35
|
-
datetime: {
|
|
36
|
-
value: string;
|
|
37
|
-
label: string;
|
|
38
|
-
}[];
|
|
39
|
-
time: {
|
|
40
|
-
value: string;
|
|
41
|
-
label: string;
|
|
42
|
-
}[];
|
|
43
|
-
};
|
|
44
18
|
export declare const patternsColumnTypes: string[];
|
|
45
|
-
export declare const validateColumn: <T extends "string" | "boolean" | "time" | "integer" | "float" | "email" | "
|
|
19
|
+
export declare const validateColumn: <T extends "string" | "boolean" | "time" | "integer" | "float" | "email" | "url" | "enum" | "date" | "datetime">(columnData: ColumnRequiredProps<T>) => Promise<void>;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import * as yup from "yup";
|
|
47
|
+
import { FieldTypes, mutableValidationTypes, mutableTransformationTypes, } from "../types";
|
|
48
|
+
import { allowedPatterns, datePatterns, dateTimePatterns, timePatterns, } from "./datePatterns";
|
|
49
|
+
var commonValidations = [
|
|
50
|
+
{
|
|
51
|
+
value: "regex",
|
|
52
|
+
label: "Must Match Regex",
|
|
53
|
+
options: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
key: "pattern",
|
|
57
|
+
tooltip: "Regex Pattern",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
var uniqueValidation = [
|
|
63
|
+
{ value: "unique_case_sensitive", label: "Must be Unique (case sensitive)" },
|
|
64
|
+
{
|
|
65
|
+
value: "unique_case_insensitive",
|
|
66
|
+
label: "Must be Unique (case insensitive)",
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
var containsValidations = [
|
|
70
|
+
{
|
|
71
|
+
value: "cannot_contain",
|
|
72
|
+
label: "Cannot Contain",
|
|
73
|
+
options: [
|
|
74
|
+
{
|
|
75
|
+
type: "text",
|
|
76
|
+
key: "pattern",
|
|
77
|
+
tooltip: "It must be a word that you want to exclude",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: "contain",
|
|
83
|
+
label: "Must Contain",
|
|
84
|
+
options: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
key: "pattern",
|
|
88
|
+
tooltip: "It must be a word to be included mandatorily",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
var stringValidations = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], containsValidations, true), [
|
|
94
|
+
{
|
|
95
|
+
value: "max_length",
|
|
96
|
+
label: "Length (shorter than)",
|
|
97
|
+
options: [
|
|
98
|
+
{
|
|
99
|
+
type: "number",
|
|
100
|
+
key: "max_length",
|
|
101
|
+
tooltip: "Number of characters",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "min_length",
|
|
107
|
+
label: "Length (longer than)",
|
|
108
|
+
options: [
|
|
109
|
+
{
|
|
110
|
+
type: "number",
|
|
111
|
+
key: "min_length",
|
|
112
|
+
tooltip: "Number of characters",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
value: "length_exactly",
|
|
118
|
+
label: "Length (exactly)",
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
type: "number",
|
|
122
|
+
key: "length",
|
|
123
|
+
tooltip: "Number of characters",
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
}
|
|
127
|
+
], false), uniqueValidation, true), commonValidations, true);
|
|
128
|
+
var numericValidations = __spreadArray(__spreadArray([
|
|
129
|
+
{
|
|
130
|
+
value: "less_than",
|
|
131
|
+
label: "Must Be Less Than",
|
|
132
|
+
options: [
|
|
133
|
+
{
|
|
134
|
+
type: "number",
|
|
135
|
+
key: "max",
|
|
136
|
+
tooltip: "The max allowed value",
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: "greater_than",
|
|
142
|
+
label: "Must Be Greater Than",
|
|
143
|
+
options: [
|
|
144
|
+
{
|
|
145
|
+
type: "number",
|
|
146
|
+
key: "min",
|
|
147
|
+
tooltip: "The minimum allowed value",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{ value: "even", label: "Must be Even" },
|
|
152
|
+
{ value: "odd", label: "Must be Odd" }
|
|
153
|
+
], uniqueValidation, true), commonValidations, true);
|
|
154
|
+
var emailValidations = __spreadArray([
|
|
155
|
+
{ value: "email", label: "Must be an email", isDefaultValidation: true }
|
|
156
|
+
], stringValidations, true);
|
|
157
|
+
var urlValidations = __spreadArray([
|
|
158
|
+
{ value: "url", label: "Must be a URL", isDefaultValidation: true }
|
|
159
|
+
], stringValidations, true);
|
|
160
|
+
var booleanValidations = [
|
|
161
|
+
{
|
|
162
|
+
value: "boolean",
|
|
163
|
+
label: "Must be True or False",
|
|
164
|
+
isDefaultValidation: true,
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
var structuredDataValidations = __spreadArray([], uniqueValidation, true);
|
|
168
|
+
var dateValidations = __spreadArray(__spreadArray([], uniqueValidation, true), [
|
|
169
|
+
{
|
|
170
|
+
value: "before_date",
|
|
171
|
+
label: "Must Be Before Date",
|
|
172
|
+
options: [
|
|
173
|
+
{
|
|
174
|
+
type: "date",
|
|
175
|
+
key: "max",
|
|
176
|
+
tooltip: "The maximum allowed date",
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
value: "after_date",
|
|
182
|
+
label: "Must Be After Date",
|
|
183
|
+
options: [
|
|
184
|
+
{
|
|
185
|
+
type: "date",
|
|
186
|
+
key: "min",
|
|
187
|
+
tooltip: "The minimum allowed date",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
], false);
|
|
192
|
+
export var validationsByColumnType = {
|
|
193
|
+
string: stringValidations,
|
|
194
|
+
integer: __spreadArray([
|
|
195
|
+
{
|
|
196
|
+
value: "integer",
|
|
197
|
+
label: "Must be an integer",
|
|
198
|
+
isDefaultValidation: true,
|
|
199
|
+
}
|
|
200
|
+
], numericValidations, true),
|
|
201
|
+
float: __spreadArray([
|
|
202
|
+
{
|
|
203
|
+
value: "float",
|
|
204
|
+
label: "Must be a float",
|
|
205
|
+
isDefaultValidation: true,
|
|
206
|
+
}
|
|
207
|
+
], numericValidations, true),
|
|
208
|
+
email: emailValidations,
|
|
209
|
+
enum: structuredDataValidations,
|
|
210
|
+
url: urlValidations,
|
|
211
|
+
boolean: booleanValidations,
|
|
212
|
+
date: dateValidations,
|
|
213
|
+
datetime: dateValidations,
|
|
214
|
+
time: uniqueValidation,
|
|
215
|
+
};
|
|
216
|
+
export var validationsByType = Object.values(validationsByColumnType)
|
|
217
|
+
.reduce(function (acc, arr) { return acc.concat(arr); }, [])
|
|
218
|
+
.reduce(function (result, p) {
|
|
219
|
+
result[p.value] = p;
|
|
220
|
+
return result;
|
|
221
|
+
}, {});
|
|
222
|
+
export var availableColumnTypes = Object.keys(validationsByColumnType);
|
|
223
|
+
export var patternsColumnTypes = Object.keys(allowedPatterns);
|
|
224
|
+
var iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
225
|
+
var validationsSchema = yup
|
|
226
|
+
.mixed()
|
|
227
|
+
.test("validations", "Invalid validations", function (value) {
|
|
228
|
+
var isAnArray = Array.isArray(value);
|
|
229
|
+
if (isAnArray) {
|
|
230
|
+
for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
|
|
231
|
+
var validation = value_1[_i];
|
|
232
|
+
var validation_type = validation.validation_type, options = validation.options;
|
|
233
|
+
var optionsPropertyIsNotRequiredFor = [
|
|
234
|
+
"unique_case_insensitive",
|
|
235
|
+
"unique_case_sensitive",
|
|
236
|
+
"integer",
|
|
237
|
+
"boolean",
|
|
238
|
+
"odd",
|
|
239
|
+
"even",
|
|
240
|
+
"email",
|
|
241
|
+
"url",
|
|
242
|
+
"float",
|
|
243
|
+
];
|
|
244
|
+
if (mutableValidationTypes.includes(validation_type)) {
|
|
245
|
+
if (optionsPropertyIsNotRequiredFor.includes(validation_type)) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (!options) {
|
|
249
|
+
return this.createError({
|
|
250
|
+
path: "validations",
|
|
251
|
+
message: "Options is required for this validation type",
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
var min = options.min, max = options.max;
|
|
255
|
+
var minOptionDoesNotMatchISO = min && !min.match(iso8601Regex);
|
|
256
|
+
var maxOptionDoesNotMatchISO = max && !max.match(iso8601Regex);
|
|
257
|
+
if (minOptionDoesNotMatchISO || maxOptionDoesNotMatchISO) {
|
|
258
|
+
return this.createError({
|
|
259
|
+
path: "validations",
|
|
260
|
+
message: "Invalid ISO 8601 format for min or max",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
return this.createError({
|
|
266
|
+
path: "validations",
|
|
267
|
+
message: "".concat(validation_type, " is not a valid validation type. Please check the values you inserted."),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
var arrayIsNotDefined = !["undefined", "null"].includes(typeof value);
|
|
274
|
+
if (arrayIsNotDefined && !isAnArray) {
|
|
275
|
+
return this.createError({
|
|
276
|
+
path: "validations",
|
|
277
|
+
message: "Validations must be an array",
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return true;
|
|
281
|
+
});
|
|
282
|
+
var transformationsOptionsPropIsRequiredFor = [
|
|
283
|
+
"prefix",
|
|
284
|
+
"number_of_decimals",
|
|
285
|
+
];
|
|
286
|
+
var transformationsSchema = yup
|
|
287
|
+
.array()
|
|
288
|
+
.of(yup.object().shape({
|
|
289
|
+
transformation_type: yup
|
|
290
|
+
.string()
|
|
291
|
+
.oneOf(mutableTransformationTypes)
|
|
292
|
+
.required(),
|
|
293
|
+
options: yup.mixed().when("transformation_type", {
|
|
294
|
+
is: function (type) {
|
|
295
|
+
return transformationsOptionsPropIsRequiredFor.includes(type);
|
|
296
|
+
},
|
|
297
|
+
then: yup
|
|
298
|
+
.object()
|
|
299
|
+
.required("Options is required for this transformation type"),
|
|
300
|
+
}),
|
|
301
|
+
}))
|
|
302
|
+
.test("transformations", "Invalid transformations", function (value, context) {
|
|
303
|
+
var isAnArray = Array.isArray(value);
|
|
304
|
+
if (isAnArray) {
|
|
305
|
+
for (var _i = 0, value_2 = value; _i < value_2.length; _i++) {
|
|
306
|
+
var transformation = value_2[_i];
|
|
307
|
+
var transformation_type = transformation.transformation_type;
|
|
308
|
+
// if user is selecting autoformat (for date, datetime and time) but has not
|
|
309
|
+
// defined pattern, it should throw an error
|
|
310
|
+
if (transformation_type === "autoformat") {
|
|
311
|
+
var parentRecord = context.parent;
|
|
312
|
+
if (!(parentRecord === null || parentRecord === void 0 ? void 0 : parentRecord.pattern)) {
|
|
313
|
+
var columnType = parentRecord.column_type;
|
|
314
|
+
var availablePatternsForColumnType = null;
|
|
315
|
+
var getAvailablePatterns = function (patterns) {
|
|
316
|
+
var patternValues = patterns.map(function (pattern) { return pattern.value; });
|
|
317
|
+
return patternValues.join(", ");
|
|
318
|
+
};
|
|
319
|
+
switch (columnType) {
|
|
320
|
+
case "date":
|
|
321
|
+
availablePatternsForColumnType = getAvailablePatterns(datePatterns);
|
|
322
|
+
break;
|
|
323
|
+
case "datetime":
|
|
324
|
+
availablePatternsForColumnType = getAvailablePatterns(dateTimePatterns);
|
|
325
|
+
break;
|
|
326
|
+
case "time":
|
|
327
|
+
availablePatternsForColumnType = getAvailablePatterns(timePatterns);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
return this.createError({
|
|
331
|
+
path: "transformations",
|
|
332
|
+
message: "The selected transformation type requires you to specify a pattern to your column. Available patterns for your column_type: ".concat(availablePatternsForColumnType),
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (!mutableTransformationTypes.includes(transformation_type)) {
|
|
337
|
+
return this.createError({
|
|
338
|
+
path: "transformations",
|
|
339
|
+
message: "".concat(transformation_type, " is not a valid transformation type. Please check the values you inserted."),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
var arrayIsNotDefined = !["undefined", "null"].includes(typeof value);
|
|
346
|
+
if (arrayIsNotDefined && !isAnArray) {
|
|
347
|
+
return this.createError({
|
|
348
|
+
path: "validations",
|
|
349
|
+
message: "Validations must be an array",
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
return true;
|
|
353
|
+
});
|
|
354
|
+
var columnSchema = yup.object().shape({
|
|
355
|
+
column_type: yup.string().oneOf(availableColumnTypes).required(),
|
|
356
|
+
internal_key: yup.string().required(),
|
|
357
|
+
label: yup.string().required(),
|
|
358
|
+
required: yup.boolean().required(),
|
|
359
|
+
validations: validationsSchema,
|
|
360
|
+
transformations: transformationsSchema,
|
|
361
|
+
});
|
|
362
|
+
var dateColumnSchema = columnSchema.shape({
|
|
363
|
+
pattern: yup.string().oneOf(datePatterns.map(function (p) { return p.value; })),
|
|
364
|
+
});
|
|
365
|
+
var dateTimeColumnSchema = columnSchema.shape({
|
|
366
|
+
pattern: yup.string().oneOf(dateTimePatterns.map(function (p) { return p.value; })),
|
|
367
|
+
});
|
|
368
|
+
var timeColumnSchema = columnSchema.shape({
|
|
369
|
+
pattern: yup.string().oneOf(timePatterns.map(function (p) { return p.value; })),
|
|
370
|
+
});
|
|
371
|
+
var enumColumnSchema = columnSchema.shape({
|
|
372
|
+
values: yup.array().of(yup.string()).min(1).required(),
|
|
373
|
+
});
|
|
374
|
+
export var validateColumn = function (columnData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
375
|
+
var schema, error_1;
|
|
376
|
+
return __generator(this, function (_a) {
|
|
377
|
+
switch (_a.label) {
|
|
378
|
+
case 0:
|
|
379
|
+
schema = columnData.column_type === FieldTypes.date
|
|
380
|
+
? dateColumnSchema
|
|
381
|
+
: columnData.column_type === FieldTypes.datetime
|
|
382
|
+
? dateTimeColumnSchema
|
|
383
|
+
: columnData.column_type === FieldTypes.time
|
|
384
|
+
? timeColumnSchema
|
|
385
|
+
: columnData.column_type === FieldTypes.enum
|
|
386
|
+
? enumColumnSchema
|
|
387
|
+
: columnSchema;
|
|
388
|
+
_a.label = 1;
|
|
389
|
+
case 1:
|
|
390
|
+
_a.trys.push([1, 3, , 4]);
|
|
391
|
+
return [4 /*yield*/, schema.validate(columnData, { abortEarly: true })];
|
|
392
|
+
case 2:
|
|
393
|
+
_a.sent();
|
|
394
|
+
return [3 /*break*/, 4];
|
|
395
|
+
case 3:
|
|
396
|
+
error_1 = _a.sent();
|
|
397
|
+
throw new Error("Error on custom column creation: ".concat(error_1.message));
|
|
398
|
+
case 4: return [2 /*return*/];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}); };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const datePatterns: {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}[];
|
|
5
|
+
export declare const dateTimePatterns: {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const timePatterns: {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const allowedPatterns: {
|
|
14
|
+
date: {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
datetime: {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
time: {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|