@arquimedes.co/eureka-forms 1.2.0-test → 1.4.0-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/@Types/FormStep.d.ts +1 -6
- package/dist/App.d.ts +3 -1
- package/dist/App.js +3 -3
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +54 -48
- package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +2 -4
- package/dist/FormComponents/Form/Form.d.ts +1 -0
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +2 -1
- package/dist/FormComponents/Step/Step.js +5 -7
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +23 -7
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +1 -1
- package/dist/constants/FormStepTypes.d.ts +0 -6
- package/dist/constants/FormStepTypes.js +0 -7
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.d.ts +2 -4
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +8 -5
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Types, { ClassifierOptionTypes,
|
|
1
|
+
import Types, { ClassifierOptionTypes, OptionTypes } from '../constants/FormStepTypes';
|
|
2
2
|
export declare type FormStep = Title | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
|
|
3
3
|
export interface Title {
|
|
4
4
|
id: string;
|
|
@@ -34,7 +34,6 @@ export interface TextArea {
|
|
|
34
34
|
description: string | null;
|
|
35
35
|
required: boolean;
|
|
36
36
|
hasTextEditor: boolean;
|
|
37
|
-
isPrimary: boolean;
|
|
38
37
|
}
|
|
39
38
|
export interface TextInput {
|
|
40
39
|
id: string;
|
|
@@ -43,9 +42,6 @@ export interface TextInput {
|
|
|
43
42
|
description: string | null;
|
|
44
43
|
validation?: FormValidation;
|
|
45
44
|
required: boolean;
|
|
46
|
-
isSubject: boolean;
|
|
47
|
-
isClientInfo: boolean;
|
|
48
|
-
clientInfoType?: ClientInfoTypes;
|
|
49
45
|
size: 1 | 2 | 3 | 4;
|
|
50
46
|
}
|
|
51
47
|
export interface DatePicker {
|
|
@@ -55,7 +51,6 @@ export interface DatePicker {
|
|
|
55
51
|
pickTime: boolean;
|
|
56
52
|
description: string | null;
|
|
57
53
|
required: boolean;
|
|
58
|
-
showIcon: boolean;
|
|
59
54
|
size: 1 | 2 | 3 | 4;
|
|
60
55
|
}
|
|
61
56
|
declare type FormValidation = {
|
package/dist/App.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface AppProps {
|
|
|
19
19
|
valuesData?: Record<string, unknown>;
|
|
20
20
|
/** Custom steps to display */
|
|
21
21
|
customSteps?: Record<string, CustomStep>;
|
|
22
|
+
/** Custom function to call on send */
|
|
23
|
+
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
22
24
|
/** Function to call on postview to fetch the download url of a file */
|
|
23
25
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
24
26
|
/** Function to call after the confimation dialog has been closed */
|
|
@@ -28,7 +30,7 @@ export interface CustomStep {
|
|
|
28
30
|
component: ReactNode;
|
|
29
31
|
updateValue: (idStep: string, values: Record<string, any>, form: Form) => void;
|
|
30
32
|
}
|
|
31
|
-
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
33
|
+
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSend, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
32
34
|
export default App;
|
|
33
35
|
export declare enum SIZES {
|
|
34
36
|
SMALL = "SMALL",
|
package/dist/App.js
CHANGED
|
@@ -68,7 +68,7 @@ import widgetInstance from './AxiosWidget';
|
|
|
68
68
|
function App(_a) {
|
|
69
69
|
var _this = this;
|
|
70
70
|
var _b, _c, _d, _e;
|
|
71
|
-
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
|
+
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, customSend = _a.customSend, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
72
72
|
var _f = useState(undefined), form = _f[0], setForm = _f[1];
|
|
73
73
|
var _g = useState({}), originalValues = _g[0], setOriginalValues = _g[1];
|
|
74
74
|
var _h = useState(undefined), organizationInfo = _h[0], setOrganizationInfo = _h[1];
|
|
@@ -127,7 +127,7 @@ function App(_a) {
|
|
|
127
127
|
if (!(organizationInfo && form !== undefined)) return [3 /*break*/, 4];
|
|
128
128
|
if (!(process.env.NODE_ENV === 'production' &&
|
|
129
129
|
apiKey !== 'rCgWiEfOSN1TlUmHO28Y0' &&
|
|
130
|
-
apiKey !== '
|
|
130
|
+
apiKey !== 'FORMSTEST' &&
|
|
131
131
|
!internal &&
|
|
132
132
|
!postview &&
|
|
133
133
|
!preview)) return [3 /*break*/, 4];
|
|
@@ -256,7 +256,7 @@ function App(_a) {
|
|
|
256
256
|
if (handleConfirmed) {
|
|
257
257
|
handleConfirmed();
|
|
258
258
|
}
|
|
259
|
-
}, 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));
|
|
259
|
+
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, customSend: customSend, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
export default App;
|
|
@@ -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, ...others }: FormComponentProps): JSX.Element;
|
|
3
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, customSend, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
4
4
|
export default ColumnForm;
|
|
@@ -70,7 +70,7 @@ import axiosInstance from '../../../AxiosAPI';
|
|
|
70
70
|
import widgetInstance from '../../../AxiosWidget';
|
|
71
71
|
function ColumnForm(_a) {
|
|
72
72
|
var _this = this;
|
|
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"]);
|
|
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, customSend = _a.customSend, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "customSend", "originalValues"]);
|
|
74
74
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
75
75
|
var _c = useForm({
|
|
76
76
|
defaultValues: mapOriginal(originalValues, form),
|
|
@@ -93,7 +93,7 @@ function ColumnForm(_a) {
|
|
|
93
93
|
return __generator(this, function (_c) {
|
|
94
94
|
switch (_c.label) {
|
|
95
95
|
case 0:
|
|
96
|
-
if (!(apiKey || internal)) return [3 /*break*/,
|
|
96
|
+
if (!(apiKey || internal)) return [3 /*break*/, 11];
|
|
97
97
|
return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
98
98
|
case 1:
|
|
99
99
|
valid = _c.sent();
|
|
@@ -104,42 +104,46 @@ function ColumnForm(_a) {
|
|
|
104
104
|
setTimeout(function () {
|
|
105
105
|
setTempError(false);
|
|
106
106
|
}, 500);
|
|
107
|
-
return [3 /*break*/,
|
|
107
|
+
return [3 /*break*/, 11];
|
|
108
108
|
case 2:
|
|
109
|
-
_c.trys.push([2,
|
|
109
|
+
_c.trys.push([2, 10, , 11]);
|
|
110
110
|
setLoading(true);
|
|
111
111
|
for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
|
|
112
112
|
idStep = _a[_i];
|
|
113
113
|
updateValue(idStep, values, form, customSteps);
|
|
114
114
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
if (!customSend) return [3 /*break*/, 4];
|
|
116
|
+
return [4 /*yield*/, customSend(values, reload)];
|
|
117
|
+
case 3:
|
|
118
|
+
_c.sent();
|
|
119
|
+
return [3 /*break*/, 9];
|
|
120
|
+
case 4:
|
|
119
121
|
payload = {
|
|
120
122
|
formValues: { steps: values },
|
|
121
123
|
};
|
|
122
124
|
url = "/ticket/" + (internal ? form.apiKey : apiKey);
|
|
123
|
-
if (!(domain || internal)) return [3 /*break*/,
|
|
125
|
+
if (!(domain || internal)) return [3 /*break*/, 6];
|
|
124
126
|
return [4 /*yield*/, widgetInstance.post(url + "?idOrganization=" + domain, payload)];
|
|
125
|
-
case 3:
|
|
126
|
-
_b = _c.sent();
|
|
127
|
-
return [3 /*break*/, 6];
|
|
128
|
-
case 4: return [4 /*yield*/, axiosInstance.post(url, payload)];
|
|
129
127
|
case 5:
|
|
130
128
|
_b = _c.sent();
|
|
131
|
-
|
|
132
|
-
case 6:
|
|
129
|
+
return [3 /*break*/, 8];
|
|
130
|
+
case 6: return [4 /*yield*/, axiosInstance.post(url, payload)];
|
|
131
|
+
case 7:
|
|
132
|
+
_b = _c.sent();
|
|
133
|
+
_c.label = 8;
|
|
134
|
+
case 8:
|
|
133
135
|
resp = _b;
|
|
134
136
|
setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
|
|
137
|
+
_c.label = 9;
|
|
138
|
+
case 9:
|
|
135
139
|
setLoading(false);
|
|
136
|
-
return [3 /*break*/,
|
|
137
|
-
case
|
|
140
|
+
return [3 /*break*/, 11];
|
|
141
|
+
case 10:
|
|
138
142
|
error_1 = _c.sent();
|
|
139
143
|
console.error(error_1);
|
|
140
144
|
setLoading(false);
|
|
141
|
-
return [3 /*break*/,
|
|
142
|
-
case
|
|
145
|
+
return [3 /*break*/, 11];
|
|
146
|
+
case 11: return [2 /*return*/];
|
|
143
147
|
}
|
|
144
148
|
});
|
|
145
149
|
}); };
|
|
@@ -196,38 +200,40 @@ var mapOriginal = function (values, form) {
|
|
|
196
200
|
};
|
|
197
201
|
var updateValue = function (idStep, values, form, customSteps) {
|
|
198
202
|
var step = form.steps[idStep];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
|
|
204
|
+
if (custom !== undefined) {
|
|
205
|
+
custom.updateValue(idStep, values, form);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
209
|
+
case Types.TEXTAREA: {
|
|
210
|
+
var value = values[step.id];
|
|
211
|
+
if (step.hasTextEditor) {
|
|
212
|
+
var currentContent = value.getCurrentContent();
|
|
213
|
+
values[step.id] = {
|
|
214
|
+
value: currentContent.getPlainText(),
|
|
215
|
+
draft: convertToRaw(currentContent),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
values[step.id] = {
|
|
220
|
+
value: value,
|
|
221
|
+
draft: stringToDraft(value),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
208
225
|
}
|
|
209
|
-
|
|
210
|
-
values[step.id]
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
case Types.FILEUPLOAD: {
|
|
227
|
+
var value = values[step.id];
|
|
228
|
+
values[step.id] = value.map(function (val) { return ({
|
|
229
|
+
fileName: val.fileName,
|
|
230
|
+
S3Key: val.S3Key,
|
|
231
|
+
}); });
|
|
232
|
+
break;
|
|
214
233
|
}
|
|
215
|
-
|
|
234
|
+
default:
|
|
235
|
+
break;
|
|
216
236
|
}
|
|
217
|
-
case Types.FILEUPLOAD: {
|
|
218
|
-
var value = values[step.id];
|
|
219
|
-
values[step.id] = value.map(function (val) { return ({
|
|
220
|
-
fileName: val.fileName,
|
|
221
|
-
S3Key: val.S3Key,
|
|
222
|
-
}); });
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
default:
|
|
226
|
-
var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
|
|
227
|
-
if (custom !== undefined) {
|
|
228
|
-
custom.updateValue(idStep, values, form);
|
|
229
|
-
}
|
|
230
|
-
break;
|
|
231
237
|
}
|
|
232
238
|
};
|
|
233
239
|
function stringToDraft(text) {
|
|
@@ -24,10 +24,8 @@ function ConfirmationDialog(_a) {
|
|
|
24
24
|
},
|
|
25
25
|
}, open: true }, { children: _jsxs("div", __assign({ className: styles.confirmationContainer, style: { color: formStyle.textColor } }, { children: [_jsx("div", __assign({ className: styles.closeIcon, onClick: function () {
|
|
26
26
|
onClose();
|
|
27
|
-
} }, { children: _jsx(CloseRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.checkContainer, style: { color: formStyle.primaryColor } }, { children: _jsx(CheckCircleOutlineRoundedIcon, { fontSize: "inherit", style: { fontSize: '160px' } }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.messageContainer }, { children: ["Tu caso n\u00FAmero", ' ', _jsx("span", __assign({ style: { fontWeight: 'bold' } }, { children: confirmation.case }), void 0), ' ', "ha sido registrado!"] }), void 0), _jsx("div", __assign({ className: styles.messageContainer }, { children: "Pronto te estaremos dando respuesta." }), void 0), _jsxs("div", __assign({ className: styles.linkContainer }, { children: ["Puedes consultar el estado aqui:", ' '] }), void 0), _jsx("
|
|
28
|
-
|
|
29
|
-
(_c = (_b = (_a = window
|
|
30
|
-
.open) === null || _a === void 0 ? void 0 : _a.call(window, confirmation.url, '_blank')) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
27
|
+
} }, { children: _jsx(CloseRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.checkContainer, style: { color: formStyle.primaryColor } }, { children: _jsx(CheckCircleOutlineRoundedIcon, { fontSize: "inherit", style: { fontSize: '160px' } }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.messageContainer }, { children: ["Tu caso n\u00FAmero", ' ', _jsx("span", __assign({ style: { fontWeight: 'bold' } }, { children: confirmation.case }), void 0), ' ', "ha sido registrado!"] }), void 0), _jsx("div", __assign({ className: styles.messageContainer }, { children: "Pronto te estaremos dando respuesta." }), void 0), _jsxs("div", __assign({ className: styles.linkContainer }, { children: ["Puedes consultar el estado aqui:", ' '] }), void 0), _jsx("a", __assign({ className: styles.url, "data-testid": "ResUrl", target: "_blank", href: confirmation.url, style: {
|
|
28
|
+
color: formStyle.textColor,
|
|
31
29
|
} }, { children: confirmation.url }), void 0)] }), void 0)] }), void 0) }), void 0));
|
|
32
30
|
}
|
|
33
31
|
export default ConfirmationDialog;
|
|
@@ -11,6 +11,7 @@ export interface FormComponentProps {
|
|
|
11
11
|
form: Form;
|
|
12
12
|
originalValues: Record<string, unknown>;
|
|
13
13
|
customSteps: Record<string, CustomStep>;
|
|
14
|
+
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
14
15
|
widthStats: WidthStats;
|
|
15
16
|
internal: boolean;
|
|
16
17
|
reload: Function;
|
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, { pickTime: step.pickTime,
|
|
30
|
+
return (_jsx(RoundedDatePicker, __assign({}, field, { pickTime: step.pickTime, inputRef: field.ref, cantEdit: postview, "data-testid": step.id, secondaryColor: formStyle.secondaryColor, contrastColor: formStyle.secondaryContrastColor, accentColor: formStyle.textColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, helperTextColor: formStyle.descriptionTextColor, 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));
|
package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js
CHANGED
|
@@ -190,7 +190,8 @@ function FileUploadStep(_a) {
|
|
|
190
190
|
}
|
|
191
191
|
return '';
|
|
192
192
|
};
|
|
193
|
-
return (_jsxs("div", __assign({ className: styles.container
|
|
193
|
+
return (_jsxs("div", __assign({ className: styles.container +
|
|
194
|
+
(error || !!errors[step.id] ? ' EF-error' : ''), "data-testid": step.id }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label }), void 0), step.description && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor } }, { children: step.description }), void 0)), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: function (e) {
|
|
194
195
|
var files = e.target.files;
|
|
195
196
|
if (files) {
|
|
196
197
|
var filesArray = Array.from(files);
|
|
@@ -33,6 +33,10 @@ import FileUploadStep from './FileUploadStep/FileUploadStep';
|
|
|
33
33
|
import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep';
|
|
34
34
|
function StepComponent(_a) {
|
|
35
35
|
var step = _a.step, props = __rest(_a, ["step"]);
|
|
36
|
+
var customStep = props.customSteps[step.type];
|
|
37
|
+
if (customStep) {
|
|
38
|
+
return customStep.component(__assign({ step: step }, props));
|
|
39
|
+
}
|
|
36
40
|
switch (step.type) {
|
|
37
41
|
case Types.TITLE: {
|
|
38
42
|
return _jsx(TitleStep, __assign({ step: step }, props), void 0);
|
|
@@ -62,13 +66,7 @@ function StepComponent(_a) {
|
|
|
62
66
|
return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
|
|
63
67
|
}
|
|
64
68
|
default:
|
|
65
|
-
|
|
66
|
-
if (customStep) {
|
|
67
|
-
return customStep.component(__assign({ step: step }, props));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
return _jsx("div", {}, void 0);
|
|
71
|
-
}
|
|
69
|
+
return _jsx("div", {}, void 0);
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
export default StepComponent;
|
|
@@ -20,10 +20,9 @@ import { convertFromRaw, EditorState } from 'draft-js';
|
|
|
20
20
|
import { useState } from 'react';
|
|
21
21
|
import { ClickAwayListener } from '@material-ui/core';
|
|
22
22
|
function TextAreaStep(_a) {
|
|
23
|
-
var _b;
|
|
24
23
|
var step = _a.step, errors = _a.errors, control = _a.control, postview = _a.postview, formStyle = _a.formStyle, originalValues = _a.originalValues;
|
|
25
|
-
var
|
|
26
|
-
var
|
|
24
|
+
var _b = useState(false), hovering = _b[0], setHovering = _b[1];
|
|
25
|
+
var _c = useState(false), focus = _c[0], setFocus = _c[1];
|
|
27
26
|
var calcStyle = function () {
|
|
28
27
|
if (focus) {
|
|
29
28
|
return {
|
|
@@ -42,6 +41,23 @@ function TextAreaStep(_a) {
|
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
};
|
|
44
|
+
var calcDefaultStringValue = function (defaultValue) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (typeof defaultValue === 'string') {
|
|
47
|
+
return defaultValue;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _a !== void 0 ? _a : '';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var calcDefaultDraftValue = function (defaultValue) {
|
|
54
|
+
if (typeof defaultValue === 'string') {
|
|
55
|
+
return EditorState.createWithContent(convertFromRaw(stringToDraft(defaultValue)));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return EditorState.createWithContent(convertFromRaw(getRawText(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.draft, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text)));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
45
61
|
if (step.hasTextEditor) {
|
|
46
62
|
return (_jsxs("div", __assign({ className: styles.textEditorContainer, style: {
|
|
47
63
|
'--eureka-outline': formStyle.outlineColor,
|
|
@@ -54,7 +70,7 @@ function TextAreaStep(_a) {
|
|
|
54
70
|
if (!postview) {
|
|
55
71
|
setFocus(false);
|
|
56
72
|
}
|
|
57
|
-
} }, { children: _jsx("div", __assign({ className: styles.textContainer + ' EF-DraftContainer', style: calcStyle(), onMouseEnter: function () {
|
|
73
|
+
} }, { children: _jsx("div", __assign({ className: styles.textContainer + ' EF-DraftContainer', "data-testid": step.id, style: calcStyle(), onMouseEnter: function () {
|
|
58
74
|
if (!postview) {
|
|
59
75
|
setHovering(true);
|
|
60
76
|
}
|
|
@@ -67,7 +83,7 @@ function TextAreaStep(_a) {
|
|
|
67
83
|
setFocus(true);
|
|
68
84
|
}
|
|
69
85
|
} }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: originalValues[step.id]
|
|
70
|
-
?
|
|
86
|
+
? calcDefaultDraftValue(originalValues[step.id])
|
|
71
87
|
: EditorState.createEmpty(), rules: step.required
|
|
72
88
|
? {
|
|
73
89
|
validate: function (editorState) {
|
|
@@ -95,7 +111,7 @@ function TextAreaStep(_a) {
|
|
|
95
111
|
}
|
|
96
112
|
return (_jsx(Editor, { editorRef: field.ref, onFocus: function () {
|
|
97
113
|
setFocus(true);
|
|
98
|
-
},
|
|
114
|
+
}, readOnly: postview, onBlur: field.onBlur, stripPastedStyles: true, editorState: field.value, onEditorStateChange: field.onChange, toolbarClassName: styles.toolbar +
|
|
99
115
|
(postview
|
|
100
116
|
? ' postview-editor-toolbar'
|
|
101
117
|
: ''), editorClassName: editorClassName, wrapperClassName: styles.wrapper, placeholder: (_b = step.description) !== null && _b !== void 0 ? _b : '', toolbar: {
|
|
@@ -123,7 +139,7 @@ function TextAreaStep(_a) {
|
|
|
123
139
|
else {
|
|
124
140
|
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
125
141
|
paddingBottom: step.description || !!errors[step.id] ? '0px' : '23px',
|
|
126
|
-
} }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: (
|
|
142
|
+
} }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: calcDefaultStringValue(originalValues[step.id]), rules: {
|
|
127
143
|
required: step.required
|
|
128
144
|
? 'Este campo es obligatorio'
|
|
129
145
|
: undefined,
|
|
@@ -25,10 +25,4 @@ export declare enum ClassifierOptionTypes {
|
|
|
25
25
|
HIDE = "CLASSIFIER_HIDE",
|
|
26
26
|
NESTED = "CLASSIFIER_NESTED"
|
|
27
27
|
}
|
|
28
|
-
export declare enum ClientInfoTypes {
|
|
29
|
-
NAME = "NAME",
|
|
30
|
-
LASTNAME = "LASTNAME",
|
|
31
|
-
EMAIL = "EMAIL",
|
|
32
|
-
OTHER = "OTHER"
|
|
33
|
-
}
|
|
34
28
|
export default TYPES;
|
|
@@ -30,11 +30,4 @@ export var ClassifierOptionTypes;
|
|
|
30
30
|
ClassifierOptionTypes["HIDE"] = "CLASSIFIER_HIDE";
|
|
31
31
|
ClassifierOptionTypes["NESTED"] = "CLASSIFIER_NESTED";
|
|
32
32
|
})(ClassifierOptionTypes || (ClassifierOptionTypes = {}));
|
|
33
|
-
export var ClientInfoTypes;
|
|
34
|
-
(function (ClientInfoTypes) {
|
|
35
|
-
ClientInfoTypes["NAME"] = "NAME";
|
|
36
|
-
ClientInfoTypes["LASTNAME"] = "LASTNAME";
|
|
37
|
-
ClientInfoTypes["EMAIL"] = "EMAIL";
|
|
38
|
-
ClientInfoTypes["OTHER"] = "OTHER";
|
|
39
|
-
})(ClientInfoTypes || (ClientInfoTypes = {}));
|
|
40
33
|
export default TYPES;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { DatePickerProps } from '@material-ui/pickers';
|
|
3
3
|
interface StyleProps {
|
|
4
4
|
/** The color of the text */
|
|
5
5
|
textColor?: string;
|
|
@@ -38,13 +38,11 @@ interface StyleProps {
|
|
|
38
38
|
helperTextColor?: string;
|
|
39
39
|
}
|
|
40
40
|
interface RoundedDatePickerProps extends StyleProps {
|
|
41
|
-
/** If the calendar icon should be shown */
|
|
42
|
-
showIcon?: boolean;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Generic datepicker with apps designs. Is class do to the use in the react-hook-forms library
|
|
46
44
|
*/
|
|
47
|
-
declare class RoundedDatePicker extends React.Component<RoundedDatePickerProps &
|
|
45
|
+
declare class RoundedDatePicker extends React.Component<RoundedDatePickerProps & DatePickerProps> {
|
|
48
46
|
render(): JSX.Element;
|
|
49
47
|
}
|
|
50
48
|
export default RoundedDatePicker;
|
|
@@ -39,7 +39,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
39
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
|
-
import {
|
|
42
|
+
import { DatePicker, DateTimePicker, } from '@material-ui/pickers';
|
|
43
43
|
import { getLocale } from '../../FormComponents/Form/Form';
|
|
44
44
|
import { format } from 'date-fns';
|
|
45
45
|
var useDatePickerStyles = function (props) {
|
|
@@ -47,8 +47,9 @@ var useDatePickerStyles = function (props) {
|
|
|
47
47
|
root: {
|
|
48
48
|
borderRadius: props.borderRadius,
|
|
49
49
|
backgroundColor: props.backgroundColor,
|
|
50
|
+
cursor: props.cantEdit ? 'default' : 'pointer',
|
|
50
51
|
'& input, textarea': {
|
|
51
|
-
cursor: props.cantEdit ? 'default' : '
|
|
52
|
+
cursor: props.cantEdit ? 'default' : 'pointer',
|
|
52
53
|
padding: props.padding,
|
|
53
54
|
fontWeight: props.fontWeight,
|
|
54
55
|
color: props.textColor,
|
|
@@ -210,7 +211,7 @@ var useDatePickerDialogStyles = function (props) {
|
|
|
210
211
|
}); });
|
|
211
212
|
};
|
|
212
213
|
function CustomDatePicker(_a) {
|
|
213
|
-
var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.secondaryColor, secondaryColor = _c === void 0 ? '#98c1d9' : _c, _d = _a.outlineColor, outlineColor = _d === void 0 ? '#0000003b' : _d, _e = _a.backgroundColor, backgroundColor = _e === void 0 ? 'white' : _e, innerBackgroundColor = _a.innerBackgroundColor, _f = _a.textColor, textColor = _f === void 0 ? '#293241' : _f, _g = _a.contrastColor, contrastColor = _g === void 0 ? '#ee6c4d' : _g, _h = _a.accentColor, accentColor = _h === void 0 ? '#293241' : _h, _j = _a.errorColor, errorColor = _j === void 0 ? '#cc2936' : _j, _k = _a.borderRadius, borderRadius = _k === void 0 ? 10 : _k, _l = _a.padding, padding = _l === void 0 ? '6px 0px 6px 12px' : _l, _m = _a.fontSize, fontSize = _m === void 0 ? '1rem' : _m, _o = _a.shrunkenFontSize, shrunkenFontSize = _o === void 0 ? '1rem' : _o, _p = _a.helperTextColor, helperTextColor = _p === void 0 ? '#989898' : _p, _q = _a.fontWeight, fontWeight = _q === void 0 ? '300' : _q, _r = _a.
|
|
214
|
+
var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.secondaryColor, secondaryColor = _c === void 0 ? '#98c1d9' : _c, _d = _a.outlineColor, outlineColor = _d === void 0 ? '#0000003b' : _d, _e = _a.backgroundColor, backgroundColor = _e === void 0 ? 'white' : _e, innerBackgroundColor = _a.innerBackgroundColor, _f = _a.textColor, textColor = _f === void 0 ? '#293241' : _f, _g = _a.contrastColor, contrastColor = _g === void 0 ? '#ee6c4d' : _g, _h = _a.accentColor, accentColor = _h === void 0 ? '#293241' : _h, _j = _a.errorColor, errorColor = _j === void 0 ? '#cc2936' : _j, _k = _a.borderRadius, borderRadius = _k === void 0 ? 10 : _k, _l = _a.padding, padding = _l === void 0 ? '6px 0px 6px 12px' : _l, _m = _a.fontSize, fontSize = _m === void 0 ? '1rem' : _m, _o = _a.shrunkenFontSize, shrunkenFontSize = _o === void 0 ? '1rem' : _o, _p = _a.helperTextColor, helperTextColor = _p === void 0 ? '#989898' : _p, _q = _a.fontWeight, fontWeight = _q === void 0 ? '300' : _q, _r = _a.cantEdit, cantEdit = _r === void 0 ? false : _r, _s = _a.pickTime, pickTime = _s === void 0 ? false : _s, onChange = _a.onChange, required = _a.required, others = __rest(_a, ["focusColor", "secondaryColor", "outlineColor", "backgroundColor", "innerBackgroundColor", "textColor", "contrastColor", "accentColor", "errorColor", "borderRadius", "padding", "fontSize", "shrunkenFontSize", "helperTextColor", "fontWeight", "cantEdit", "pickTime", "onChange", "required"]);
|
|
214
215
|
var classes = useDatePickerStyles({
|
|
215
216
|
padding: padding,
|
|
216
217
|
cantEdit: cantEdit,
|
|
@@ -277,7 +278,7 @@ function CustomDatePicker(_a) {
|
|
|
277
278
|
helperTextColor: helperTextColor,
|
|
278
279
|
})();
|
|
279
280
|
if (pickTime) {
|
|
280
|
-
return (_jsx(
|
|
281
|
+
return (_jsx(DateTimePicker, __assign({}, others, { inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, onChange: onChange, placeholder: format(new Date(), 'Pp', { locale: getLocale() }), format: "Pp", required: required, InputLabelProps: { classes: labelClasses }, DialogProps: {
|
|
281
282
|
disableEnforceFocus: true,
|
|
282
283
|
className: datePicker,
|
|
283
284
|
cancelLabel: '',
|
|
@@ -286,6 +287,7 @@ function CustomDatePicker(_a) {
|
|
|
286
287
|
required: required,
|
|
287
288
|
classes: classes,
|
|
288
289
|
disabled: cantEdit,
|
|
290
|
+
endAdornment: (_jsx(CalendarTodayRoundedIcon, { fontSize: "inherit", style: { color: '#757575' } }, void 0)),
|
|
289
291
|
}, FormHelperTextProps: {
|
|
290
292
|
classes: helperTextStyles,
|
|
291
293
|
}, renderDay: function (day, selectedDate, dayInCurrentMonth, dayComponent) {
|
|
@@ -298,7 +300,7 @@ function CustomDatePicker(_a) {
|
|
|
298
300
|
}, variant: "dialog" }), void 0));
|
|
299
301
|
}
|
|
300
302
|
else {
|
|
301
|
-
return (_jsx(
|
|
303
|
+
return (_jsx(DatePicker, __assign({}, others, { inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, onChange: onChange, placeholder: format(new Date(), 'P', { locale: getLocale() }), format: "P", required: required, InputLabelProps: { classes: labelClasses }, DialogProps: {
|
|
302
304
|
disableEnforceFocus: true,
|
|
303
305
|
className: datePicker,
|
|
304
306
|
cancelLabel: '',
|
|
@@ -307,6 +309,7 @@ function CustomDatePicker(_a) {
|
|
|
307
309
|
required: required,
|
|
308
310
|
classes: classes,
|
|
309
311
|
disabled: cantEdit,
|
|
312
|
+
endAdornment: (_jsx(CalendarTodayRoundedIcon, { fontSize: "inherit", style: { color: '#757575' } }, void 0)),
|
|
310
313
|
}, FormHelperTextProps: {
|
|
311
314
|
classes: helperTextStyles,
|
|
312
315
|
}, renderDay: function (day, selectedDate, dayInCurrentMonth, dayComponent) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"1.
|
|
4
|
+
"version":"1.4.0-test",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
@@ -57,11 +57,12 @@
|
|
|
57
57
|
"@types/react-router-dom": "^5.1.7",
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^4.24.0",
|
|
59
59
|
"@typescript-eslint/parser": "^4.24.0",
|
|
60
|
-
"cypress": "^9.5.
|
|
60
|
+
"cypress": "^9.5.2",
|
|
61
61
|
"eslint": "^7.27.0",
|
|
62
62
|
"eslint-config-prettier": "^8.3.0",
|
|
63
63
|
"eslint-plugin-prettier": "^3.4.0",
|
|
64
64
|
"jest-junit": "^12.2.0",
|
|
65
|
+
"local-web-server": "^5.2.0",
|
|
65
66
|
"postcss-normalize": "^10.0.1",
|
|
66
67
|
"prettier": "^2.3.0",
|
|
67
68
|
"react": "^17.0.2",
|
|
@@ -76,8 +77,7 @@
|
|
|
76
77
|
"react": "^17.x.x",
|
|
77
78
|
"react-dom": "^17.x.x",
|
|
78
79
|
"react-draft-wysiwyg": "^1.14.x",
|
|
79
|
-
"react-hook-form": "^7.6.4"
|
|
80
|
-
"react-router-dom": "^5.2.0"
|
|
80
|
+
"react-hook-form": "^7.6.4"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|