@arquimedes.co/eureka-forms 1.4.0-test → 1.4.4-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/CBRFormStep.d.ts +72 -0
- package/dist/@Types/CBRFormStep.js +1 -0
- package/dist/@Types/Form.d.ts +4 -1
- package/dist/@Types/FormStep.d.ts +10 -41
- package/dist/@Types/GenericFormSteps.d.ts +58 -0
- package/dist/@Types/GenericFormSteps.js +1 -0
- package/dist/App.js +27 -8
- package/dist/App.module.css +1 -0
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +45 -12
- package/dist/FormComponents/Form/Form.d.ts +4 -1
- package/dist/FormComponents/Form/Form.js +22 -10
- package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +2 -1
- package/dist/FormComponents/Section/Section.d.ts +4 -1
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.d.ts +9 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +25 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +8 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +48 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.module.css +60 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +11 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +112 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +34 -0
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.d.ts +8 -0
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +124 -0
- package/dist/FormComponents/Step/CBRStepMapper.d.ts +13 -0
- package/dist/FormComponents/Step/CBRStepMapper.js +243 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_INMUEBLE.json +13151 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_LOCATIVAS.json +71 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_PROYECTO.json +74 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_DOC.json +50 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_ESPACIO.json +320 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_SOLICITANTE.json +42 -0
- package/dist/FormComponents/Step/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +2 -2
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +12 -7
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +7 -5
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +4 -0
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +147 -0
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +9 -0
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.d.ts +24 -0
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.js +25 -0
- package/dist/FormComponents/Step/Step.js +6 -1
- package/dist/FormComponents/Step/StepFunctions.d.ts +3 -3
- package/dist/FormComponents/Step/StepFunctions.js +5 -5
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +5 -2
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -1
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +1 -1
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +3 -3
- package/dist/FormComponents/Step/TextInputStep/TextInputStep.d.ts +2 -0
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -1
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.module.css +1 -8
- package/dist/constants/CBRFormStepTypes.d.ts +20 -0
- package/dist/constants/CBRFormStepTypes.js +21 -0
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.d.ts +1 -1
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +1 -1
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +1 -1
- package/dist/shared/RoundedSelect/RoundedSelect.d.ts +5 -1
- package/dist/shared/RoundedSelect/RoundedSelect.js +8 -2
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +63 -0
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +172 -0
- package/dist/shared/RoundedTextField/RoundedTextField.d.ts +2 -0
- package/dist/shared/RoundedTextField/RoundedTextField.js +7 -2
- package/package.json +2 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Types from '../constants/CBRFormStepTypes';
|
|
2
|
+
import { GSmartSelect, GTextArea, GTextInput, GBaseStep } from './GenericFormSteps';
|
|
3
|
+
export declare type CBRFormStep = CBRFirstNameStep | CBRMiddleNameStep | CBRLastNameStep | CBRSecondLastNameStep | PostVentaStep | CBRProjectStep | CBRDocStep | CBRCelStep | CBRPhoneStep | CBRDocTypeStep | CBREmailStep | CBRRequesterTypeStep | CBRPropertyStep | CBRSpaceTypeStep | CBRElementStep | CBRCommentStep | CBRIncidentsStep;
|
|
4
|
+
export interface PostVentaStep extends GBaseStep {
|
|
5
|
+
type: Types.CBR_POSTVENTA;
|
|
6
|
+
}
|
|
7
|
+
export interface CBRProjectStep extends GSmartSelect {
|
|
8
|
+
type: Types.CBR_PROYECTO;
|
|
9
|
+
steps: string[];
|
|
10
|
+
/** Only has maxSize if level === 0 */
|
|
11
|
+
maxSize: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CBRDocTypeStep extends Omit<GSmartSelect, 'showIcon'> {
|
|
14
|
+
type: Types.CBR_TIPO_DOC;
|
|
15
|
+
}
|
|
16
|
+
export interface CBRRequesterTypeStep extends GSmartSelect {
|
|
17
|
+
type: Types.CBR_TIPO_SOLICITANTE;
|
|
18
|
+
}
|
|
19
|
+
export interface CBRPropertyStep extends GSmartSelect {
|
|
20
|
+
type: Types.CBR_INMUEBLE;
|
|
21
|
+
}
|
|
22
|
+
export interface CBRSpaceTypeStep extends GSmartSelect {
|
|
23
|
+
type: Types.CBR_TIPO_ESPACIO;
|
|
24
|
+
}
|
|
25
|
+
export interface CBRFirstNameStep extends GTextInput {
|
|
26
|
+
type: Types.CBR_FIRST_NAME;
|
|
27
|
+
}
|
|
28
|
+
export interface CBRMiddleNameStep extends GTextInput {
|
|
29
|
+
type: Types.CBR_MIDDLE_NAME;
|
|
30
|
+
}
|
|
31
|
+
export interface CBRLastNameStep extends GTextInput {
|
|
32
|
+
type: Types.CBR_LAST_NAME;
|
|
33
|
+
}
|
|
34
|
+
export interface CBRSecondLastNameStep extends GTextInput {
|
|
35
|
+
type: Types.CBR_SECOND_LAST_NAME;
|
|
36
|
+
}
|
|
37
|
+
export interface CBRDocStep extends GTextInput {
|
|
38
|
+
type: Types.CBR_DOC;
|
|
39
|
+
showIcon: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CBRCelStep extends GTextInput {
|
|
42
|
+
type: Types.CBR_CEL;
|
|
43
|
+
}
|
|
44
|
+
export interface CBRPhoneStep extends GTextInput {
|
|
45
|
+
type: Types.CBR_PHONE;
|
|
46
|
+
}
|
|
47
|
+
export interface CBREmailStep extends GTextInput {
|
|
48
|
+
type: Types.CBR_EMAIL;
|
|
49
|
+
}
|
|
50
|
+
export interface CBRElementStep extends GSmartSelect {
|
|
51
|
+
type: Types.CBR_LOCATIVAS;
|
|
52
|
+
subStep: string | null;
|
|
53
|
+
parentStep: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface CBRCommentStep extends Omit<GTextArea, 'hasTextEditor'> {
|
|
56
|
+
type: Types.CBR_COMENTARIO;
|
|
57
|
+
}
|
|
58
|
+
export interface CBRIncidentsStep extends GBaseStep {
|
|
59
|
+
type: Types.CBR_INCIDENCIAS;
|
|
60
|
+
label: string;
|
|
61
|
+
description: string | null;
|
|
62
|
+
addBtnLabel: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
unitLabel: string;
|
|
65
|
+
spaceStep: Omit<CBRSpaceTypeStep, 'id' | 'type'>;
|
|
66
|
+
newLineAfterSpace: boolean;
|
|
67
|
+
elementStep: IncidentElementStep;
|
|
68
|
+
commentStep: Omit<CBRCommentStep, 'id' | 'type'>;
|
|
69
|
+
}
|
|
70
|
+
export interface IncidentElementStep extends Omit<CBRElementStep, 'id' | 'subStep' | 'parentStep' | 'type'> {
|
|
71
|
+
subStep?: IncidentElementStep;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export interface Form {
|
|
|
16
16
|
style: FormStyle;
|
|
17
17
|
classifiers: Record<string, ParentClassifier>;
|
|
18
18
|
terms: Term[];
|
|
19
|
+
size: FormSize;
|
|
20
|
+
}
|
|
21
|
+
export interface FormSize {
|
|
19
22
|
blockNum: 1 | 2 | 3 | 4;
|
|
20
23
|
blockSize: number;
|
|
21
24
|
spacingSize: number;
|
|
@@ -34,7 +37,7 @@ interface TermLink {
|
|
|
34
37
|
type: 'LINK';
|
|
35
38
|
url: string;
|
|
36
39
|
}
|
|
37
|
-
interface Classifier {
|
|
40
|
+
export interface Classifier {
|
|
38
41
|
_id: string;
|
|
39
42
|
name: string;
|
|
40
43
|
}
|
|
@@ -1,64 +1,34 @@
|
|
|
1
1
|
import Types, { ClassifierOptionTypes, OptionTypes } from '../constants/FormStepTypes';
|
|
2
|
+
import * as GSteps from './GenericFormSteps';
|
|
2
3
|
export declare type FormStep = Title | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
|
|
3
|
-
export interface Title {
|
|
4
|
-
id: string;
|
|
4
|
+
export interface Title extends GSteps.GBaseStep {
|
|
5
5
|
type: Types.TITLE;
|
|
6
6
|
title: string;
|
|
7
7
|
description: string | null;
|
|
8
8
|
}
|
|
9
|
-
export interface CheckBox {
|
|
10
|
-
label: string;
|
|
11
|
-
description: string | null;
|
|
12
|
-
id: string;
|
|
9
|
+
export interface CheckBox extends GSteps.GCheckBox {
|
|
13
10
|
type: Types.CHECKBOX;
|
|
14
|
-
required: boolean;
|
|
15
|
-
size: 1 | 2 | 3 | 4;
|
|
16
11
|
}
|
|
17
|
-
export interface FileUpload {
|
|
18
|
-
id: string;
|
|
12
|
+
export interface FileUpload extends GSteps.GBaseStep {
|
|
19
13
|
type: Types.FILEUPLOAD;
|
|
20
14
|
label: string;
|
|
21
15
|
description: string | null;
|
|
22
16
|
required: boolean;
|
|
23
17
|
value: string[];
|
|
24
18
|
}
|
|
25
|
-
export interface Separator {
|
|
26
|
-
id: string;
|
|
19
|
+
export interface Separator extends GSteps.GSeparator {
|
|
27
20
|
type: Types.SEPARATOR;
|
|
28
|
-
transparent: boolean;
|
|
29
21
|
}
|
|
30
|
-
export interface TextArea {
|
|
31
|
-
id: string;
|
|
22
|
+
export interface TextArea extends GSteps.GTextArea {
|
|
32
23
|
type: Types.TEXTAREA;
|
|
33
|
-
label: string;
|
|
34
|
-
description: string | null;
|
|
35
|
-
required: boolean;
|
|
36
|
-
hasTextEditor: boolean;
|
|
37
24
|
}
|
|
38
|
-
export interface TextInput {
|
|
39
|
-
id: string;
|
|
25
|
+
export interface TextInput extends GSteps.GTextInput {
|
|
40
26
|
type: Types.TEXTINPUT;
|
|
41
|
-
label: string;
|
|
42
|
-
description: string | null;
|
|
43
|
-
validation?: FormValidation;
|
|
44
|
-
required: boolean;
|
|
45
|
-
size: 1 | 2 | 3 | 4;
|
|
46
27
|
}
|
|
47
|
-
export interface DatePicker {
|
|
48
|
-
id: string;
|
|
28
|
+
export interface DatePicker extends GSteps.GDatePicker {
|
|
49
29
|
type: Types.DATEPICKER;
|
|
50
|
-
label: string;
|
|
51
|
-
pickTime: boolean;
|
|
52
|
-
description: string | null;
|
|
53
|
-
required: boolean;
|
|
54
|
-
size: 1 | 2 | 3 | 4;
|
|
55
30
|
}
|
|
56
|
-
|
|
57
|
-
message: string;
|
|
58
|
-
value: string;
|
|
59
|
-
};
|
|
60
|
-
export interface FormSelector {
|
|
61
|
-
id: string;
|
|
31
|
+
export interface FormSelector extends GSteps.GBaseStep {
|
|
62
32
|
type: Types.SELECTOR;
|
|
63
33
|
label: string;
|
|
64
34
|
description: string;
|
|
@@ -85,8 +55,7 @@ interface AddSectionOption {
|
|
|
85
55
|
type: OptionTypes.ADD_SECTION;
|
|
86
56
|
idSection: string;
|
|
87
57
|
}
|
|
88
|
-
export interface ClassifierSelector {
|
|
89
|
-
id: string;
|
|
58
|
+
export interface ClassifierSelector extends GSteps.GBaseStep {
|
|
90
59
|
type: Types.CLASSIFIER_SELECTOR;
|
|
91
60
|
idClassifier: string | null;
|
|
92
61
|
label: string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface GBaseStep {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
dependencies?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface GTitle extends GBaseStep {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface GCheckBox extends GBaseStep {
|
|
11
|
+
label: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
required: boolean;
|
|
14
|
+
size: 1 | 2 | 3 | 4;
|
|
15
|
+
}
|
|
16
|
+
export interface GSeparator extends GBaseStep {
|
|
17
|
+
transparent: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface GTextArea extends GBaseStep {
|
|
20
|
+
label: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
required: boolean;
|
|
23
|
+
hasTextEditor: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface GTextInput extends GBaseStep {
|
|
26
|
+
label: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
validation?: {
|
|
29
|
+
message: string;
|
|
30
|
+
value: string;
|
|
31
|
+
type: 'EMAIL' | 'OTHER';
|
|
32
|
+
};
|
|
33
|
+
required: boolean;
|
|
34
|
+
showIcon?: boolean;
|
|
35
|
+
size: 1 | 2 | 3 | 4;
|
|
36
|
+
}
|
|
37
|
+
export interface GDatePicker extends GBaseStep {
|
|
38
|
+
label: string;
|
|
39
|
+
description: string | null;
|
|
40
|
+
pickTime: boolean;
|
|
41
|
+
required: boolean;
|
|
42
|
+
size: 1 | 2 | 3 | 4;
|
|
43
|
+
}
|
|
44
|
+
export interface GAgentPicker extends GBaseStep {
|
|
45
|
+
label: string;
|
|
46
|
+
description: string | null;
|
|
47
|
+
required: boolean;
|
|
48
|
+
multiple: boolean;
|
|
49
|
+
size: 1 | 2 | 3 | 4;
|
|
50
|
+
}
|
|
51
|
+
export interface GSmartSelect extends GBaseStep {
|
|
52
|
+
label: string;
|
|
53
|
+
description: string | null;
|
|
54
|
+
showIcon: boolean;
|
|
55
|
+
required: boolean;
|
|
56
|
+
searchable: boolean;
|
|
57
|
+
size: 1 | 2 | 3 | 4;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/App.js
CHANGED
|
@@ -68,10 +68,18 @@ 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,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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, _f = _a.customSend, customSend = _f === void 0 ? function (a, b) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
// eslint-disable-next-line no-console
|
|
74
|
+
console.log('HOLA', a, b);
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
});
|
|
77
|
+
}); } : _f, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
78
|
+
// eslint-disable-next-line no-console
|
|
79
|
+
console.log(formData, valuesData, customSend);
|
|
80
|
+
var _g = useState(undefined), form = _g[0], setForm = _g[1];
|
|
81
|
+
var _h = useState({}), originalValues = _h[0], setOriginalValues = _h[1];
|
|
82
|
+
var _j = useState(undefined), organizationInfo = _j[0], setOrganizationInfo = _j[1];
|
|
75
83
|
function fetchPreview(formData) {
|
|
76
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
85
|
var response;
|
|
@@ -283,10 +291,21 @@ var migrateFormData = function (form) {
|
|
|
283
291
|
steps[idStep] = step;
|
|
284
292
|
}
|
|
285
293
|
var newForm = __assign(__assign({}, form), { steps: steps });
|
|
286
|
-
if (form.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
if (form.size === undefined) {
|
|
295
|
+
if (form.spacingSize) {
|
|
296
|
+
newForm.size = {
|
|
297
|
+
spacingSize: form.spacingSize,
|
|
298
|
+
blockNum: form.blockNum,
|
|
299
|
+
blockSize: form.blockSize,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
newForm.size = {
|
|
304
|
+
spacingSize: 20,
|
|
305
|
+
blockNum: 4,
|
|
306
|
+
blockSize: 210,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
290
309
|
}
|
|
291
310
|
return newForm;
|
|
292
311
|
};
|
package/dist/App.module.css
CHANGED
|
@@ -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, customSend, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
3
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, customSend, handleLoaded, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
4
4
|
export default ColumnForm;
|
|
@@ -70,20 +70,22 @@ 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, customSend = _a.customSend, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "customSend", "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, handleLoaded = _a.handleLoaded, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "customSend", "handleLoaded", "originalValues"]);
|
|
74
74
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
75
|
-
var _c =
|
|
76
|
-
|
|
75
|
+
var _c = useState(calcDependencies(form.steps, originalValues)), dependencyStore = _c[0], setDependencyStore = _c[1];
|
|
76
|
+
var _d = useForm({
|
|
77
|
+
defaultValues: mapOriginalValues(originalValues, form),
|
|
77
78
|
mode: 'onTouched',
|
|
78
79
|
shouldFocusError: true,
|
|
79
|
-
}), getValues =
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
80
|
+
}), getValues = _d.getValues, setValue = _d.setValue, clearErrors = _d.clearErrors, control = _d.control, errors = _d.formState.errors, trigger = _d.trigger;
|
|
81
|
+
var _e = useState(undefined), sections = _e[0], setSections = _e[1];
|
|
82
|
+
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
83
|
+
var _g = useState(), showConfirmation = _g[0], setShowConfirmation = _g[1];
|
|
83
84
|
useEffect(function () {
|
|
84
85
|
var tempSections = [];
|
|
85
86
|
calcNextSection(form, form.firstSection, tempSections);
|
|
86
87
|
setSections(tempSections);
|
|
88
|
+
handleLoaded();
|
|
87
89
|
}, []);
|
|
88
90
|
if (sections === undefined) {
|
|
89
91
|
return _jsx("div", {}, void 0);
|
|
@@ -150,7 +152,7 @@ function ColumnForm(_a) {
|
|
|
150
152
|
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 () {
|
|
151
153
|
reload();
|
|
152
154
|
setShowConfirmation(undefined);
|
|
153
|
-
} }, 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 &&
|
|
155
|
+
} }, 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, setDependencyStore: setDependencyStore, dependencyStore: dependencyStore, trigger: trigger }, others), index)); }), form.terms &&
|
|
154
156
|
!internal &&
|
|
155
157
|
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": "form__submit", className: styles.submitBtn, onClick: function () {
|
|
156
158
|
onSubmit();
|
|
@@ -174,15 +176,15 @@ function calcNextSection(form, idSection, sections) {
|
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
|
-
var
|
|
178
|
-
var newValues = __assign({},
|
|
179
|
-
for (var _i = 0, _a = Object.keys(
|
|
179
|
+
var mapOriginalValues = function (originalValues, form) {
|
|
180
|
+
var newValues = __assign({}, originalValues);
|
|
181
|
+
for (var _i = 0, _a = Object.keys(originalValues); _i < _a.length; _i++) {
|
|
180
182
|
var val = _a[_i];
|
|
181
183
|
var step = form.steps[val];
|
|
182
184
|
if (step) {
|
|
183
185
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
184
186
|
case Types.TEXTAREA: {
|
|
185
|
-
var value =
|
|
187
|
+
var value = originalValues[step.id];
|
|
186
188
|
if (step.hasTextEditor) {
|
|
187
189
|
delete newValues[step.id];
|
|
188
190
|
}
|
|
@@ -254,3 +256,34 @@ function stringToDraft(text) {
|
|
|
254
256
|
});
|
|
255
257
|
return draftStructure;
|
|
256
258
|
}
|
|
259
|
+
function calcDependencies(steps, originalValues) {
|
|
260
|
+
var dependencies = {};
|
|
261
|
+
for (var _i = 0, _a = Object.values(steps); _i < _a.length; _i++) {
|
|
262
|
+
var step = _a[_i];
|
|
263
|
+
if (step.dependencies) {
|
|
264
|
+
for (var _b = 0, _c = step.dependencies; _b < _c.length; _b++) {
|
|
265
|
+
var idDep = _c[_b];
|
|
266
|
+
var depStep = steps[idDep];
|
|
267
|
+
if (depStep && dependencies[idDep] === undefined) {
|
|
268
|
+
switch (depStep === null || depStep === void 0 ? void 0 : depStep.type) {
|
|
269
|
+
case Types.TEXTAREA: {
|
|
270
|
+
if (depStep.hasTextEditor) {
|
|
271
|
+
dependencies[idDep] = null;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
dependencies[idDep] =
|
|
275
|
+
originalValues[idDep].value;
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
default:
|
|
280
|
+
dependencies[idDep] = originalValues[idDep];
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
dependencies['CBR_PROYECTO'] = null; //REMOVE
|
|
288
|
+
return dependencies;
|
|
289
|
+
}
|
|
@@ -5,6 +5,7 @@ import { CustomStep } from '../../App';
|
|
|
5
5
|
export declare const getLocale: () => any;
|
|
6
6
|
export interface WidthStats {
|
|
7
7
|
currentBreakPoint: number;
|
|
8
|
+
isResponsive: boolean;
|
|
8
9
|
isMobile: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface FormComponentProps {
|
|
@@ -21,8 +22,10 @@ export interface FormComponentProps {
|
|
|
21
22
|
apiKey: string | undefined;
|
|
22
23
|
/** Function to call on postview to fetch the download url of a file */
|
|
23
24
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
25
|
+
/** Function to call when the form has loaded */
|
|
26
|
+
handleLoaded: () => void;
|
|
24
27
|
}
|
|
25
|
-
declare function FormComponent({ form, internal, postview, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle'> & {
|
|
28
|
+
declare function FormComponent({ form, internal, postview, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'handleLoaded'> & {
|
|
26
29
|
containerRef: any;
|
|
27
30
|
organization: Organization | null;
|
|
28
31
|
}): JSX.Element;
|
|
@@ -47,25 +47,30 @@ export var getLocale = function () {
|
|
|
47
47
|
navigator.language ||
|
|
48
48
|
navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
|
|
49
49
|
};
|
|
50
|
-
var blockSize = 210;
|
|
51
|
-
var spacingSize = 20;
|
|
52
|
-
var blockNum = 4;
|
|
53
50
|
function FormComponent(_a) {
|
|
54
51
|
var _b, _c;
|
|
55
52
|
var form = _a.form, internal = _a.internal, postview = _a.postview, organization = _a.organization, containerRef = _a.containerRef, others = __rest(_a, ["form", "internal", "postview", "organization", "containerRef"]);
|
|
56
|
-
var _d = useState(
|
|
53
|
+
var _d = useState(false), loaded = _d[0], setLoaded = _d[1];
|
|
54
|
+
var _e = useState(undefined), widthStats = _e[0], setWidthStats = _e[1];
|
|
57
55
|
/** Calcs the currentBreakPoint and if is mobile */
|
|
58
56
|
var handleResize = function () {
|
|
59
57
|
var _a;
|
|
60
58
|
var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
|
61
59
|
if (currentWidth !== undefined) {
|
|
62
|
-
var currentBreakPoint = blockNum;
|
|
60
|
+
var currentBreakPoint = form.size.blockNum;
|
|
63
61
|
while (currentWidth <
|
|
64
|
-
(blockSize + spacingSize) *
|
|
62
|
+
(form.size.blockSize + form.size.spacingSize) *
|
|
63
|
+
currentBreakPoint +
|
|
64
|
+
40) {
|
|
65
65
|
currentBreakPoint--;
|
|
66
66
|
}
|
|
67
67
|
setWidthStats({
|
|
68
|
-
|
|
68
|
+
isResponsive: currentWidth <
|
|
69
|
+
(form.size.blockSize + form.size.spacingSize) *
|
|
70
|
+
form.size.blockNum +
|
|
71
|
+
40,
|
|
72
|
+
isMobile: currentWidth <
|
|
73
|
+
(form.size.blockSize + form.size.spacingSize) * 2 + 40,
|
|
69
74
|
currentBreakPoint: currentBreakPoint,
|
|
70
75
|
});
|
|
71
76
|
}
|
|
@@ -85,13 +90,20 @@ function FormComponent(_a) {
|
|
|
85
90
|
backgroundColor: internal
|
|
86
91
|
? InternalFormStyle.backgroundColor
|
|
87
92
|
: form.style.backgroundColor,
|
|
88
|
-
} }, { children: _jsx(FormTypeComponent, __assign({}, others, {
|
|
93
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { handleLoaded: function () {
|
|
94
|
+
setLoaded(true);
|
|
95
|
+
}, widthStats: widthStats, form: form, internal: internal, postview: postview, formStyle: internal ? InternalFormStyle : form.style }), void 0) }), void 0));
|
|
89
96
|
}
|
|
90
97
|
else if (organization && widthStats !== undefined) {
|
|
91
98
|
//Standalone cant have widget
|
|
92
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_c = organization.styles) === null || _c === void 0 ? void 0 : _c.primaryColor }, void 0), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.
|
|
99
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_c = organization.styles) === null || _c === void 0 ? void 0 : _c.primaryColor }, void 0), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
|
|
93
100
|
? styles.fullScreenStandAloneForm
|
|
94
|
-
: styles.standAloneFormCard, style: {
|
|
101
|
+
: styles.standAloneFormCard, style: {
|
|
102
|
+
backgroundColor: form.style.backgroundColor,
|
|
103
|
+
visibility: loaded ? 'visible' : 'hidden',
|
|
104
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style, handleLoaded: function () {
|
|
105
|
+
setLoaded(true);
|
|
106
|
+
} }), void 0) }), void 0) }), void 0)] }, void 0));
|
|
95
107
|
}
|
|
96
108
|
else {
|
|
97
109
|
return _jsx("div", {}, void 0);
|
|
@@ -27,7 +27,8 @@ import styles from './MaterialSection.module.css';
|
|
|
27
27
|
function MaterialSection(_a) {
|
|
28
28
|
var section = _a.section, form = _a.form, others = __rest(_a, ["section", "form"]);
|
|
29
29
|
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
30
|
-
width: (form.blockSize + form.spacingSize) *
|
|
30
|
+
width: (form.size.blockSize + form.size.spacingSize) *
|
|
31
|
+
form.size.blockNum,
|
|
31
32
|
} }, { children: section.steps.map(function (idStep, index) {
|
|
32
33
|
var step = form.steps[idStep];
|
|
33
34
|
if (step) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Control, FieldValues, UseFormGetValues } from 'react-hook-form';
|
|
2
|
+
import { Control, FieldValues, UseFormGetValues, UseFormTrigger } from 'react-hook-form';
|
|
3
3
|
import { Form, FormStyle, Section } from '../../@Types/Form';
|
|
4
4
|
import { CustomStep } from '../../App';
|
|
5
5
|
import { WidthStats } from '../Form/Form';
|
|
@@ -17,6 +17,9 @@ export interface RecursiveData {
|
|
|
17
17
|
customSteps: Record<string, CustomStep>;
|
|
18
18
|
/** Function to call on postview to fetch the download url of a file */
|
|
19
19
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
20
|
+
dependencyStore: Record<string, any>;
|
|
21
|
+
setDependencyStore: (values: Record<string, any>) => void;
|
|
22
|
+
trigger: UseFormTrigger<any>;
|
|
20
23
|
}
|
|
21
24
|
export interface SectionComponentProps extends RecursiveData {
|
|
22
25
|
section: Section;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CBRIncidentsStep as CBRIncidentsStepType } from '../../../../@Types/CBRFormStep';
|
|
3
|
+
import { StepProps } from '../../Step';
|
|
4
|
+
export interface CBRIncidentsStepProps extends Omit<StepProps, 'step'> {
|
|
5
|
+
/** The CBRIncidentsStep to display */
|
|
6
|
+
step: CBRIncidentsStepType;
|
|
7
|
+
}
|
|
8
|
+
declare function CBRIncidentsStep(props: CBRIncidentsStepProps): JSX.Element;
|
|
9
|
+
export default CBRIncidentsStep;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { FormStyleTypes } from '../../../../constants/FormStepTypes';
|
|
14
|
+
import MaterialCBRIncidentsStep from './MaterialCBRIncidentsStep/MaterialCBRIncidentsStep';
|
|
15
|
+
function CBRIncidentsStep(props) {
|
|
16
|
+
switch (props.formStyle.type) {
|
|
17
|
+
case FormStyleTypes.MATERIAL: {
|
|
18
|
+
return _jsx(MaterialCBRIncidentsStep, __assign({}, props), void 0);
|
|
19
|
+
}
|
|
20
|
+
default: {
|
|
21
|
+
return _jsx(MaterialCBRIncidentsStep, __assign({}, props), void 0);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export default CBRIncidentsStep;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CBRIncidentsStepProps } from '../../CBRIncidentsStep';
|
|
3
|
+
import { Incident } from '../MaterialCBRIncidentsStep';
|
|
4
|
+
declare function IncidentComponent({ step, form, level, incident, formStyle, handleDelete, ...others }: CBRIncidentsStepProps & {
|
|
5
|
+
incident: Incident;
|
|
6
|
+
handleDelete: Function;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default IncidentComponent;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import styles from './Incident.module.css';
|
|
25
|
+
import StepComponent from '../../../../Step';
|
|
26
|
+
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
27
|
+
function IncidentComponent(_a) {
|
|
28
|
+
var step = _a.step, form = _a.form, level = _a.level, incident = _a.incident, formStyle = _a.formStyle, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "form", "level", "incident", "formStyle", "handleDelete"]);
|
|
29
|
+
var spaceStep = form.steps[incident.idSpaceStep];
|
|
30
|
+
var elementStep = form.steps[incident.idElementStep];
|
|
31
|
+
var commentStep = form.steps[incident.idCommentStep];
|
|
32
|
+
if (incident.deleted) {
|
|
33
|
+
return _jsx("div", {}, void 0);
|
|
34
|
+
}
|
|
35
|
+
return (_jsx("div", __assign({ className: others.widthStats.isMobile
|
|
36
|
+
? styles.mobileContainer
|
|
37
|
+
: styles.container }, { children: _jsxs("div", __assign({ className: styles.contentContainer, style: {
|
|
38
|
+
width: (form.size.blockSize + form.size.spacingSize) *
|
|
39
|
+
(form.size.blockNum - 1),
|
|
40
|
+
} }, { children: [_jsxs("div", __assign({ className: styles.titleLbl, style: { color: formStyle.textColor } }, { children: [step.unitLabel + ' ' + incident.num, ":"] }), void 0), _jsx("div", __assign({ className: others.postview
|
|
41
|
+
? styles.disabledDeleteBtn
|
|
42
|
+
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: function () {
|
|
43
|
+
if (!others.postview) {
|
|
44
|
+
handleDelete();
|
|
45
|
+
}
|
|
46
|
+
} }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsx(StepComponent, __assign({}, others, { formStyle: formStyle, form: form, step: spaceStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: elementStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: commentStep, handleSizeChange: function () { }, level: level + 1 }), void 0)] }), void 0) }), void 0));
|
|
47
|
+
}
|
|
48
|
+
export default IncidentComponent;
|