@arquimedes.co/eureka-forms 2.0.122 → 2.0.123

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.
@@ -168,9 +168,9 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
168
168
  if (path === void 0) { path = ''; }
169
169
  return __awaiter(void 0, void 0, void 0, function () {
170
170
  var _a, elements, mappedElements, _loop_1, _i, elements_1, element, defaultValue, option, stepClassifier, classifier, params, url, entityValues, entityValue, country;
171
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
172
- return __generator(this, function (_o) {
173
- switch (_o.label) {
171
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
172
+ return __generator(this, function (_p) {
173
+ switch (_p.label) {
174
174
  case 0:
175
175
  if (!value)
176
176
  return [2 /*return*/, value];
@@ -188,9 +188,9 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
188
188
  elements = value;
189
189
  mappedElements = [];
190
190
  _loop_1 = function (element) {
191
- var idElement, mappedElement, base, _p, _q, subStep, dependencies, _r, dependencies_1, idDep, mappedIdDep, _s, _t, key;
192
- return __generator(this, function (_u) {
193
- switch (_u.label) {
191
+ var idElement, mappedElement, base, _q, _r, subStep, dependencies, _s, dependencies_1, idDep, mappedIdDep, _t, _u, key;
192
+ return __generator(this, function (_v) {
193
+ switch (_v.label) {
194
194
  case 0:
195
195
  idElement = (_b = element.id) !== null && _b !== void 0 ? _b : nanoid();
196
196
  mappedElement = {
@@ -223,15 +223,15 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
223
223
  });
224
224
  }); }))];
225
225
  case 1:
226
- _u.sent();
227
- for (_p = 0, _q = Object.values(step.steps); _p < _q.length; _p++) {
228
- subStep = _q[_p];
226
+ _v.sent();
227
+ for (_q = 0, _r = Object.values(step.steps); _q < _r.length; _q++) {
228
+ subStep = _r[_q];
229
229
  dependencies = (_c = subStep.dependencies) !== null && _c !== void 0 ? _c : [];
230
230
  if (subStep.condition) {
231
231
  dependencies = __spreadArray(__spreadArray([], dependencies, true), calcNestedConditionSteps(subStep.condition), true).filter(function (item, i, ar) { return ar.indexOf(item) === i; });
232
232
  }
233
- for (_r = 0, dependencies_1 = dependencies; _r < dependencies_1.length; _r++) {
234
- idDep = dependencies_1[_r];
233
+ for (_s = 0, dependencies_1 = dependencies; _s < dependencies_1.length; _s++) {
234
+ idDep = dependencies_1[_s];
235
235
  mappedIdDep = base + step.id + '-' + idElement + '-' + idDep;
236
236
  if (!values.sections[step.idSection][idDep] &&
237
237
  !values.global[mappedIdDep] &&
@@ -241,8 +241,8 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
241
241
  }
242
242
  }
243
243
  }
244
- for (_s = 0, _t = Object.keys(element); _s < _t.length; _s++) {
245
- key = _t[_s];
244
+ for (_t = 0, _u = Object.keys(element); _t < _u.length; _t++) {
245
+ key = _u[_t];
246
246
  if (step.steps[key] || key === 'id')
247
247
  continue;
248
248
  mappedElement.originalValues[key] = element[key];
@@ -253,14 +253,14 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
253
253
  });
254
254
  };
255
255
  _i = 0, elements_1 = elements;
256
- _o.label = 2;
256
+ _p.label = 2;
257
257
  case 2:
258
258
  if (!(_i < elements_1.length)) return [3 /*break*/, 5];
259
259
  element = elements_1[_i];
260
260
  return [5 /*yield**/, _loop_1(element)];
261
261
  case 3:
262
- _o.sent();
263
- _o.label = 4;
262
+ _p.sent();
263
+ _p.label = 4;
264
264
  case 4:
265
265
  _i++;
266
266
  return [3 /*break*/, 2];
@@ -281,7 +281,7 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
281
281
  return [2 /*return*/, (_e = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _e !== void 0 ? _e : ''];
282
282
  }
283
283
  }
284
- _o.label = 7;
284
+ _p.label = 7;
285
285
  case 7:
286
286
  {
287
287
  option = step.options.find(function (option) { return option.value === value; });
@@ -289,7 +289,7 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
289
289
  return [2 /*return*/, option];
290
290
  return [2 /*return*/, value];
291
291
  }
292
- _o.label = 8;
292
+ _p.label = 8;
293
293
  case 8:
294
294
  {
295
295
  stepClassifier = (_f = form === null || form === void 0 ? void 0 : form.classifiers) === null || _f === void 0 ? void 0 : _f[(_g = step.idClassifier) !== null && _g !== void 0 ? _g : ''];
@@ -299,14 +299,16 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
299
299
  }
300
300
  return [3 /*break*/, 14];
301
301
  }
302
- _o.label = 9;
302
+ _p.label = 9;
303
303
  case 9:
304
304
  if (!!value._id) return [3 /*break*/, 11];
305
- params = new URLSearchParams(value);
305
+ params = typeof value !== 'string'
306
+ ? new URLSearchParams(value)
307
+ : new URLSearchParams();
306
308
  url = "".concat(orgInfo.idOrganization, "/entities/").concat(step.idEntity, "?").concat(params.toString());
307
309
  return [4 /*yield*/, widgetInstance.get(url)];
308
310
  case 10:
309
- entityValues = (_o.sent()).data;
311
+ entityValues = (_p.sent()).data;
310
312
  if (entityValues.length === 1) {
311
313
  entityValue = entityValues[0];
312
314
  if (((_j = step.options[entityValue._id]) === null || _j === void 0 ? void 0 : _j.type) ===
@@ -314,16 +316,22 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
314
316
  return [2 /*return*/, undefined];
315
317
  return [2 /*return*/, entityValues[0]];
316
318
  }
319
+ if (typeof value === 'string') {
320
+ if (((_k = step.options[value]) === null || _k === void 0 ? void 0 : _k.type) ===
321
+ EntityValueOptionTypes.HIDE)
322
+ return [2 /*return*/, undefined];
323
+ return [2 /*return*/, entityValues.find(function (ev) { return ev._id === value; })];
324
+ }
317
325
  return [2 /*return*/, null];
318
326
  case 11: return [2 /*return*/, value];
319
327
  case 12:
320
328
  {
321
329
  if (step.clientInfoType === 'cel' ||
322
- ((_k = step.validation) === null || _k === void 0 ? void 0 : _k.type) === 'PHONE') {
330
+ ((_l = step.validation) === null || _l === void 0 ? void 0 : _l.type) === 'PHONE') {
323
331
  if (!isValidPhoneNumber(value)) {
324
332
  country = getCountry({
325
333
  field: 'iso2',
326
- value: (_m = (_l = orgInfo.countryCode) === null || _l === void 0 ? void 0 : _l.toLowerCase()) !== null && _m !== void 0 ? _m : 'co',
334
+ value: (_o = (_m = orgInfo.countryCode) === null || _m === void 0 ? void 0 : _m.toLowerCase()) !== null && _o !== void 0 ? _o : 'co',
327
335
  });
328
336
  if (country &&
329
337
  isValidPhoneNumber(country.dialCode + value)) {
@@ -333,7 +341,7 @@ export var mapOriginalValue = function (orgInfo, step, value, values, form, path
333
341
  }
334
342
  return [2 /*return*/, value];
335
343
  }
336
- _o.label = 13;
344
+ _p.label = 13;
337
345
  case 13:
338
346
  if (step.type.startsWith('CBR_') &&
339
347
  (value === null || value === void 0 ? void 0 : value.id) &&
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.122",
4
+ "version": "2.0.123",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",