@arquimedes.co/eureka-forms 2.0.20-test → 2.0.21
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/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +1 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +23 -23
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +6 -0
- package/dist/FormSteps/StepFunctions.js +1 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +2 -2
- package/package.json +2 -2
|
@@ -7,5 +7,5 @@ export interface Incident {
|
|
|
7
7
|
deleted?: boolean;
|
|
8
8
|
num: number;
|
|
9
9
|
}
|
|
10
|
-
declare function CBRIncidentsStep(
|
|
10
|
+
declare function CBRIncidentsStep({ step, editable, ...others }: CBRIncidentsStepProps): JSX.Element;
|
|
11
11
|
export default CBRIncidentsStep;
|
|
@@ -41,27 +41,37 @@ import FormContext from '../../../../Contexts/FormContext';
|
|
|
41
41
|
import { addStepsDependencies } from '../../../../States/SiteSlice';
|
|
42
42
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
43
43
|
import CustomContext from '../../../../Contexts/CustomContext';
|
|
44
|
-
import {
|
|
45
|
-
function
|
|
46
|
-
var step = _a.step,
|
|
44
|
+
import { useFormStep } from '../../../StepHooks';
|
|
45
|
+
function CBRIncidentsStep(_a) {
|
|
46
|
+
var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
|
|
47
|
+
console.log(step.required);
|
|
48
|
+
var _b = useFormStep(step, {
|
|
49
|
+
rules: {
|
|
50
|
+
validate: function (array) {
|
|
51
|
+
return !step.required ||
|
|
52
|
+
(step.required &&
|
|
53
|
+
array.filter(function (elem) { return !elem.deleted; }).length > 0);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}), ref = _b.ref, value = _b.value, onChange = _b.onChange, error = _b.error;
|
|
47
57
|
var customSteps = useContext(CustomContext).customSteps;
|
|
48
|
-
var
|
|
58
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
49
59
|
var dispatch = useAppDispatch();
|
|
50
60
|
var form = useContext(FormContext);
|
|
51
61
|
/** Form to pass down with aditional steps */
|
|
52
|
-
var
|
|
53
|
-
var
|
|
62
|
+
var _d = useState(__assign(__assign({}, form), { steps: __assign({}, form.steps) })), localForm = _d[0], setLocalForm = _d[1];
|
|
63
|
+
var _e = useState(false), firstRender = _e[0], setFirstRender = _e[1];
|
|
54
64
|
useEffect(function () {
|
|
55
65
|
setFirstRender(true);
|
|
56
66
|
}, []);
|
|
57
67
|
useEffect(function () {
|
|
58
|
-
if (firstRender &&
|
|
68
|
+
if (firstRender && value.length === 0 && !postview && editable) {
|
|
59
69
|
handleAddIncident();
|
|
60
70
|
}
|
|
61
71
|
}, [firstRender]);
|
|
62
72
|
var handleAddIncident = function () {
|
|
63
73
|
var _a, _b;
|
|
64
|
-
var current =
|
|
74
|
+
var current = value.filter(function (incident) { return !incident.deleted; });
|
|
65
75
|
var newIncident = {
|
|
66
76
|
idSpaceStep: CBRFormStepTypes.CBR_TIPO_ESPACIO + '-' + nanoid(),
|
|
67
77
|
idCommentStep: CBRFormStepTypes.CBR_COMENTARIO + '-' + nanoid(),
|
|
@@ -72,7 +82,7 @@ function Incidents(_a) {
|
|
|
72
82
|
newSteps[newIncident.idSpaceStep] = __assign(__assign({}, step.spaceStep), { id: newIncident.idSpaceStep, type: CBRFormStepTypes.CBR_TIPO_ESPACIO, dependencies: step.dependencies });
|
|
73
83
|
newSteps[newIncident.idCommentStep] = __assign(__assign({}, step.commentStep), { id: newIncident.idCommentStep, type: CBRFormStepTypes.CBR_COMENTARIO });
|
|
74
84
|
addRecursiveElementStep(newIncident.idElementStep, step.elementStep, null, newSteps, (_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '');
|
|
75
|
-
onChange(__spreadArray(__spreadArray([],
|
|
85
|
+
onChange(__spreadArray(__spreadArray([], value, true), [newIncident], false));
|
|
76
86
|
setLocalForm(__assign(__assign({}, localForm), { steps: newSteps }));
|
|
77
87
|
dispatch(addStepsDependencies({
|
|
78
88
|
steps: newSteps,
|
|
@@ -98,8 +108,8 @@ function Incidents(_a) {
|
|
|
98
108
|
margin: step.description
|
|
99
109
|
? '10px 0px'
|
|
100
110
|
: '0px 0px 5px 0px',
|
|
101
|
-
} }, { children: step.description }))), _jsx(FormContext.Provider, __assign({ value: localForm }, { children:
|
|
102
|
-
var tempIncidents = __spreadArray([],
|
|
111
|
+
} }, { children: step.description }))), _jsx(FormContext.Provider, __assign({ value: localForm }, { children: value.map(function (incident, index) { return (_jsx(IncidentComponent, __assign({ incident: incident, step: step, editable: editable, handleDelete: function () {
|
|
112
|
+
var tempIncidents = __spreadArray([], value, true);
|
|
103
113
|
tempIncidents[index].deleted = true;
|
|
104
114
|
var n = 1;
|
|
105
115
|
for (var _i = 0, tempIncidents_1 = tempIncidents; _i < tempIncidents_1.length; _i++) {
|
|
@@ -110,20 +120,10 @@ function Incidents(_a) {
|
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
onChange(tempIncidents);
|
|
113
|
-
} }, others), index)); }) })), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref:
|
|
123
|
+
} }, others), index)); }) })), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: ref, className: 'hidden-input' }), _jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
114
124
|
if (editable && !postview) {
|
|
115
125
|
handleAddIncident();
|
|
116
126
|
}
|
|
117
|
-
} })] }))] })));
|
|
118
|
-
}
|
|
119
|
-
function CBRIncidentsStep(props) {
|
|
120
|
-
return (_jsx(Controller, { name: props.step.id, defaultValue: [], rules: {
|
|
121
|
-
required: props.step.required
|
|
122
|
-
? 'Este campo es obligatorio'
|
|
123
|
-
: undefined,
|
|
124
|
-
}, shouldUnregister: true, render: function (_a) {
|
|
125
|
-
var _b = _a.field, ref = _b.ref, value = _b.value, field = __rest(_b, ["ref", "value"]);
|
|
126
|
-
return (_jsx(Incidents, __assign({}, props, field, { incidents: value, onChange: field.onChange, btnRef: ref })));
|
|
127
|
-
} }));
|
|
127
|
+
} })] })), !!error && value.filter(function (elem) { return !elem.deleted; }).length === 0 && (_jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: "Este campo es obligatorio" })))] })));
|
|
128
128
|
}
|
|
129
129
|
export default CBRIncidentsStep;
|
|
@@ -126,9 +126,9 @@ function TextAreaStep(_a) {
|
|
|
126
126
|
if (canEdit) {
|
|
127
127
|
setFocus(true);
|
|
128
128
|
}
|
|
129
|
-
} }, { children: _jsx(Editor, __assign({}, field, { editorRef: ref, onFocus: function () {
|
|
129
|
+
}, "data-testid": step.id }, { children: _jsx(Editor, __assign({}, field, { editorRef: ref, onFocus: function () {
|
|
130
130
|
setFocus(true);
|
|
131
|
-
}, readOnly: !canEdit, stripPastedStyles: true, onEditorStateChange: handleChange, toolbarClassName: !canEdit ? ' postview-editor-toolbar' : '',
|
|
131
|
+
}, readOnly: !canEdit, stripPastedStyles: true, onEditorStateChange: handleChange, toolbarClassName: !canEdit ? ' postview-editor-toolbar' : '', editorClassName: editorClassName, wrapperClassName: styles.wrapper, placeholder: (_b = step.description) !== null && _b !== void 0 ? _b : '', toolbar: {
|
|
132
132
|
options: ['inline', 'list', 'history'],
|
|
133
133
|
inline: {
|
|
134
134
|
options: [
|
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":"2.0.
|
|
4
|
+
"version": "2.0.21",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "react-scripts test",
|
|
10
10
|
"test-ci": "react-scripts test --reporters=default --reporters=jest-junit --coverage --coverageReporters cobertura html",
|
|
11
11
|
"tsc-build": "tsc --noEmit false --outDir ./dist --incremental false",
|
|
12
|
-
"watch": "tsc -w --preserveWatchOutput",
|
|
12
|
+
"watch": "tsc -w --noEmit false --outDir ./dist --preserveWatchOutput",
|
|
13
13
|
"storybook": "storybook dev -p 6006",
|
|
14
14
|
"build-storybook": "storybook build",
|
|
15
15
|
"cypress": "DISPLAY=:0 cypress open"
|