@arquimedes.co/eureka-forms 2.0.37-test → 2.0.37
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.
|
@@ -19,7 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
import React, { useContext, useMemo } from 'react';
|
|
22
|
+
import React, { useContext, useEffect, useMemo } from 'react';
|
|
23
23
|
import { OptionTypes } from '../../../constants/FormStepTypes';
|
|
24
24
|
import StepComponent from '../../Step';
|
|
25
25
|
import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
@@ -81,6 +81,12 @@ function SelectorStep(_a) {
|
|
|
81
81
|
return false;
|
|
82
82
|
});
|
|
83
83
|
}, idDependencies.map(function (id) { return dependencies[id].value; }));
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
if (filteredOptions.find(function (option) { return option.value === (value === null || value === void 0 ? void 0 : value.value); }) ===
|
|
86
|
+
undefined) {
|
|
87
|
+
onChange('');
|
|
88
|
+
}
|
|
89
|
+
}, [filteredOptions]);
|
|
84
90
|
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { value: value, inputRef: ref, handleUpdate: onChange, disabled: false, loading: false, options: filteredOptions, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_b = formStyle.stepBackgroundColor) !== null && _b !== void 0 ? _b : 'white', label: step.label, required: step.required, height: '31px', searchable: step.searchable, icon: undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", getOptionSelected: function (option, value) {
|
|
85
91
|
return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
|
|
86
92
|
}, helperText: (_d = (_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : step.description, error: !!error })) })), value && mapNestedOption()] }));
|
|
@@ -268,19 +268,20 @@ export var calcSubSteps = function (idStep, allSteps, idModifier) {
|
|
|
268
268
|
return subSteps;
|
|
269
269
|
};
|
|
270
270
|
export var evaluateCondition = function (condition, dependencies) {
|
|
271
|
+
var _a, _b;
|
|
271
272
|
switch (condition.type) {
|
|
272
273
|
case ConditionTypes.EXPRESSION: {
|
|
273
274
|
if (condition.expression === ExpressionTypes.OR) {
|
|
274
|
-
for (var _i = 0,
|
|
275
|
-
var subCondition =
|
|
275
|
+
for (var _i = 0, _c = condition.conditions; _i < _c.length; _i++) {
|
|
276
|
+
var subCondition = _c[_i];
|
|
276
277
|
if (evaluateCondition(subCondition, dependencies))
|
|
277
278
|
return true;
|
|
278
279
|
}
|
|
279
280
|
return false;
|
|
280
281
|
}
|
|
281
282
|
else {
|
|
282
|
-
for (var
|
|
283
|
-
var subCondition =
|
|
283
|
+
for (var _d = 0, _e = condition.conditions; _d < _e.length; _d++) {
|
|
284
|
+
var subCondition = _e[_d];
|
|
284
285
|
if (!evaluateCondition(subCondition, dependencies))
|
|
285
286
|
return false;
|
|
286
287
|
}
|
|
@@ -313,9 +314,11 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
313
314
|
var propertyDate = new Date(condition.value);
|
|
314
315
|
switch (condition.operator) {
|
|
315
316
|
case OperatorTypes.EQUAL:
|
|
316
|
-
return value.
|
|
317
|
+
return (value.toUTCString().split('T')[0] ===
|
|
318
|
+
propertyDate.toUTCString().split('T')[0]);
|
|
317
319
|
case OperatorTypes.NOTEQUAL:
|
|
318
|
-
return value.
|
|
320
|
+
return (value.toUTCString().split('T')[0] !==
|
|
321
|
+
propertyDate.toUTCString().split('T')[0]);
|
|
319
322
|
case OperatorTypes.LESS:
|
|
320
323
|
return value.getTime() < propertyDate.getTime();
|
|
321
324
|
case OperatorTypes.MORE:
|
|
@@ -326,28 +329,26 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
326
329
|
}
|
|
327
330
|
case FormStepTypes.SELECTOR: {
|
|
328
331
|
if (condition.operator === OperatorTypes.EQUAL) {
|
|
329
|
-
return condition.value === value;
|
|
332
|
+
return condition.value === (value === null || value === void 0 ? void 0 : value.value);
|
|
330
333
|
}
|
|
331
334
|
else {
|
|
332
|
-
return !(condition.value === value);
|
|
335
|
+
return !(condition.value === (value === null || value === void 0 ? void 0 : value.value));
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
338
|
case FormStepTypes.TEXTINPUT: {
|
|
336
339
|
if (condition.operator === OperatorTypes.INCLUDES) {
|
|
337
|
-
return value
|
|
338
|
-
.toLowerCase()
|
|
339
|
-
.includes(condition.value.toLowerCase());
|
|
340
|
+
return (_a = value === null || value === void 0 ? void 0 : value.toLowerCase()) === null || _a === void 0 ? void 0 : _a.includes(condition.value.toLowerCase());
|
|
340
341
|
}
|
|
341
342
|
else if (condition.operator === OperatorTypes.NOTINCLUDES) {
|
|
342
|
-
return !value
|
|
343
|
-
.toLowerCase()
|
|
344
|
-
.includes(condition.value.toLowerCase());
|
|
343
|
+
return !((_b = value === null || value === void 0 ? void 0 : value.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(condition.value.toLowerCase()));
|
|
345
344
|
}
|
|
346
345
|
else if (condition.operator === OperatorTypes.EQUAL) {
|
|
347
|
-
return condition.value ===
|
|
346
|
+
return (condition.value.toLowerCase() ===
|
|
347
|
+
(value === null || value === void 0 ? void 0 : value.toLowerCase()));
|
|
348
348
|
}
|
|
349
349
|
else if (condition.operator === OperatorTypes.NOTEQUAL) {
|
|
350
|
-
return !(condition.value ===
|
|
350
|
+
return !(condition.value.toLowerCase() ===
|
|
351
|
+
(value === null || value === void 0 ? void 0 : value.toLowerCase()));
|
|
351
352
|
}
|
|
352
353
|
else {
|
|
353
354
|
return false;
|
|
@@ -361,10 +362,11 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
361
362
|
}
|
|
362
363
|
regx += ')\\b';
|
|
363
364
|
if (condition.operator === OperatorTypes.INCLUDES) {
|
|
364
|
-
return new RegExp(regx).test(value.toLowerCase());
|
|
365
|
+
return (value && new RegExp(regx).test(value.toLowerCase()));
|
|
365
366
|
}
|
|
366
367
|
else {
|
|
367
|
-
return !
|
|
368
|
+
return (!value ||
|
|
369
|
+
!new RegExp(regx).test(value.toLowerCase()));
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
case FormStepTypes.RATING: {
|
|
@@ -389,7 +391,7 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
389
391
|
}
|
|
390
392
|
case FormStepTypes.CLASSIFIER_SELECTOR: {
|
|
391
393
|
var boolFactor = condition.operator === OperatorTypes.EQUAL;
|
|
392
|
-
if (value === condition.idValue) {
|
|
394
|
+
if ((value === null || value === void 0 ? void 0 : value.value) === condition.idValue) {
|
|
393
395
|
//Si op es EQUALS (boolfactor true) evaluará a true
|
|
394
396
|
//Si op es NOTEQUALS (boolfactor false) evaluará a false
|
|
395
397
|
return boolFactor;
|
|
@@ -400,9 +402,9 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
400
402
|
}
|
|
401
403
|
case FormStepTypes.ENTITYVALUEPICKER: {
|
|
402
404
|
var boolFactor = condition.operator === OperatorTypes.EQUAL;
|
|
403
|
-
for (var
|
|
404
|
-
var idEntityValue =
|
|
405
|
-
if (value._id === idEntityValue) {
|
|
405
|
+
for (var _f = 0, _g = condition.values; _f < _g.length; _f++) {
|
|
406
|
+
var idEntityValue = _g[_f];
|
|
407
|
+
if ((value === null || value === void 0 ? void 0 : value._id) === idEntityValue) {
|
|
406
408
|
return boolFactor;
|
|
407
409
|
}
|
|
408
410
|
}
|
|
@@ -83,7 +83,7 @@ function CustomCheckBox(_a) {
|
|
|
83
83
|
uncheckedColor: uncheckedColor,
|
|
84
84
|
checkedHoverColor: checkedColor + '0a',
|
|
85
85
|
})();
|
|
86
|
-
return (_jsx(Checkbox, __assign({}, others, { disabled: cantEdit, classes: classes, checked: checked, onChange: onChange, required: true, icon: _jsx(CheckBoxOutlineBlankRoundedIcon, { fontSize: "inherit" }), checkedIcon: _jsx(CheckBoxRoundedIcon, { fontSize: "inherit" }) })));
|
|
86
|
+
return (_jsx(Checkbox, __assign({}, others, { disabled: cantEdit, classes: classes, checked: checked, onChange: function (event) { return onChange === null || onChange === void 0 ? void 0 : onChange(event.target.checked); }, required: true, icon: _jsx(CheckBoxOutlineBlankRoundedIcon, { fontSize: "inherit" }), checkedIcon: _jsx(CheckBoxRoundedIcon, { fontSize: "inherit" }) })));
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Generic datepicker with apps designs. Is class do to the use in the react-hook-forms library
|
|
@@ -307,7 +307,10 @@ function CustomDatePicker(_a) {
|
|
|
307
307
|
}, variant: "dialog" })));
|
|
308
308
|
}
|
|
309
309
|
else {
|
|
310
|
-
return (_jsx(DatePicker, __assign({}, others, { ref: ref, "data-testid": "date-picker", inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, onChange:
|
|
310
|
+
return (_jsx(DatePicker, __assign({}, others, { ref: ref, "data-testid": "date-picker", inputVariant: "outlined", size: "small", disabled: cantEdit, fullWidth: true, onChange: function (date) {
|
|
311
|
+
if (!date || (!others.value && date))
|
|
312
|
+
onChange(date);
|
|
313
|
+
}, placeholder: format(new Date(), 'P', { locale: getLocale() }), format: "P", required: required, InputLabelProps: { classes: labelClasses }, DialogProps: {
|
|
311
314
|
disableEnforceFocus: true,
|
|
312
315
|
className: datePicker,
|
|
313
316
|
cancelLabel: '',
|
package/package.json
CHANGED