@arquimedes.co/eureka-forms 1.9.35-test → 1.9.36-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.
@@ -79,7 +79,7 @@ function ColumnForm(_a) {
79
79
  defaultValues: originalValues,
80
80
  mode: 'onTouched',
81
81
  shouldFocusError: true,
82
- }), getValues = _d.getValues, setValue = _d.setValue, clearErrors = _d.clearErrors, control = _d.control, errors = _d.formState.errors, trigger = _d.trigger;
82
+ }), getValues = _d.getValues, setValue = _d.setValue, clearErrors = _d.clearErrors, control = _d.control, errors = _d.formState.errors, trigger = _d.trigger, setFocus = _d.setFocus;
83
83
  var recaptchaRef = useRef();
84
84
  var _e = useState(undefined), sections = _e[0], setSections = _e[1];
85
85
  var _f = useState(false), loading = _f[0], setLoading = _f[1];
@@ -164,7 +164,7 @@ function ColumnForm(_a) {
164
164
  return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
165
165
  reload();
166
166
  setShowConfirmation(undefined);
167
- } })), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, sendLabel: sendLabel, 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 &&
167
+ } })), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, sendLabel: sendLabel, 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, setFocus: setFocus }, others), index)); }), form.terms &&
168
168
  (!internal || (internal && postview)) &&
169
169
  (originalValues === null || originalValues === void 0 ? void 0 : originalValues['INTERNAL_CREATING_AGENT']) === undefined && (_jsx("div", __assign({ className: styles.termsContainer, style: {
170
170
  width: (form.size.blockSize + form.size.spacingSize) *
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Control, FieldValues, UseFormGetValues, UseFormTrigger } from 'react-hook-form';
2
+ import { Control, FieldValues, UseFormGetValues } from 'react-hook-form';
3
3
  import { Organization } from '../../@Types';
4
4
  import { Form, FormStyle, Section } from '../../@Types/Form';
5
5
  import { CustomStep } from '../../App';
@@ -24,7 +24,7 @@ export interface RecursiveData {
24
24
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
25
25
  dependencyStore: Record<string, any>;
26
26
  setDependencyStore: (values: Record<string, any>) => void;
27
- trigger: UseFormTrigger<any>;
27
+ setFocus: (id: string) => void;
28
28
  }
29
29
  export interface SectionComponentProps extends RecursiveData {
30
30
  /** The custom send label to display */
@@ -88,7 +88,7 @@ function EntityValuePickerStep(_a) {
88
88
  if (typeof currentValue === 'string')
89
89
  value = currentValue;
90
90
  else
91
- value = (_c = currentValue.id) !== null && _c !== void 0 ? _c : currentValue.id;
91
+ value = (_c = currentValue._id) !== null && _c !== void 0 ? _c : currentValue.id;
92
92
  //TODO: Manejo de multiple!
93
93
  }
94
94
  else if (filter.required) {
@@ -38,6 +38,7 @@ import RoundedButton from '../../../../shared/RoundedButton/RoundedButton';
38
38
  import { nanoid } from 'nanoid';
39
39
  import { calcStepDependencyValue } from '../../../Form/ColumnForm/ColumnForm';
40
40
  import MapperElementComponent from './Element/MapperElement';
41
+ import AYFFormStepTypes from '../../../../constants/AYFFormStepTypes';
41
42
  function Elements(_a) {
42
43
  var step = _a.step, form = _a.form, btnRef = _a.btnRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, elements = _a.elements, formStyle = _a.formStyle, dependencyStore = _a.dependencyStore, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["step", "form", "btnRef", "editable", "postview", "onChange", "elements", "formStyle", "dependencyStore", "setDependencyStore"]);
43
44
  var _b = useState(false), firstRender = _b[0], setFirstRender = _b[1];
@@ -80,7 +81,7 @@ function Elements(_a) {
80
81
  var newSteps = {};
81
82
  for (var _i = 0, _a = Object.keys(step.steps); _i < _a.length; _i++) {
82
83
  var idStep = _a[_i];
83
- var baseStep = JSON.parse(JSON.stringify(form.steps[idStep]));
84
+ var baseStep = JSON.parse(JSON.stringify(step.steps[idStep]));
84
85
  var newIdStep = step.id + '-' + idStep + '-' + idElement;
85
86
  baseStep.id = newIdStep;
86
87
  newElement.ids[idStep] = newIdStep;
@@ -138,7 +139,7 @@ function calcRecursiveData(element, newSteps, deps) {
138
139
  var idDep = step.dependencies[i];
139
140
  var newId = element.ids[idDep];
140
141
  if (newId) {
141
- step.dependencies[i] = element.ids[newId];
142
+ step.dependencies[i] = newId;
142
143
  deps[newId] = calcStepDependencyValue(newSteps[newId], {});
143
144
  }
144
145
  }
@@ -182,6 +183,28 @@ function calcRecursiveData(element, newSteps, deps) {
182
183
  }
183
184
  }
184
185
  break;
186
+ case StepTypes.ENTITYVALUEPICKER:
187
+ for (var _h = 0, _j = step.filters; _h < _j.length; _h++) {
188
+ var filter = _j[_h];
189
+ if (filter.idStep) {
190
+ var newId = element.ids[filter.idStep];
191
+ if (newId) {
192
+ filter.idStep = newId;
193
+ deps[newId] = calcStepDependencyValue(newSteps[newId], {});
194
+ }
195
+ }
196
+ }
197
+ break;
198
+ case AYFFormStepTypes.AYF_ICA_CITY:
199
+ var cityStep = step;
200
+ if (cityStep.idNitStep) {
201
+ var newId = element.ids[cityStep.idNitStep];
202
+ if (newId) {
203
+ cityStep.idNitStep = newId;
204
+ deps[newId] = calcStepDependencyValue(newSteps[newId], {});
205
+ }
206
+ }
207
+ break;
185
208
  default:
186
209
  break;
187
210
  }
@@ -66,7 +66,7 @@ import React from 'react';
66
66
  function SmartSelect(_a) {
67
67
  var _this = this;
68
68
  var _b, _c, _d, _e;
69
- var icon = _a.icon, step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, trigger = _a.trigger, children = _a.children, editable = _a.editable, onChange = _a.onChange, inputRef = _a.inputRef, postview = _a.postview, formStyle = _a.formStyle, getOptions = _a.getOptions, widthStats = _a.widthStats, organization = _a.organization, calcDepError = _a.calcDepError, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, originalValues = _a.originalValues, changeListener = _a.changeListener, dependencyStore = _a.dependencyStore, _f = _a.calcInvalidDeps, calcInvalidDeps = _f === void 0 ? function (step, depStore) {
69
+ var icon = _a.icon, step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, setFocus = _a.setFocus, children = _a.children, editable = _a.editable, onChange = _a.onChange, inputRef = _a.inputRef, postview = _a.postview, formStyle = _a.formStyle, getOptions = _a.getOptions, widthStats = _a.widthStats, organization = _a.organization, calcDepError = _a.calcDepError, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, originalValues = _a.originalValues, changeListener = _a.changeListener, dependencyStore = _a.dependencyStore, _f = _a.calcInvalidDeps, calcInvalidDeps = _f === void 0 ? function (step, depStore) {
70
70
  var _a;
71
71
  var missingDeps = [];
72
72
  for (var _i = 0, _b = (_a = step.dependencies) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
@@ -76,7 +76,7 @@ function SmartSelect(_a) {
76
76
  }
77
77
  }
78
78
  return missingDeps;
79
- } : _f, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["icon", "step", "form", "value", "onBlur", "errors", "trigger", "children", "editable", "onChange", "inputRef", "postview", "formStyle", "getOptions", "widthStats", "organization", "calcDepError", "valueOverwrite", "getValueString", "originalValues", "changeListener", "dependencyStore", "calcInvalidDeps", "getValueWarning", "getOptionSelected", "setDependencyStore"]);
79
+ } : _f, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["icon", "step", "form", "value", "onBlur", "errors", "setFocus", "children", "editable", "onChange", "inputRef", "postview", "formStyle", "getOptions", "widthStats", "organization", "calcDepError", "valueOverwrite", "getValueString", "originalValues", "changeListener", "dependencyStore", "calcInvalidDeps", "getValueWarning", "getOptionSelected", "setDependencyStore"]);
80
80
  var _g = useState(true), first = _g[0], setFirst = _g[1];
81
81
  var _h = useState(), options = _h[0], setOptions = _h[1];
82
82
  var _j = useState(), error = _j[0], setError = _j[1];
@@ -164,7 +164,7 @@ function SmartSelect(_a) {
164
164
  setError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(invalids.map(function (idDep) { return form.steps[idDep]; })));
165
165
  if (!value) {
166
166
  if (invalids.length > 0) {
167
- trigger(invalids, { shouldFocus: true });
167
+ setFocus(invalids[0]);
168
168
  }
169
169
  else {
170
170
  setLoading(true);
@@ -194,10 +194,10 @@ function SmartSelect(_a) {
194
194
  if (options === undefined && !(!editable || postview)) {
195
195
  setLoading(true);
196
196
  }
197
- }, disabled: options === null, loading: loading, options: options !== null && options !== void 0 ? options : [], inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_d = formStyle.stepBackgroundColor) !== null && _d !== void 0 ? _d : 'white', label: step.label, required: step.required, height: '31px', changeListener: changeListener, searchable: step.searchable, icon: step.showIcon ? icon : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: function (value) {
197
+ }, disabled: options === null, loading: loading, options: options !== null && options !== void 0 ? options : undefined, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_d = formStyle.stepBackgroundColor) !== null && _d !== void 0 ? _d : 'white', label: step.label, required: step.required, height: '31px', changeListener: changeListener, searchable: step.searchable, icon: step.showIcon ? icon : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: function (value) {
198
198
  var _a;
199
199
  if (dependencyStore[step.id] !== undefined) {
200
- setDependencyStore(__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = value, _a)));
200
+ setDependencyStore(__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = value !== null && value !== void 0 ? value : null, _a)));
201
201
  }
202
202
  valueOverwrite
203
203
  ? onChange(valueOverwrite(value))
@@ -210,7 +210,7 @@ function SmartSelect(_a) {
210
210
  !!errors[step.id] }) })), children &&
211
211
  cloneElement(children, {
212
212
  value: value,
213
- stepProps: __assign({ step: step, form: form, errors: errors, trigger: trigger, postview: postview, editable: editable, formStyle: formStyle, widthStats: widthStats, organization: organization, originalValues: originalValues, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore }, others),
213
+ stepProps: __assign({ step: step, form: form, errors: errors, setFocus: setFocus, postview: postview, editable: editable, formStyle: formStyle, widthStats: widthStats, organization: organization, originalValues: originalValues, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore }, others),
214
214
  })] }));
215
215
  }
216
216
  function SmartSelectStep(props) {
@@ -103,6 +103,9 @@ var useTextfieldStyles = function (props) {
103
103
  '& .EF-MuiFormHelperText-root': {
104
104
  color: props.helperTextColor,
105
105
  },
106
+ '& .EF-MuiFormHelperText-root.Mui-error': {
107
+ color: props.errorColor + ' !important',
108
+ },
106
109
  '& .EF-MuiFormLabel-root.Mui-disabled': {
107
110
  color: '#0000008a',
108
111
  },
@@ -125,7 +128,7 @@ var useTextfieldStyles = function (props) {
125
128
  }); });
126
129
  };
127
130
  export default function RoundedSmartSelect(_a) {
128
- var _b = _a.options, options = _b === void 0 ? [] : _b, _c = _a.value, value = _c === void 0 ? '' : _c, handleUpdate = _a.handleUpdate, label = _a.label, _d = _a.getValueString, getValueString = _d === void 0 ? function (value) { return value.value; } : _d, _e = _a.color, color = _e === void 0 ? '#293241' : _e, _f = _a.errorColor, errorColor = _f === void 0 ? '#cc2936' : _f, _g = _a.focusColor, focusColor = _g === void 0 ? '#3d5a7f' : _g, _h = _a.helperTextColor, helperTextColor = _h === void 0 ? '#989898' : _h, _j = _a.outlineColor, outlineColor = _j === void 0 ? '#b8b8b8' : _j, _k = _a.backgroundColor, backgroundColor = _k === void 0 ? '#ffffff' : _k, _l = _a.cantEdit, cantEdit = _l === void 0 ? false : _l, _m = _a.loading, loading = _m === void 0 ? false : _m, _o = _a.height, height = _o === void 0 ? '31px' : _o, _p = _a.fontSize, fontSize = _p === void 0 ? '1rem' : _p, required = _a.required, changeListener = _a.changeListener, error = _a.error, innerBackgroundColor = _a.innerBackgroundColor, getOptionSelected = _a.getOptionSelected, helperText = _a.helperText, _q = _a.readOnly, readOnly = _q === void 0 ? false : _q, _r = _a.borderRadius, borderRadius = _r === void 0 ? 10 : _r, _s = _a.fontWeight, fontWeight = _s === void 0 ? '400' : _s, icon = _a.icon, _t = _a.searchable, searchable = _t === void 0 ? false : _t, _u = _a.containerMargin, containerMargin = _u === void 0 ? '0px' : _u, _v = _a.showIcon, showIcon = _v === void 0 ? true : _v, inputRef = _a.inputRef, disabled = _a.disabled, _w = _a.creatable, creatable = _w === void 0 ? false : _w, onBlur = _a.onBlur, name = _a.name, onFocus = _a.onFocus;
131
+ var options = _a.options, _b = _a.value, value = _b === void 0 ? '' : _b, handleUpdate = _a.handleUpdate, label = _a.label, _c = _a.getValueString, getValueString = _c === void 0 ? function (value) { return value.value; } : _c, _d = _a.color, color = _d === void 0 ? '#293241' : _d, _e = _a.errorColor, errorColor = _e === void 0 ? '#cc2936' : _e, _f = _a.focusColor, focusColor = _f === void 0 ? '#3d5a7f' : _f, _g = _a.helperTextColor, helperTextColor = _g === void 0 ? '#989898' : _g, _h = _a.outlineColor, outlineColor = _h === void 0 ? '#b8b8b8' : _h, _j = _a.backgroundColor, backgroundColor = _j === void 0 ? '#ffffff' : _j, _k = _a.cantEdit, cantEdit = _k === void 0 ? false : _k, _l = _a.loading, loading = _l === void 0 ? false : _l, _m = _a.height, height = _m === void 0 ? '31px' : _m, _o = _a.fontSize, fontSize = _o === void 0 ? '1rem' : _o, required = _a.required, changeListener = _a.changeListener, error = _a.error, innerBackgroundColor = _a.innerBackgroundColor, getOptionSelected = _a.getOptionSelected, helperText = _a.helperText, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.borderRadius, borderRadius = _q === void 0 ? 10 : _q, _r = _a.fontWeight, fontWeight = _r === void 0 ? '400' : _r, icon = _a.icon, _s = _a.searchable, searchable = _s === void 0 ? false : _s, _t = _a.containerMargin, containerMargin = _t === void 0 ? '0px' : _t, _u = _a.showIcon, showIcon = _u === void 0 ? true : _u, inputRef = _a.inputRef, disabled = _a.disabled, _v = _a.creatable, creatable = _v === void 0 ? false : _v, onBlur = _a.onBlur, name = _a.name, onFocus = _a.onFocus;
129
132
  var props = {
130
133
  color: color,
131
134
  height: height,
@@ -144,7 +147,7 @@ export default function RoundedSmartSelect(_a) {
144
147
  };
145
148
  var textFieldClasses = useTextfieldStyles(props)();
146
149
  if (searchable) {
147
- return (_jsx(Autocomplete, { onFocus: onFocus, size: "small", fullWidth: true, openOnFocus: true, freeSolo: creatable, disabled: cantEdit || disabled, popupIcon: loading ? (_jsx(CircularProgress, { size: 22, style: { color: '#757575' } })) : showIcon && icon ? (icon) : undefined, onOpen: function () { }, loading: loading, loadingText: 'Cargando...', closeIcon: false, options: options, getOptionLabel: function (option) {
150
+ return (_jsx(Autocomplete, { onFocus: onFocus, size: "small", fullWidth: true, openOnFocus: true, freeSolo: creatable, disabled: cantEdit || disabled, popupIcon: loading ? (_jsx(CircularProgress, { size: 22, style: { color: '#757575' } })) : showIcon && icon ? (icon) : undefined, onOpen: function () { }, loading: loading, loadingText: 'Cargando...', closeIcon: false, options: options !== null && options !== void 0 ? options : [], getOptionLabel: function (option) {
148
151
  var _a, _b;
149
152
  // Value selected with enter, right from the input
150
153
  if (typeof option === 'string') {
@@ -199,8 +202,8 @@ export default function RoundedSmartSelect(_a) {
199
202
  }, renderInput: function (params) { return (_jsx(TextField, __assign({ classes: textFieldClasses }, params, { inputRef: inputRef, onBlur: onBlur, name: name, variant: "outlined", label: label, required: required, error: error, helperText: helperText }))); }, style: { pointerEvents: 'none' }, noOptionsText: "No hay opciones" }));
200
203
  }
201
204
  else {
202
- return (_jsxs(RoundedSelect, __assign({ onBlur: onBlur, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: function (event) {
203
- handleUpdate === null || handleUpdate === void 0 ? void 0 : handleUpdate(options.find(function (option) {
205
+ return (_jsxs(RoundedSelect, __assign({ onBlur: onBlur, onFocus: onFocus, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: function (event) {
206
+ handleUpdate === null || handleUpdate === void 0 ? void 0 : handleUpdate(options === null || options === void 0 ? void 0 : options.find(function (option) {
204
207
  return getValueString(option) == event.target.value;
205
208
  }));
206
209
  }, onOpen: function () {
@@ -216,6 +219,6 @@ export default function RoundedSmartSelect(_a) {
216
219
  ? function (props) {
217
220
  return cloneElement(icon, props);
218
221
  }
219
- : undefined, showIcon: showIcon }, { children: [_jsx(MenuItem, __assign({ value: '', style: { whiteSpace: 'normal' } }, { children: _jsx("em", { children: "Sin Seleccionar" }) }), 'EMPTY'), options.map(function (option) { return (_jsx(MenuItem, __assign({ value: getValueString(option), style: { whiteSpace: 'normal' } }, { children: option.label }), getValueString(option))); })] })));
222
+ : undefined, showIcon: showIcon }, { children: [_jsx(MenuItem, __assign({ value: '', style: { whiteSpace: 'normal' } }, { children: _jsx("em", { children: options ? 'Sin Seleccionar' : 'Cargando...' }) }), 'EMPTY'), options === null || options === void 0 ? void 0 : options.map(function (option) { return (_jsx(MenuItem, __assign({ value: getValueString(option), style: { whiteSpace: 'normal' } }, { children: option.label }), getValueString(option))); })] })));
220
223
  }
221
224
  }
@@ -105,6 +105,9 @@ var useTextfieldStyles = function (props) {
105
105
  color: props.helperTextColor,
106
106
  marginRight: props.maxLength ? 40 : 14,
107
107
  },
108
+ '& .EF-MuiFormHelperText-root.Mui-error': {
109
+ color: props.errorColor,
110
+ },
108
111
  '& .EF-MuiOutlinedInput-multiline': {
109
112
  padding: 0,
110
113
  backgroundColor: props.innerBackgroundColor,
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.9.35-test",
4
+ "version":"1.9.36-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",