@arquimedes.co/eureka-forms 0.2.29 → 0.2.34-test
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/dist/App.d.ts +5 -1
- package/dist/App.js +4 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +24 -4
- package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +1 -1
- package/dist/FormComponents/Form/Form.d.ts +2 -0
- package/dist/FormComponents/Form/Form.js +17 -1
- package/dist/FormComponents/Section/Section.d.ts +2 -0
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -3
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +7 -5
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +53 -40
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +10 -2
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +7 -4
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +165 -74
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +9 -1
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +3 -3
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +4 -2
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +1 -1
- package/dist/constants/Files/FileExtensions.js +3 -0
- package/dist/controllers/FileService.d.ts +1 -1
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +11 -4
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -19,12 +19,16 @@ export interface AppProps {
|
|
|
19
19
|
valuesData?: Record<string, unknown>;
|
|
20
20
|
/** Custom steps to display */
|
|
21
21
|
customSteps?: Record<string, CustomStep>;
|
|
22
|
+
/** Function to call on postview to fetch the download url of a file */
|
|
23
|
+
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
24
|
+
/** Function to call after the confimation dialog has been closed */
|
|
25
|
+
handleConfirmed?: Function;
|
|
22
26
|
}
|
|
23
27
|
export interface CustomStep {
|
|
24
28
|
component: ReactNode;
|
|
25
29
|
updateValue: (idStep: string, values: Record<string, any>, form: Form) => void;
|
|
26
30
|
}
|
|
27
|
-
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, ...others }: AppProps): JSX.Element;
|
|
31
|
+
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
28
32
|
export default App;
|
|
29
33
|
export declare enum SIZES {
|
|
30
34
|
SMALL = "SMALL",
|
package/dist/App.js
CHANGED
|
@@ -67,7 +67,7 @@ import StepTypes from './constants/FormStepTypes';
|
|
|
67
67
|
import axiosInstance from './AxiosAPI';
|
|
68
68
|
function App(_a) {
|
|
69
69
|
var _this = this;
|
|
70
|
-
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps"]);
|
|
70
|
+
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps", "handleConfirmed"]);
|
|
71
71
|
var _b = useState(undefined), form = _b[0], setForm = _b[1];
|
|
72
72
|
var _c = useState({}), originalValues = _c[0], setOriginalValues = _c[1];
|
|
73
73
|
var _d = useState(undefined), organizationInfo = _d[0], setOrganizationInfo = _d[1];
|
|
@@ -211,6 +211,9 @@ function App(_a) {
|
|
|
211
211
|
setTimeout(function () {
|
|
212
212
|
setForm(tempForm);
|
|
213
213
|
}, 100);
|
|
214
|
+
if (handleConfirmed) {
|
|
215
|
+
handleConfirmed();
|
|
216
|
+
}
|
|
214
217
|
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
|
|
215
218
|
}
|
|
216
219
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormComponentProps } from '../Form';
|
|
3
|
-
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, }: FormComponentProps): JSX.Element;
|
|
3
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
4
4
|
export default ColumnForm;
|
|
@@ -45,6 +45,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
48
59
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
60
|
import { useEffect, useState } from 'react';
|
|
50
61
|
import SectionComponent from '../../Section/Section';
|
|
@@ -59,7 +70,7 @@ import axios from 'axios';
|
|
|
59
70
|
import axiosInstance from '../../../AxiosAPI';
|
|
60
71
|
function ColumnForm(_a) {
|
|
61
72
|
var _this = this;
|
|
62
|
-
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues;
|
|
73
|
+
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "originalValues"]);
|
|
63
74
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
64
75
|
var _c = useForm({
|
|
65
76
|
defaultValues: mapOriginal(originalValues, form),
|
|
@@ -83,10 +94,11 @@ function ColumnForm(_a) {
|
|
|
83
94
|
switch (_c.label) {
|
|
84
95
|
case 0:
|
|
85
96
|
if (!(apiKey || internal)) return [3 /*break*/, 8];
|
|
86
|
-
return [4 /*yield*/, trigger()];
|
|
97
|
+
return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
87
98
|
case 1:
|
|
88
99
|
valid = _c.sent();
|
|
89
100
|
values = getValues();
|
|
101
|
+
console.log(values);
|
|
90
102
|
if (!!valid) return [3 /*break*/, 2];
|
|
91
103
|
console.log('ERRORS:', errors);
|
|
92
104
|
setTempError(true);
|
|
@@ -101,8 +113,8 @@ function ColumnForm(_a) {
|
|
|
101
113
|
idStep = _a[_i];
|
|
102
114
|
updateValue(idStep, values, form, customSteps);
|
|
103
115
|
}
|
|
116
|
+
console.log('UPDATED:', values);
|
|
104
117
|
url = "https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/ticket?apiKey=" + (internal ? form.apiKey : apiKey) + "&domain=" + domain;
|
|
105
|
-
console.log(values);
|
|
106
118
|
payload = {
|
|
107
119
|
formValues: { steps: values },
|
|
108
120
|
};
|
|
@@ -133,7 +145,7 @@ function ColumnForm(_a) {
|
|
|
133
145
|
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }, void 0), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
|
|
134
146
|
reload();
|
|
135
147
|
setShowConfirmation(undefined);
|
|
136
|
-
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, { form: form, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps }, index)); }), form.terms &&
|
|
148
|
+
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps }, others), index)); }), form.terms &&
|
|
137
149
|
!internal &&
|
|
138
150
|
form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }), !postview && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "login__submit", className: styles.submitBtn, onClick: function () {
|
|
139
151
|
onSubmit();
|
|
@@ -201,6 +213,14 @@ var updateValue = function (idStep, values, form, customSteps) {
|
|
|
201
213
|
}
|
|
202
214
|
break;
|
|
203
215
|
}
|
|
216
|
+
case Types.FILEUPLOAD: {
|
|
217
|
+
var value = values[step.id];
|
|
218
|
+
values[step.id] = value.map(function (val) { return ({
|
|
219
|
+
fileName: val.fileName,
|
|
220
|
+
S3Key: val.S3Key,
|
|
221
|
+
}); });
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
204
224
|
default:
|
|
205
225
|
var custom = customSteps[idStep];
|
|
206
226
|
if (custom !== undefined) {
|
|
@@ -17,6 +17,8 @@ export interface FormComponentProps {
|
|
|
17
17
|
formStyle: FormStyle;
|
|
18
18
|
domain?: string;
|
|
19
19
|
apiKey: string | undefined;
|
|
20
|
+
/** Function to call on postview to fetch the download url of a file */
|
|
21
|
+
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
20
22
|
}
|
|
21
23
|
declare function FormComponent({ form, internal, postview, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle'> & {
|
|
22
24
|
containerRef: any;
|
|
@@ -32,6 +32,21 @@ import DateFnsUtils from '@date-io/date-fns';
|
|
|
32
32
|
import { createGenerateClassName, createTheme, StylesProvider, ThemeProvider, } from '@material-ui/core';
|
|
33
33
|
import { SEED } from '../../constants/MaterialClassNameSeed';
|
|
34
34
|
import InternalFormStyle from '../../constants/InternalFormStyle';
|
|
35
|
+
import enLocale from 'date-fns/locale/en-US';
|
|
36
|
+
import esLocale from 'date-fns/locale/es';
|
|
37
|
+
var localeMap = {
|
|
38
|
+
en: enLocale,
|
|
39
|
+
'en-US': enLocale,
|
|
40
|
+
es: esLocale,
|
|
41
|
+
};
|
|
42
|
+
var getNavigatorLanguage = function () {
|
|
43
|
+
return navigator.languages && navigator.languages.length
|
|
44
|
+
? navigator.languages[0]
|
|
45
|
+
: navigator.userLanguage ||
|
|
46
|
+
navigator.language ||
|
|
47
|
+
navigator.browserLanguage ||
|
|
48
|
+
'es';
|
|
49
|
+
};
|
|
35
50
|
var blockSize = 210;
|
|
36
51
|
var spacingSize = 20;
|
|
37
52
|
var blockNum = 4;
|
|
@@ -93,6 +108,7 @@ var generateClassName = createGenerateClassName({
|
|
|
93
108
|
productionPrefix: 'efjss',
|
|
94
109
|
});
|
|
95
110
|
function FormTypeComponent(_a) {
|
|
111
|
+
var _b;
|
|
96
112
|
var props = __rest(_a, []);
|
|
97
113
|
var renderTypes = function () {
|
|
98
114
|
switch (props.form.type) {
|
|
@@ -109,7 +125,7 @@ function FormTypeComponent(_a) {
|
|
|
109
125
|
};
|
|
110
126
|
switch (props.formStyle.type) {
|
|
111
127
|
case FormStyleTypes.MATERIAL:
|
|
112
|
-
return (_jsx(StylesProvider, __assign({ generateClassName: generateClassName }, { children: _jsx(ThemeProvider, __assign({ theme: muiTheme }, { children: _jsx(MuiPickersUtilsProvider, __assign({ utils: DateFnsUtils }, { children: renderTypes() }), void 0) }), void 0) }), void 0));
|
|
128
|
+
return (_jsx(StylesProvider, __assign({ generateClassName: generateClassName }, { children: _jsx(ThemeProvider, __assign({ theme: muiTheme }, { children: _jsx(MuiPickersUtilsProvider, __assign({ utils: DateFnsUtils, locale: (_b = localeMap[getNavigatorLanguage()]) !== null && _b !== void 0 ? _b : localeMap.es }, { children: renderTypes() }), void 0) }), void 0) }), void 0));
|
|
113
129
|
default:
|
|
114
130
|
return renderTypes();
|
|
115
131
|
}
|
|
@@ -15,6 +15,8 @@ export interface RecursiveData {
|
|
|
15
15
|
getValues: UseFormGetValues<FieldValues>;
|
|
16
16
|
originalValues: Record<string, any>;
|
|
17
17
|
customSteps: Record<string, CustomStep>;
|
|
18
|
+
/** Function to call on postview to fetch the download url of a file */
|
|
19
|
+
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
18
20
|
}
|
|
19
21
|
export interface SectionComponentProps extends RecursiveData {
|
|
20
22
|
section: Section;
|
|
@@ -31,7 +31,7 @@ import StepComponent from '../../Step';
|
|
|
31
31
|
import { Controller } from 'react-hook-form';
|
|
32
32
|
import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
|
|
33
33
|
function ClassifierSelector(_a) {
|
|
34
|
-
var step = _a.step, form = _a.form, level = _a.level, errors = _a.errors, value = _a.value, onBlur = _a.onBlur, control = _a.control, onChange = _a.onChange, postview = _a.postview, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "errors", "value", "onBlur", "control", "onChange", "postview", "formStyle", "getValues", "widthStats", "handleSizeChange"]);
|
|
34
|
+
var step = _a.step, form = _a.form, level = _a.level, errors = _a.errors, value = _a.value, onBlur = _a.onBlur, control = _a.control, onChange = _a.onChange, postview = _a.postview, inputRef = _a.inputRef, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "errors", "value", "onBlur", "control", "onChange", "postview", "inputRef", "formStyle", "getValues", "widthStats", "handleSizeChange"]);
|
|
35
35
|
var _b = useState(level === 0 ? calcFillerSize(step, form.steps, getValues(), form) : 0), fillerSize = _b[0], setFillerSize = _b[1];
|
|
36
36
|
if (!step.idClassifier) {
|
|
37
37
|
return _jsx("div", {}, void 0);
|
|
@@ -56,7 +56,7 @@ function ClassifierSelector(_a) {
|
|
|
56
56
|
} }, { children: _jsxs(RoundedSelect, __assign({ fullWidth: true, value: value, cantEdit: postview, errorColor: formStyle.errorColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, label: step.label ? step.label : classifier.name, required: step.required, containerMargin: "0px", height: '31px', onBlur: onBlur, handleUpdate: function (event) {
|
|
57
57
|
onChange(event.target.value);
|
|
58
58
|
sizeChange();
|
|
59
|
-
}, helperText: errors[step.id]
|
|
59
|
+
}, inputRef: inputRef, helperText: errors[step.id]
|
|
60
60
|
? errors[step.id].message
|
|
61
61
|
: step.description, error: !!errors[step.id] }, { children: [_jsx(MenuItem, __assign({ value: '' }, { children: _jsx("em", { children: "Sin Seleccionar" }, void 0) }), 'EMPTY'), classifier.children
|
|
62
62
|
.filter(function (classifier) {
|
|
@@ -100,6 +100,6 @@ function ClassifierSelectorStep(props) {
|
|
|
100
100
|
: undefined,
|
|
101
101
|
}, shouldUnregister: true, render: function (_a) {
|
|
102
102
|
var field = _a.field;
|
|
103
|
-
return (_jsx(ClassifierSelector, __assign({}, props, { value: field.value, onChange: field.onChange, onBlur: field.onBlur }), void 0));
|
|
103
|
+
return (_jsx(ClassifierSelector, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur }), void 0));
|
|
104
104
|
} }, void 0));
|
|
105
105
|
}
|
package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js
CHANGED
|
@@ -27,7 +27,7 @@ function DatePickerStep(_a) {
|
|
|
27
27
|
: undefined,
|
|
28
28
|
}, shouldUnregister: true, render: function (_a) {
|
|
29
29
|
var field = _a.field;
|
|
30
|
-
return (_jsx(RoundedDatePicker, __assign({}, field, { showIcon: step.showIcon, cantEdit: postview, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, fontWeight: 400, label: step.label, helperText: errors[step.id]
|
|
30
|
+
return (_jsx(RoundedDatePicker, __assign({}, field, { showIcon: step.showIcon, inputRef: field.ref, cantEdit: postview, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, fontWeight: 400, label: step.label, helperText: errors[step.id]
|
|
31
31
|
? errors[step.id].message
|
|
32
32
|
: step.description, error: !!errors[step.id], required: step.required }), void 0));
|
|
33
33
|
} }, void 0) }), void 0));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { FileObject, UploadedFileObject } from '../MaterialFileUploadStep';
|
|
3
3
|
import { FormStyle } from '../../../../../@Types/Form';
|
|
4
4
|
interface FileComponentProps {
|
|
5
|
-
|
|
6
|
-
handleUploaded: Function;
|
|
7
|
-
handleRemoveUploaded: Function;
|
|
5
|
+
file: FileObject | UploadedFileObject;
|
|
8
6
|
formStyle: FormStyle;
|
|
7
|
+
error: boolean;
|
|
8
|
+
handleRemove: Function;
|
|
9
|
+
/** Function to call on postview to fetch the download url of a file */
|
|
10
|
+
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
9
11
|
}
|
|
10
|
-
declare function FileUploadComponent({
|
|
12
|
+
declare function FileUploadComponent({ file, formStyle, error, handleRemove, fetchDownloadUrl, }: FileComponentProps): JSX.Element;
|
|
11
13
|
export default FileUploadComponent;
|
|
@@ -46,65 +46,78 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
-
import { useEffect, useState } from 'react';
|
|
50
|
-
import { postFile } from '../../../../../controllers/FileService';
|
|
51
49
|
import styles from './FileComponent.module.css';
|
|
52
50
|
import ClearRoundedIcon from '@material-ui/icons/ClearRounded';
|
|
53
51
|
import DescriptionRoundedIcon from '@material-ui/icons/DescriptionRounded';
|
|
52
|
+
import ErrorRoundedIcon from '@material-ui/icons/ErrorRounded';
|
|
54
53
|
import Loader from '../../../../../shared/Loader/Loader';
|
|
55
|
-
|
|
56
|
-
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
57
|
-
};
|
|
54
|
+
import { useState } from 'react';
|
|
58
55
|
function FileUploadComponent(_a) {
|
|
59
56
|
var _this = this;
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
|
|
57
|
+
var _b, _c;
|
|
58
|
+
var file = _a.file, formStyle = _a.formStyle, error = _a.error, handleRemove = _a.handleRemove, fetchDownloadUrl = _a.fetchDownloadUrl;
|
|
59
|
+
var _d = useState(false), downloading = _d[0], setDownloading = _d[1];
|
|
60
|
+
if (!file) {
|
|
61
|
+
return _jsx("div", {}, void 0);
|
|
62
|
+
}
|
|
63
|
+
var downloadFile = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
+
var fileUrl, a, error_1;
|
|
64
65
|
return __generator(this, function (_a) {
|
|
65
66
|
switch (_a.label) {
|
|
66
67
|
case 0:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return [4 /*yield*/, Promise.all([
|
|
70
|
-
postFile(file.file, file.postInfo),
|
|
71
|
-
timeout(1000),
|
|
72
|
-
])];
|
|
68
|
+
if (!(fetchDownloadUrl && file.S3Key && file.fileName)) return [3 /*break*/, 4];
|
|
69
|
+
_a.label = 1;
|
|
73
70
|
case 1:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return [3 /*break*/, 3];
|
|
71
|
+
_a.trys.push([1, 3, , 4]);
|
|
72
|
+
setDownloading(true);
|
|
73
|
+
return [4 /*yield*/, fetchDownloadUrl(file.S3Key, file.fileName)];
|
|
78
74
|
case 2:
|
|
75
|
+
fileUrl = _a.sent();
|
|
76
|
+
a = document.createElement('a');
|
|
77
|
+
a.href = fileUrl;
|
|
78
|
+
a.setAttribute('download', file.fileName);
|
|
79
|
+
a.click();
|
|
80
|
+
setDownloading(false);
|
|
81
|
+
return [3 /*break*/, 4];
|
|
82
|
+
case 3:
|
|
79
83
|
error_1 = _a.sent();
|
|
80
84
|
console.error(error_1);
|
|
81
|
-
return [3 /*break*/,
|
|
82
|
-
case
|
|
85
|
+
return [3 /*break*/, 4];
|
|
86
|
+
case 4: return [2 /*return*/];
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
}); };
|
|
86
|
-
useEffect(function () {
|
|
87
|
-
if (fileInfo.loading === 'TRY_UPLOADING' && !file) {
|
|
88
|
-
uploadFile(fileInfo);
|
|
89
|
-
}
|
|
90
|
-
}, [fileInfo]);
|
|
91
90
|
var calcIcon = function () {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
if (downloading) {
|
|
92
|
+
return (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { size: 26, color: formStyle.primaryColor }, void 0) }), void 0));
|
|
93
|
+
}
|
|
94
|
+
else if (file.state !== undefined) {
|
|
95
|
+
switch (file.state) {
|
|
96
|
+
case 'STARTING':
|
|
97
|
+
case 'UPLOADING':
|
|
98
|
+
return (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { size: 26, color: formStyle.primaryColor }, void 0) }), void 0));
|
|
99
|
+
case 'DONE':
|
|
100
|
+
return (_jsx("div", __assign({ className: styles.documentIcon, style: { color: formStyle.primaryColor } }, { children: _jsx(DescriptionRoundedIcon, {}, void 0) }), void 0));
|
|
101
|
+
case 'ERROR':
|
|
102
|
+
return (_jsx("div", __assign({ className: styles.documentIcon, style: { color: formStyle.errorColor } }, { children: _jsx(ErrorRoundedIcon, {}, void 0) }), void 0));
|
|
103
|
+
default:
|
|
104
|
+
return _jsx("div", {}, void 0);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return (_jsx("div", __assign({ className: styles.documentIcon, style: { color: formStyle.primaryColor } }, { children: _jsx(DescriptionRoundedIcon, {}, void 0) }), void 0));
|
|
102
109
|
}
|
|
103
110
|
};
|
|
104
|
-
return (_jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.iconContainer }, { children: calcIcon() }), void 0), _jsx("div", __assign({ className:
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
return (_jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.iconContainer }, { children: calcIcon() }), void 0), _jsx("div", __assign({ className: fetchDownloadUrl && file.S3Key
|
|
112
|
+
? styles.downloadableLbl
|
|
113
|
+
: styles.label, style: {
|
|
114
|
+
color: error ? formStyle.errorColor : formStyle.textColor,
|
|
115
|
+
}, onClick: function () {
|
|
116
|
+
if (fetchDownloadUrl !== undefined && file.S3Key) {
|
|
117
|
+
downloadFile();
|
|
107
118
|
}
|
|
108
|
-
} }, { children:
|
|
119
|
+
} }, { children: (_c = (_b = file.file) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : file.fileName }), void 0), _jsx("div", __assign({ className: styles.deletBtn, onClick: function () {
|
|
120
|
+
handleRemove();
|
|
121
|
+
} }, { children: file.state !== undefined && (_jsx(ClearRoundedIcon, { fontSize: "inherit" }, void 0)) }), void 0)] }), void 0));
|
|
109
122
|
}
|
|
110
123
|
export default FileUploadComponent;
|
|
@@ -14,14 +14,21 @@
|
|
|
14
14
|
height: 30px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.label
|
|
17
|
+
.label,
|
|
18
|
+
.downloadableLbl {
|
|
18
19
|
font-size: 1rem;
|
|
19
20
|
margin-left: 2px;
|
|
20
21
|
cursor: default;
|
|
21
22
|
white-space: nowrap;
|
|
22
23
|
overflow: hidden;
|
|
23
24
|
text-overflow: ellipsis;
|
|
24
|
-
max-width: calc(100% -
|
|
25
|
+
max-width: calc(100% - 80px);
|
|
26
|
+
}
|
|
27
|
+
.downloadableLbl {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
.downloadableLbl:hover {
|
|
31
|
+
text-decoration: underline;
|
|
25
32
|
}
|
|
26
33
|
.deletBtn {
|
|
27
34
|
font-size: 26px;
|
|
@@ -46,6 +53,7 @@
|
|
|
46
53
|
.iconContainer {
|
|
47
54
|
height: 30px;
|
|
48
55
|
width: 30px;
|
|
56
|
+
margin-left: 10px;
|
|
49
57
|
display: flex;
|
|
50
58
|
align-items: center;
|
|
51
59
|
justify-content: center;
|
package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FileUploadStepProps } from '../FileUploadStep';
|
|
3
|
-
export interface
|
|
4
|
-
|
|
3
|
+
export interface FileObject {
|
|
4
|
+
state: 'STARTING' | 'UPLOADING' | 'DONE' | 'CANCEL' | 'ERROR';
|
|
5
5
|
file: File;
|
|
6
|
-
postInfo
|
|
6
|
+
postInfo: any;
|
|
7
|
+
fileName?: string;
|
|
8
|
+
S3Key?: string;
|
|
9
|
+
error?: boolean;
|
|
7
10
|
}
|
|
8
|
-
export interface
|
|
11
|
+
export interface UploadedFileObject {
|
|
9
12
|
fileName: string;
|
|
10
13
|
S3Key: string;
|
|
11
14
|
}
|
package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js
CHANGED
|
@@ -60,106 +60,197 @@ import { Controller } from 'react-hook-form';
|
|
|
60
60
|
import RoundedButton from '../../../../shared/RoundedButton/RoundedButton';
|
|
61
61
|
import { useEffect, useRef, useState } from 'react';
|
|
62
62
|
import { getAcceptedExtensions } from '../../../../constants/Files/FileExtensions';
|
|
63
|
-
import
|
|
64
|
-
import { getUploadUrls } from '../../../../controllers/FileService';
|
|
63
|
+
import { getUploadUrls, postFile } from '../../../../controllers/FileService';
|
|
65
64
|
import FileComponent from './FileComponent/FileComponent';
|
|
65
|
+
import maxSize from '../../../../constants/Files/FileMaxSize';
|
|
66
66
|
function FileUploadStep(_a) {
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var _c = useState(
|
|
70
|
-
var _a;
|
|
71
|
-
return ((_a = {
|
|
72
|
-
file: new File([], file.fileName),
|
|
73
|
-
loading: 'DONE',
|
|
74
|
-
}) !== null && _a !== void 0 ? _a : []);
|
|
75
|
-
})), files = _c[0], setFiles = _c[1];
|
|
76
|
-
var _d = useState(undefined), fileUploaded = _d[0], setFileUploaded = _d[1];
|
|
77
|
-
var _e = useState([]), uploadedFiles = _e[0], setUploadedFiles = _e[1];
|
|
67
|
+
var step = _a.step, errors = _a.errors, value = _a.value, domain = _a.domain, btnRef = _a.btnRef, postview = _a.postview, onChange = _a.onChange, formStyle = _a.formStyle, clearErrors = _a.clearErrors, fetchDownloadUrl = _a.fetchDownloadUrl;
|
|
68
|
+
var _b = useState(undefined), error = _b[0], setError = _b[1];
|
|
69
|
+
var _c = useState([]), fileChange = _c[0], setFileChange = _c[1];
|
|
78
70
|
var inputRef = useRef();
|
|
79
71
|
useEffect(function () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
var filesToFetchLink = [];
|
|
73
|
+
var filesChanged = [];
|
|
74
|
+
for (var _i = 0, fileChange_1 = fileChange; _i < fileChange_1.length; _i++) {
|
|
75
|
+
var file = fileChange_1[_i];
|
|
76
|
+
if (file.state === 'STARTING') {
|
|
77
|
+
filesToFetchLink.push(file);
|
|
78
|
+
}
|
|
79
|
+
if (file.state === 'UPLOADING') {
|
|
80
|
+
uploadFile(file);
|
|
81
|
+
filesChanged.push(file);
|
|
82
|
+
}
|
|
83
|
+
if (file.state === 'DONE' ||
|
|
84
|
+
file.state === 'ERROR') {
|
|
85
|
+
filesChanged.push(file);
|
|
86
|
+
}
|
|
87
|
+
if (file.state === 'CANCEL') {
|
|
88
|
+
var newValue = __spreadArray([], value, true);
|
|
89
|
+
for (var i = 0; i < value.length; i++) {
|
|
90
|
+
if (value[i].file === file.file) {
|
|
91
|
+
newValue.splice(i, 1);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
onChange(newValue);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (filesChanged.length > 0) {
|
|
99
|
+
var newValue = __spreadArray([], value, true);
|
|
100
|
+
for (var _a = 0, filesChanged_1 = filesChanged; _a < filesChanged_1.length; _a++) {
|
|
101
|
+
var file = filesChanged_1[_a];
|
|
102
|
+
for (var i = 0; i < value.length; i++) {
|
|
103
|
+
if (value[i].file === file.file) {
|
|
104
|
+
newValue[i] = file;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
onChange(newValue);
|
|
109
|
+
}
|
|
110
|
+
if (filesToFetchLink.length > 0) {
|
|
111
|
+
getLinks(filesToFetchLink);
|
|
112
|
+
onChange(__spreadArray(__spreadArray([], value, true), filesToFetchLink, true));
|
|
85
113
|
}
|
|
86
|
-
}, [
|
|
87
|
-
function
|
|
114
|
+
}, [fileChange]);
|
|
115
|
+
function getLinks(pFiles) {
|
|
88
116
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var
|
|
117
|
+
var fileLinks_1, errorsExt_1, error_1;
|
|
90
118
|
return __generator(this, function (_a) {
|
|
91
119
|
switch (_a.label) {
|
|
92
120
|
case 0:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.error('FILE IS TOO LARGE', largeFile);
|
|
96
|
-
return [3 /*break*/, 5];
|
|
121
|
+
_a.trys.push([0, 2, , 3]);
|
|
122
|
+
return [4 /*yield*/, getUploadUrls(pFiles.map(function (file) { return file.file; }), domain)];
|
|
97
123
|
case 1:
|
|
98
|
-
currentFiles = __spreadArray([], files, true);
|
|
99
|
-
setFiles(__spreadArray(__spreadArray([], files, true), pFiles.map(function (file) {
|
|
100
|
-
return ({
|
|
101
|
-
loading: 'STARTING',
|
|
102
|
-
file: file,
|
|
103
|
-
postInfo: null,
|
|
104
|
-
});
|
|
105
|
-
}), true));
|
|
106
|
-
_a.label = 2;
|
|
107
|
-
case 2:
|
|
108
|
-
_a.trys.push([2, 4, , 5]);
|
|
109
|
-
return [4 /*yield*/, getUploadUrls(pFiles, domain)];
|
|
110
|
-
case 3:
|
|
111
124
|
fileLinks_1 = _a.sent();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
file:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
errorsExt_1 = [];
|
|
126
|
+
setFileChange(pFiles.map(function (file, index) {
|
|
127
|
+
var _a;
|
|
128
|
+
if (fileLinks_1[index] === 'ERROR:INVALIDEXTENSION') {
|
|
129
|
+
errorsExt_1.push((_a = file.file.name.split('.').pop()) !== null && _a !== void 0 ? _a : '');
|
|
130
|
+
return __assign(__assign({}, file), { state: 'ERROR' });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return __assign(__assign({}, file), { state: 'UPLOADING', postInfo: fileLinks_1[index] });
|
|
134
|
+
}
|
|
135
|
+
}));
|
|
136
|
+
if (errorsExt_1.length === 1) {
|
|
137
|
+
setError('La extención .' + errorsExt_1[0] + ' no es válida');
|
|
138
|
+
}
|
|
139
|
+
else if (errorsExt_1.length > 1) {
|
|
140
|
+
setError('Las extenciónes .' +
|
|
141
|
+
errorsExt_1.join(',.') +
|
|
142
|
+
' no son válidas');
|
|
143
|
+
}
|
|
144
|
+
return [3 /*break*/, 3];
|
|
145
|
+
case 2:
|
|
121
146
|
error_1 = _a.sent();
|
|
122
|
-
console.error(
|
|
123
|
-
return [3 /*break*/,
|
|
124
|
-
case
|
|
147
|
+
console.error(error_1);
|
|
148
|
+
return [3 /*break*/, 3];
|
|
149
|
+
case 3: return [2 /*return*/];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function uploadFile(pFile) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var resp, error_2;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
_a.trys.push([0, 2, , 3]);
|
|
161
|
+
return [4 /*yield*/, Promise.all([
|
|
162
|
+
postFile(pFile.file, pFile.postInfo),
|
|
163
|
+
new Promise(function (resolve) { return setTimeout(resolve, 1000); }),
|
|
164
|
+
])];
|
|
165
|
+
case 1:
|
|
166
|
+
resp = _a.sent();
|
|
167
|
+
setFileChange([__assign(__assign(__assign({}, pFile), { state: 'DONE' }), resp[0])]);
|
|
168
|
+
return [3 /*break*/, 3];
|
|
169
|
+
case 2:
|
|
170
|
+
error_2 = _a.sent();
|
|
171
|
+
console.error(error_2);
|
|
172
|
+
return [3 /*break*/, 3];
|
|
173
|
+
case 3: return [2 /*return*/];
|
|
125
174
|
}
|
|
126
175
|
});
|
|
127
176
|
});
|
|
128
177
|
}
|
|
178
|
+
var calcErrorMsg = function () {
|
|
179
|
+
if (!!errors[step.id]) {
|
|
180
|
+
var errNum = value.filter(function (val) { return val.state === 'ERROR'; }).length;
|
|
181
|
+
if (errNum === 1) {
|
|
182
|
+
return 'Este archivo no es válido';
|
|
183
|
+
}
|
|
184
|
+
else if (errNum > 1) {
|
|
185
|
+
return 'Estos archivos no son válidos';
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
return 'Este campo es obligatorio';
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return '';
|
|
192
|
+
};
|
|
129
193
|
return (_jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label }), void 0), step.description && (_jsx("div", __assign({ className: styles.stepDescriptionLabel }, { children: step.description }), void 0)), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: function (e) {
|
|
130
194
|
var files = e.target.files;
|
|
131
195
|
if (files) {
|
|
132
196
|
var filesArray = Array.from(files);
|
|
133
|
-
|
|
197
|
+
var maxFiles = filesArray.filter(function (file) { return file.size > maxSize; });
|
|
198
|
+
if (maxFiles.length > 0) {
|
|
199
|
+
setError('El tamaño máximo de carga es de 30Mb.');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
setFileChange(filesArray
|
|
203
|
+
.filter(function (file) {
|
|
204
|
+
return value.find(function (val) {
|
|
205
|
+
return val.file ===
|
|
206
|
+
file;
|
|
207
|
+
}) === undefined;
|
|
208
|
+
})
|
|
209
|
+
.map(function (file) {
|
|
210
|
+
return ({
|
|
211
|
+
state: 'STARTING',
|
|
212
|
+
file: file,
|
|
213
|
+
postInfo: null,
|
|
214
|
+
});
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
inputRef.current.value = '';
|
|
134
218
|
}
|
|
135
|
-
}, multiple: true, accept: getAcceptedExtensions() }, void 0),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
219
|
+
}, multiple: true, accept: getAcceptedExtensions() }, void 0), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className: styles.hiddenInput }, void 0), _jsx(RoundedButton, { disabled: postview, text: 'Examinar' + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
220
|
+
if (!postview) {
|
|
221
|
+
var input = inputRef.current;
|
|
222
|
+
if (input !== null) {
|
|
223
|
+
clearErrors(step.id);
|
|
224
|
+
setError(undefined);
|
|
225
|
+
input.click();
|
|
226
|
+
}
|
|
141
227
|
}
|
|
228
|
+
} }, void 0)] }), void 0), _jsx("div", __assign({ className: styles.filesContainer }, { children: value.map(function (file, index) { return (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!errors[step.id] &&
|
|
229
|
+
file.state !== 'DONE') ||
|
|
230
|
+
file.state === 'ERROR', handleRemove: function () {
|
|
231
|
+
if (value.filter(function (val) {
|
|
232
|
+
return val.state === 'ERROR';
|
|
233
|
+
}).length === 1) {
|
|
234
|
+
clearErrors(step.id);
|
|
235
|
+
setError(undefined);
|
|
142
236
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
onChange(tempArray);
|
|
150
|
-
setUploadedFiles(tempArray);
|
|
151
|
-
}, handleUploaded: function (info) {
|
|
152
|
-
setFileUploaded(info);
|
|
153
|
-
} }, index)); }) }), void 0)] }), void 0));
|
|
237
|
+
if (file.state !== undefined) {
|
|
238
|
+
setFileChange([
|
|
239
|
+
__assign(__assign({}, file), { state: 'CANCEL' }),
|
|
240
|
+
]);
|
|
241
|
+
}
|
|
242
|
+
}, fetchDownloadUrl: fetchDownloadUrl }, index)); }) }), void 0), _jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: error !== null && error !== void 0 ? error : calcErrorMsg() }), void 0)] }), void 0));
|
|
154
243
|
}
|
|
155
244
|
function UploadStepComponent(props) {
|
|
156
|
-
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: [], rules:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
245
|
+
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: [], rules: {
|
|
246
|
+
validate: function (array) {
|
|
247
|
+
return ((props.step.required && array.length > 0) ||
|
|
248
|
+
!props.step.required) &&
|
|
249
|
+
array.find(function (file) { return !file.S3Key; }) === undefined;
|
|
250
|
+
},
|
|
251
|
+
}, shouldUnregister: true, render: function (_a) {
|
|
161
252
|
var field = _a.field;
|
|
162
|
-
return (_jsx(FileUploadStep, __assign({}, props, { onChange: field.onChange }), void 0));
|
|
253
|
+
return (_jsx(FileUploadStep, __assign({}, props, { btnRef: field.ref, onChange: field.onChange, value: field.value }), void 0));
|
|
163
254
|
} }, void 0));
|
|
164
255
|
}
|
|
165
256
|
export default UploadStepComponent;
|
|
@@ -32,14 +32,22 @@
|
|
|
32
32
|
.btnContainer {
|
|
33
33
|
margin-top: 5px;
|
|
34
34
|
margin-left: 10px;
|
|
35
|
+
margin-bottom: 3px;
|
|
35
36
|
width: fit-content;
|
|
36
37
|
}
|
|
37
38
|
.errorMsg {
|
|
38
39
|
font-size: 0.75rem;
|
|
39
|
-
margin-top:
|
|
40
|
+
margin-top: 5px;
|
|
40
41
|
margin-left: 14px;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
.filesContainer {
|
|
44
45
|
padding-top: 5px;
|
|
45
46
|
}
|
|
47
|
+
|
|
48
|
+
.hiddenInput {
|
|
49
|
+
height: 0;
|
|
50
|
+
width: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
border-width: 0;
|
|
53
|
+
}
|
|
@@ -31,7 +31,7 @@ import StepComponent from '../../Step';
|
|
|
31
31
|
import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
|
|
32
32
|
import { Controller } from 'react-hook-form';
|
|
33
33
|
function Selector(_a) {
|
|
34
|
-
var step = _a.step, form = _a.form, value = _a.value, level = _a.level, onBlur = _a.onBlur, control = _a.control, onChange = _a.onChange, postview = _a.postview, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, errors = _a.errors, others = __rest(_a, ["step", "form", "value", "level", "onBlur", "control", "onChange", "postview", "formStyle", "getValues", "widthStats", "handleSizeChange", "errors"]);
|
|
34
|
+
var step = _a.step, form = _a.form, value = _a.value, level = _a.level, onBlur = _a.onBlur, control = _a.control, onChange = _a.onChange, postview = _a.postview, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, errors = _a.errors, inputRef = _a.inputRef, others = __rest(_a, ["step", "form", "value", "level", "onBlur", "control", "onChange", "postview", "formStyle", "getValues", "widthStats", "handleSizeChange", "errors", "inputRef"]);
|
|
35
35
|
var _b = useState(level === 0 ? calcFillerSize(step, form.steps, getValues(), form) : 0), fillerSize = _b[0], setFillerSize = _b[1];
|
|
36
36
|
var sizeChange = function () {
|
|
37
37
|
handleSizeChange();
|
|
@@ -46,7 +46,7 @@ function Selector(_a) {
|
|
|
46
46
|
: calcStepWidth(step.size, form),
|
|
47
47
|
maxWidth: '100%',
|
|
48
48
|
minHeight: step.description || step.required ? '55px' : '43px',
|
|
49
|
-
} }, { children: _jsxs(RoundedSelect, __assign({ value: value, fullWidth: true, cantEdit: postview, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, label: step.label, required: step.required, containerMargin: "0px", height: '31px', onBlur: onBlur, handleUpdate: function (event) {
|
|
49
|
+
} }, { children: _jsxs(RoundedSelect, __assign({ value: value, fullWidth: true, inputRef: inputRef, cantEdit: postview, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, label: step.label, required: step.required, containerMargin: "0px", height: '31px', onBlur: onBlur, handleUpdate: function (event) {
|
|
50
50
|
onChange(event.target.value);
|
|
51
51
|
sizeChange();
|
|
52
52
|
}, helperText: errors[step.id]
|
|
@@ -93,7 +93,7 @@ function SelectorStep(props) {
|
|
|
93
93
|
: undefined,
|
|
94
94
|
}, shouldUnregister: true, render: function (_a) {
|
|
95
95
|
var field = _a.field;
|
|
96
|
-
return (_jsx(Selector, __assign({}, props, { value: field.value, onChange: field.onChange, onBlur: field.onBlur }), void 0));
|
|
96
|
+
return (_jsx(Selector, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange, onBlur: field.onBlur }), void 0));
|
|
97
97
|
} }, void 0));
|
|
98
98
|
}
|
|
99
99
|
export default SelectorStep;
|
|
@@ -76,7 +76,9 @@ function TextAreaStep(_a) {
|
|
|
76
76
|
: {}, shouldUnregister: true, render: function (_a) {
|
|
77
77
|
var _b;
|
|
78
78
|
var field = _a.field;
|
|
79
|
-
return (_jsx(Editor, {
|
|
79
|
+
return (_jsx(Editor, { editorRef: field.ref, onFocus: function () {
|
|
80
|
+
setFocus(true);
|
|
81
|
+
}, onBlur: field.onBlur, editorState: field.value, onEditorStateChange: field.onChange, toolbarClassName: styles.toolbar, editorClassName: styles.editor, wrapperClassName: styles.wrapper, editorStyle: { lineHeight: '85%' }, placeholder: (_b = step.description) !== null && _b !== void 0 ? _b : '', toolbar: {
|
|
80
82
|
options: ['inline', 'list', 'history'],
|
|
81
83
|
inline: {
|
|
82
84
|
options: [
|
|
@@ -103,7 +105,7 @@ function TextAreaStep(_a) {
|
|
|
103
105
|
: undefined,
|
|
104
106
|
}, shouldUnregister: true, render: function (_a) {
|
|
105
107
|
var field = _a.field;
|
|
106
|
-
return (_jsx(RoundedTextField, __assign({}, field, { label: step.label, required: step.required, cantEdit: postview, fontWeight: 400, multiline: true, minRows: 4, maxRows: 6, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperText: errors[step.id]
|
|
108
|
+
return (_jsx(RoundedTextField, __assign({}, field, { label: step.label, inputRef: field.ref, required: step.required, cantEdit: postview, fontWeight: 400, multiline: true, minRows: 4, maxRows: 6, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperText: errors[step.id]
|
|
107
109
|
? errors[step.id].message
|
|
108
110
|
: step.description, error: !!errors[step.id] }), void 0));
|
|
109
111
|
} }, void 0) }), void 0));
|
package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js
CHANGED
|
@@ -35,7 +35,7 @@ function TextInputStep(_a) {
|
|
|
35
35
|
: undefined,
|
|
36
36
|
}, shouldUnregister: true, render: function (_a) {
|
|
37
37
|
var field = _a.field;
|
|
38
|
-
return (_jsx(RoundedTextField, __assign({}, field, { label: step.label, cantEdit: postview, required: step.required, fontWeight: 400, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperText: errors[step.id]
|
|
38
|
+
return (_jsx(RoundedTextField, __assign({}, field, { label: step.label, inputRef: field.ref, cantEdit: postview, required: step.required, fontWeight: 400, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperText: errors[step.id]
|
|
39
39
|
? errors[step.id].message
|
|
40
40
|
: step.description, error: !!errors[step.id] }), void 0));
|
|
41
41
|
} }, void 0) }), void 0));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getUploadUrls(files: Array<File>, domain?: string): Promise<
|
|
1
|
+
export declare function getUploadUrls(files: Array<File>, domain?: string): Promise<(Record<string, any> | string)[]>;
|
|
2
2
|
export declare function postFile(file: File, postInfo: Record<string, any>): Promise<{
|
|
3
3
|
fileName: string;
|
|
4
4
|
S3Key: string;
|
|
@@ -36,7 +36,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
36
36
|
return t;
|
|
37
37
|
};
|
|
38
38
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
39
|
-
import React from 'react';
|
|
39
|
+
import React, { cloneElement } from 'react';
|
|
40
40
|
import { makeStyles } from '@material-ui/core/styles';
|
|
41
41
|
import CalendarTodayRoundedIcon from '@material-ui/icons/CalendarTodayRounded';
|
|
42
42
|
import { KeyboardDatePicker, } from '@material-ui/pickers';
|
|
@@ -158,7 +158,7 @@ var useDatePickerDialogStyles = function (props) {
|
|
|
158
158
|
}); });
|
|
159
159
|
};
|
|
160
160
|
function CustomDatePicker(_a) {
|
|
161
|
-
var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.outlineColor, outlineColor = _c === void 0 ? '#0000003b' : _c, _d = _a.backgroundColor, backgroundColor = _d === void 0 ? 'white' : _d, innerBackgroundColor = _a.innerBackgroundColor, _e = _a.textColor, textColor = _e === void 0 ? '#293241' : _e, _f = _a.errorColor, errorColor = _f === void 0 ? '#cc2936' : _f, _g = _a.borderRadius, borderRadius = _g === void 0 ? 10 : _g, _h = _a.padding, padding = _h === void 0 ? '6px 12px' : _h, _j = _a.fontSize, fontSize = _j === void 0 ? '1rem' : _j, _k = _a.shrunkenFontSize, shrunkenFontSize = _k === void 0 ? '1rem' : _k, _l = _a.fontWeight, fontWeight = _l === void 0 ? '300' : _l, _m = _a.showIcon, showIcon = _m === void 0 ? true : _m, _o = _a.cantEdit, cantEdit = _o === void 0 ? false : _o, required = _a.required, others = __rest(_a, ["focusColor", "outlineColor", "backgroundColor", "innerBackgroundColor", "textColor", "errorColor", "borderRadius", "padding", "fontSize", "shrunkenFontSize", "fontWeight", "showIcon", "cantEdit", "required"]);
|
|
161
|
+
var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.outlineColor, outlineColor = _c === void 0 ? '#0000003b' : _c, _d = _a.backgroundColor, backgroundColor = _d === void 0 ? 'white' : _d, innerBackgroundColor = _a.innerBackgroundColor, _e = _a.textColor, textColor = _e === void 0 ? '#293241' : _e, _f = _a.errorColor, errorColor = _f === void 0 ? '#cc2936' : _f, _g = _a.borderRadius, borderRadius = _g === void 0 ? 10 : _g, _h = _a.padding, padding = _h === void 0 ? '6px 12px' : _h, _j = _a.fontSize, fontSize = _j === void 0 ? '1rem' : _j, _k = _a.shrunkenFontSize, shrunkenFontSize = _k === void 0 ? '1rem' : _k, _l = _a.fontWeight, fontWeight = _l === void 0 ? '300' : _l, _m = _a.showIcon, showIcon = _m === void 0 ? true : _m, _o = _a.cantEdit, cantEdit = _o === void 0 ? false : _o, onChange = _a.onChange, required = _a.required, others = __rest(_a, ["focusColor", "outlineColor", "backgroundColor", "innerBackgroundColor", "textColor", "errorColor", "borderRadius", "padding", "fontSize", "shrunkenFontSize", "fontWeight", "showIcon", "cantEdit", "onChange", "required"]);
|
|
162
162
|
var classes = useDatePickerStyles({
|
|
163
163
|
padding: padding,
|
|
164
164
|
cantEdit: cantEdit,
|
|
@@ -217,10 +217,10 @@ function CustomDatePicker(_a) {
|
|
|
217
217
|
shrunkenFontSize: shrunkenFontSize,
|
|
218
218
|
fontWeight: fontWeight,
|
|
219
219
|
})();
|
|
220
|
-
return (_jsx(KeyboardDatePicker, __assign({}, others, { inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, placeholder: "
|
|
220
|
+
return (_jsx(KeyboardDatePicker, __assign({}, others, { inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, onChange: onChange, placeholder: "PPP", format: "PPP", required: required, keyboardIcon: showIcon ? (_jsx(CalendarTodayRoundedIcon, { fontSize: "inherit" }, void 0)) : null, InputLabelProps: { classes: labelClasses }, DialogProps: {
|
|
221
221
|
disableEnforceFocus: true,
|
|
222
222
|
className: datePicker,
|
|
223
|
-
cancelLabel: '
|
|
223
|
+
cancelLabel: '',
|
|
224
224
|
} //Fixes the typescript declaration of the library: https://material-ui-pickers.dev/api/KeyboardDatePicker
|
|
225
225
|
, InputProps: {
|
|
226
226
|
required: required,
|
|
@@ -228,6 +228,13 @@ function CustomDatePicker(_a) {
|
|
|
228
228
|
disabled: cantEdit,
|
|
229
229
|
}, FormHelperTextProps: {
|
|
230
230
|
classes: helperTextStyles,
|
|
231
|
+
}, renderDay: function (day, selectedDate, dayInCurrentMonth, dayComponent) {
|
|
232
|
+
if (!day) {
|
|
233
|
+
return dayComponent;
|
|
234
|
+
}
|
|
235
|
+
return (_jsx("div", __assign({ onClick: function () {
|
|
236
|
+
onChange(day);
|
|
237
|
+
} }, { children: cloneElement(dayComponent) }), void 0));
|
|
231
238
|
}, variant: "dialog" }), void 0));
|
|
232
239
|
}
|
|
233
240
|
/**
|
package/package.json
CHANGED