@arquimedes.co/eureka-forms 1.9.125 → 1.9.126-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.
Files changed (27) hide show
  1. package/dist/@Types/FormStep.d.ts +37 -2
  2. package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +8 -1
  3. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +8 -2
  4. package/dist/FormComponents/Section/Section.d.ts +3 -2
  5. package/dist/FormComponents/Step/@Construction/CBRElementStep/CBRElementStep.js +6 -6
  6. package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +4 -1
  7. package/dist/FormComponents/Step/@Construction/CBRPropertyStep/CBRPropertyStep.js +6 -6
  8. package/dist/FormComponents/Step/AYFStepMapper.js +11 -11
  9. package/dist/FormComponents/Step/ApiSelectorStep/ApiSelectorStep.d.ts +15 -0
  10. package/dist/FormComponents/Step/ApiSelectorStep/ApiSelectorStep.js +35 -0
  11. package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +4 -0
  12. package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +213 -0
  13. package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +25 -0
  14. package/dist/FormComponents/Step/CBRStepMapper.js +10 -10
  15. package/dist/FormComponents/Step/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +14 -11
  16. package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/MaterialMapperStep.js +17 -5
  17. package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +60 -26
  18. package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.d.ts +2 -1
  19. package/dist/FormComponents/Step/Step.js +4 -0
  20. package/dist/FormComponents/Step/StepFunctions.d.ts +2 -2
  21. package/dist/FormComponents/Step/StepFunctions.js +19 -4
  22. package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +4 -1
  23. package/dist/constants/FormStepTypes.d.ts +10 -1
  24. package/dist/constants/FormStepTypes.js +11 -0
  25. package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +3 -1
  26. package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +7 -5
  27. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes } from '../constants/FormStepTypes';
1
+ import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
2
2
  import * as GSteps from './GenericFormSteps';
3
- export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | Mapper;
3
+ export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
4
4
  export interface Title extends GSteps.GBaseStep {
5
5
  type: Types.TITLE;
6
6
  title: string;
@@ -140,6 +140,41 @@ export interface ValueEntityValuePickerFilter {
140
140
  type: EntityValueDataTypes.VALUE;
141
141
  value: any;
142
142
  }
143
+ export interface ApiSelector extends GSteps.GSmartSelect {
144
+ type: Types.API_SELECTOR;
145
+ icon: string | null;
146
+ url: string;
147
+ pathParams: ApiSelectorParam[];
148
+ queryParams: ApiSelectorParam[];
149
+ /** Headers? Body, etc?? */
150
+ labelAttribute: string;
151
+ idAttribute: string;
152
+ /** Only has maxSize if level === 0 */
153
+ maxSize?: number;
154
+ options: Record<string, ApiSelectorOption>;
155
+ }
156
+ export type ApiSelectorOption = NestedApiSelectorOption | HideApiSelectorOption;
157
+ interface NestedApiSelectorOption {
158
+ type: ApiSelectorOptionTypes.NESTED;
159
+ idOption: string;
160
+ steps: string[];
161
+ }
162
+ interface HideApiSelectorOption {
163
+ type: ApiSelectorOptionTypes.HIDE;
164
+ idOption: string;
165
+ }
166
+ export type ApiSelectorParam = StepApiSelectorParam | ValueApiSelectorParam;
167
+ export interface StepApiSelectorParam {
168
+ type: ApiSelectorParamTypes.STEP;
169
+ key: string;
170
+ idStep: string;
171
+ required: boolean;
172
+ }
173
+ export interface ValueApiSelectorParam {
174
+ type: ApiSelectorParamTypes.VALUE;
175
+ key: string;
176
+ value: string;
177
+ }
143
178
  export interface Mapper extends GSteps.GBaseStep {
144
179
  type: Types.MAPPER;
145
180
  style: {
@@ -1,8 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  import { FormComponentProps } from '../Form';
3
+ import Types from '../../../constants/FormStepTypes';
3
4
  import { CustomStep } from '../../../App';
4
5
  import { FormStep } from '../../../@Types/FormStep';
6
+ export interface StepDependency {
7
+ value: any | undefined;
8
+ type: Types;
9
+ empty?: boolean;
10
+ }
11
+ export type DependencyStore = Record<string, StepDependency>;
5
12
  declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, sendLabel, widthStats, customSteps, customSend, customSubmit, handleLoaded, originalValues, ...others }: FormComponentProps): JSX.Element;
6
13
  export default ColumnForm;
7
14
  export declare const calcValue: (idStep: string, steps: Record<string, FormStep>, values: Record<string, any>, customSteps: Record<string, CustomStep>, deleteIds: string[], value?: any) => any;
8
- export declare function calcStepDependencyValue(depStep: FormStep, originalValues: Record<string, any>, customSteps?: Record<string, CustomStep>): any;
15
+ export declare function calcStepDependencyValue(depStep: FormStep, originalValues: Record<string, any>, customSteps?: Record<string, CustomStep>): StepDependency['value'];
@@ -334,10 +334,16 @@ function calcDependencies(steps, originalValues, customSteps, allSteps, dependen
334
334
  var idDep = _f[_e];
335
335
  var depStep = allSteps[idDep];
336
336
  if (depStep && dependencies[idDep] === undefined) {
337
- dependencies[idDep] = calcStepDependencyValue(depStep, originalValues, customSteps);
337
+ dependencies[idDep] = {
338
+ type: depStep.type,
339
+ value: calcStepDependencyValue(depStep, originalValues, customSteps),
340
+ };
338
341
  }
339
342
  else if (dependencies[idDep] === undefined) {
340
- dependencies[idDep] = originalValues[idDep];
343
+ dependencies[idDep] = {
344
+ type: depStep.type,
345
+ value: originalValues[idDep],
346
+ };
341
347
  }
342
348
  }
343
349
  }
@@ -4,6 +4,7 @@ import { Organization } from '../../@Types';
4
4
  import { Form, FormStyle, Section } from '../../@Types/Form';
5
5
  import { CustomStep } from '../../App';
6
6
  import { WidthStats } from '../Form/Form';
7
+ import { DependencyStore } from '../Form/ColumnForm/ColumnForm';
7
8
  export interface RecursiveData {
8
9
  form: Form;
9
10
  organization: Organization;
@@ -24,8 +25,8 @@ export interface RecursiveData {
24
25
  customStepProps: Record<string, any>;
25
26
  /** Function to call on postview to fetch the download url of a file */
26
27
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
27
- dependencyStore: Record<string, any>;
28
- setDependencyStore: React.Dispatch<React.SetStateAction<Record<string, any>>>;
28
+ dependencyStore: DependencyStore;
29
+ setDependencyStore: React.Dispatch<React.SetStateAction<DependencyStore>>;
29
30
  setFocus: (id: string) => void;
30
31
  setValue: (id: string, value: any) => void;
31
32
  }
@@ -81,19 +81,19 @@ var getElementOptions = function (_a, step, dependencyStore) {
81
81
  var idOrganization = _a.idOrganization;
82
82
  return __awaiter(void 0, void 0, void 0, function () {
83
83
  var idProyecto, response, father_1;
84
- var _b;
85
- return __generator(this, function (_c) {
86
- switch (_c.label) {
84
+ var _b, _c;
85
+ return __generator(this, function (_d) {
86
+ switch (_d.label) {
87
87
  case 0:
88
88
  if (!step.dependencies) return [3 /*break*/, 2];
89
- idProyecto = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.id;
89
+ idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
90
90
  if (!idProyecto) {
91
91
  return [2 /*return*/, null]; //null para indicar que falta la depedency
92
92
  }
93
93
  return [4 /*yield*/, axios.get("https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/Locativas?idOrganization=").concat(idOrganization))];
94
94
  case 1:
95
- response = (_c.sent()).data;
96
- father_1 = dependencyStore[step.dependencies[1]];
95
+ response = (_d.sent()).data;
96
+ father_1 = dependencyStore[step.dependencies[1]].value;
97
97
  if (father_1 !== undefined && father_1.id === undefined) {
98
98
  return [2 /*return*/, null];
99
99
  }
@@ -80,7 +80,10 @@ function Incidents(_a) {
80
80
  newStep.subStep = idSubStep;
81
81
  }
82
82
  if (idParent) {
83
- dependencyStore[idParent] = null;
83
+ dependencyStore[idParent] = {
84
+ type: steps[idParent].type,
85
+ value: null,
86
+ };
84
87
  (_b = (_a = newStep.dependencies) === null || _a === void 0 ? void 0 : _a.push) === null || _b === void 0 ? void 0 : _b.call(_a, idParent);
85
88
  }
86
89
  steps[idStep] = newStep;
@@ -63,13 +63,13 @@ function CBRPropertyStepComponent(props) {
63
63
  var idOrganization = _a.idOrganization;
64
64
  return __awaiter(_this, void 0, void 0, function () {
65
65
  var idProyecto, idMacroProyecto;
66
- var _b, _c;
67
- return __generator(this, function (_d) {
68
- switch (_d.label) {
66
+ var _b, _c, _d, _e;
67
+ return __generator(this, function (_f) {
68
+ switch (_f.label) {
69
69
  case 0:
70
70
  if (!step.dependencies) return [3 /*break*/, 2];
71
- idProyecto = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.id;
72
- idMacroProyecto = (_c = dependencyStore[step.dependencies[0]]) === null || _c === void 0 ? void 0 : _c.idMacroProyecto;
71
+ idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
72
+ idMacroProyecto = (_e = (_d = dependencyStore[step.dependencies[0]]) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.idMacroProyecto;
73
73
  if (!idProyecto) {
74
74
  return [2 /*return*/, null]; //null para indicar que falta la depedency
75
75
  }
@@ -80,7 +80,7 @@ function CBRPropertyStepComponent(props) {
80
80
  idProyecto +
81
81
  '&idOrganization=' +
82
82
  idOrganization)];
83
- case 1: return [2 /*return*/, (_d.sent()).data];
83
+ case 1: return [2 /*return*/, (_f.sent()).data];
84
84
  case 2: return [2 /*return*/, null];
85
85
  }
86
86
  });
@@ -79,21 +79,21 @@ function AYFStepMapper(props) {
79
79
  var idOrganization = _a.idOrganization;
80
80
  return __awaiter(_this, void 0, void 0, function () {
81
81
  var nit, params, _i, _b, dep, value, error_1;
82
- var _c, _d;
83
- return __generator(this, function (_e) {
84
- switch (_e.label) {
82
+ var _c, _d, _e, _f;
83
+ return __generator(this, function (_g) {
84
+ switch (_g.label) {
85
85
  case 0:
86
- nit = dependencyStore[step.idNitStep];
86
+ nit = (_c = dependencyStore[step.idNitStep]) === null || _c === void 0 ? void 0 : _c.value;
87
87
  params = new URLSearchParams({
88
88
  idOrganization: idOrganization,
89
89
  idCompany: nit,
90
90
  nit: 'true',
91
91
  });
92
- for (_i = 0, _b = (_c = step.dependencies) !== null && _c !== void 0 ? _c : []; _i < _b.length; _i++) {
92
+ for (_i = 0, _b = (_d = step.dependencies) !== null && _d !== void 0 ? _d : []; _i < _b.length; _i++) {
93
93
  dep = _b[_i];
94
- value = dependencyStore[dep];
94
+ value = (_e = dependencyStore[dep]) === null || _e === void 0 ? void 0 : _e.value;
95
95
  if (value && dep.startsWith('AYF')) {
96
- switch ((_d = dep.split('-')) === null || _d === void 0 ? void 0 : _d[0]) {
96
+ switch ((_f = dep.split('-')) === null || _f === void 0 ? void 0 : _f[0]) {
97
97
  case AYFFormStepTypes.AYF_START_MONTH:
98
98
  params.set('startMonth', value.id);
99
99
  break;
@@ -108,13 +108,13 @@ function AYFStepMapper(props) {
108
108
  }
109
109
  }
110
110
  }
111
- _e.label = 1;
111
+ _g.label = 1;
112
112
  case 1:
113
- _e.trys.push([1, 3, , 4]);
113
+ _g.trys.push([1, 3, , 4]);
114
114
  return [4 /*yield*/, axios.get(baseUrl + 'CiudadesICA?' + params.toString())];
115
- case 2: return [2 /*return*/, (_e.sent()).data];
115
+ case 2: return [2 /*return*/, (_g.sent()).data];
116
116
  case 3:
117
- error_1 = _e.sent();
117
+ error_1 = _g.sent();
118
118
  return [2 /*return*/, null];
119
119
  case 4: return [2 /*return*/];
120
120
  }
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { ApiSelector } from '../../../@Types/FormStep';
3
+ import { StepProps } from '../Step';
4
+ export interface StepOptions {
5
+ id: string | number;
6
+ label: string;
7
+ }
8
+ export interface ApiSelectorStepProps extends StepProps {
9
+ /** The ApiSelectorStep to display */
10
+ step: ApiSelector;
11
+ /** Default value to display */
12
+ defaultValue?: Date | null;
13
+ }
14
+ declare function ApiSelectorStep({ ...props }: ApiSelectorStepProps): JSX.Element;
15
+ export default ApiSelectorStep;
@@ -0,0 +1,35 @@
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 } from "react/jsx-runtime";
24
+ import { FormStyleTypes } from '../../../constants/FormStepTypes';
25
+ import MaterialApiSelectorStep from './MaterialApiSelectorStep/MaterialApiSelectorStep';
26
+ function ApiSelectorStep(_a) {
27
+ var props = __rest(_a, []);
28
+ switch (props.formStyle.type) {
29
+ case FormStyleTypes.MATERIAL:
30
+ default: {
31
+ return _jsx(MaterialApiSelectorStep, __assign({}, props));
32
+ }
33
+ }
34
+ }
35
+ export default ApiSelectorStep;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { ApiSelectorStepProps } from '../ApiSelectorStep';
3
+ export default ApiSelectorStep;
4
+ declare function ApiSelectorStep(props: ApiSelectorStepProps): JSX.Element;
@@ -0,0 +1,213 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ import { createElement as _createElement } from "react";
60
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
61
+ import React, { useEffect, useState } from 'react';
62
+ import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../../constants/FormStepTypes';
63
+ import styles from './MaterialApiSelectorStep.module.css';
64
+ import StepComponent from '../../Step';
65
+ import { Controller } from 'react-hook-form';
66
+ import { calcFillerSize } from '../../StepFunctions';
67
+ import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
68
+ import widgetInstance from '../../../../AxiosWidget';
69
+ import axiosInstance from '../../../../AxiosAPI';
70
+ import InputIcon from '../../../../shared/InputIcon/InputIcon';
71
+ function ApiSelector(_a) {
72
+ var _this = this;
73
+ var step = _a.step, form = _a.form, level = _a.level, value = _a.value, control = _a.control, editable = _a.editable, postview = _a.postview, inputRef = _a.inputRef, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "value", "control", "editable", "postview", "inputRef", "getValues", "widthStats", "handleSizeChange"]);
74
+ var _b = useState(level === 0
75
+ ? calcFillerSize(step, form.steps, getValues(), form.size)
76
+ : 0), fillerSize = _b[0], setFillerSize = _b[1];
77
+ function calcOptionId(option) {
78
+ var _a;
79
+ return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
80
+ }
81
+ function calcOptionLabel(option) {
82
+ var _a;
83
+ return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
84
+ }
85
+ var getApiOptions = function (_a, _step, dependencyStore, domain) {
86
+ var idOrganization = _a.idOrganization;
87
+ return __awaiter(_this, void 0, void 0, function () {
88
+ var params, _i, _b, filter, currentValue, url, response;
89
+ var _c, _d;
90
+ return __generator(this, function (_e) {
91
+ switch (_e.label) {
92
+ case 0:
93
+ params = new URLSearchParams({});
94
+ for (_i = 0, _b = step.queryParams; _i < _b.length; _i++) {
95
+ filter = _b[_i];
96
+ switch (filter.type) {
97
+ case ApiSelectorParamTypes.STEP:
98
+ currentValue = (_c = dependencyStore[filter.idStep]) === null || _c === void 0 ? void 0 : _c.value;
99
+ if (currentValue) {
100
+ if (typeof currentValue === 'string')
101
+ params.set(filter.key, currentValue);
102
+ else
103
+ params.set(filter.key, (_d = currentValue.label) !== null && _d !== void 0 ? _d : currentValue.id);
104
+ }
105
+ else if (filter.required) {
106
+ return [2 /*return*/, null];
107
+ }
108
+ break;
109
+ case ApiSelectorParamTypes.VALUE:
110
+ default:
111
+ params.set(filter.key, filter.value);
112
+ break;
113
+ }
114
+ }
115
+ url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
116
+ if (domain && url.includes(process.env.REACT_APP_DOMAIN))
117
+ params.set('idOrganization', idOrganization);
118
+ if (!step.url.includes('?'))
119
+ url += '?';
120
+ url += params.toString();
121
+ return [4 /*yield*/, (domain
122
+ ? widgetInstance.get(url)
123
+ : axiosInstance.get(url))];
124
+ case 1:
125
+ response = _e.sent();
126
+ return [2 /*return*/, response.data.filter(function (option) {
127
+ var _a;
128
+ return calcOptionId(option) &&
129
+ ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
130
+ ApiSelectorOptionTypes.HIDE;
131
+ })];
132
+ }
133
+ });
134
+ });
135
+ };
136
+ var sizeChange = function () {
137
+ handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
138
+ if (level === 0) {
139
+ setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
140
+ }
141
+ };
142
+ var renderSelect = function () {
143
+ return (_jsx(SmartSelect, __assign({}, others, { form: form, level: level, control: control, postview: postview, getValues: getValues, widthStats: widthStats, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
144
+ return calcOptionId(option) === calcOptionId(value);
145
+ }, calcDepError: function (steps) {
146
+ for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
147
+ var step_1 = steps_1[_i];
148
+ if (step_1.type === FormStepTypes.API_SELECTOR) {
149
+ return 'Selecciona un ' + step_1.label;
150
+ }
151
+ }
152
+ return undefined;
153
+ }, getValueString: function (value) { return calcOptionLabel(value); } })));
154
+ };
155
+ var mapNestedOption = function () {
156
+ if (value) {
157
+ var currentOption = step.options[calcOptionId(value)];
158
+ if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
159
+ return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
160
+ var subStep = form.steps[idStep];
161
+ return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, form: form, control: control, step: subStep, key: idStep, level: level + 1, handleSizeChange: function () {
162
+ sizeChange();
163
+ } })));
164
+ }) }));
165
+ }
166
+ }
167
+ };
168
+ if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
169
+ return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
170
+ width: widthStats.currentBreakPoint <= step.size
171
+ ? '100%'
172
+ : 'fit-content',
173
+ } }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
174
+ width: fillerSize,
175
+ } }, "SEPARATOR"))] })));
176
+ }
177
+ else {
178
+ return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
179
+ }
180
+ }
181
+ export default ApiSelectorStep;
182
+ function ApiSelectorStep(props) {
183
+ var _a, _b;
184
+ var step = props.step, dependencyStore = props.dependencyStore, defaultValue = props.defaultValue, originalValues = props.originalValues;
185
+ useEffect(function () {
186
+ /** Al modificar tambien modificar en SmartSelect */
187
+ if (!originalValues[step.id] && defaultValue) {
188
+ props.setDependencyStore(function (dependencies) {
189
+ var _a;
190
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = { type: step.type, value: props.defaultValue }, _a)));
191
+ });
192
+ }
193
+ }, []);
194
+ return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: (_b = (_a = props.originalValues[props.step.id]) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null, rules: {
195
+ required: props.step.required
196
+ ? 'Este campo es obligatorio'
197
+ : undefined,
198
+ }, shouldUnregister: true, render: function (_a) {
199
+ var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
200
+ return (_jsx(ApiSelector, __assign({}, props, field, { inputRef: ref, onChange: function (value) {
201
+ if (dependencyStore[step.id] !== undefined) {
202
+ props.setDependencyStore(function (dependencies) {
203
+ var _a;
204
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
205
+ type: step.type,
206
+ value: value !== null && value !== void 0 ? value : null,
207
+ }, _a)));
208
+ });
209
+ }
210
+ field.onChange(value);
211
+ } })));
212
+ } }));
213
+ }
@@ -0,0 +1,25 @@
1
+ .container {
2
+ width: fit-content;
3
+ max-width: calc(100% - 20px);
4
+ display: flex;
5
+ padding: 10px;
6
+ padding-bottom: 0px;
7
+ padding-top: 5px;
8
+ margin-bottom: 0px;
9
+ }
10
+ .separator {
11
+ flex-basis: 100%;
12
+ height: 0;
13
+ }
14
+
15
+ .firstLvlContainer {
16
+ max-width: 100%;
17
+ display: flex;
18
+ flex-flow: row wrap;
19
+ }
20
+
21
+ .smallSeparator {
22
+ height: 0;
23
+ max-width: 100%;
24
+ flex-basis: 0;
25
+ }
@@ -74,14 +74,14 @@ function CBRStepMapper(props) {
74
74
  var idOrganization = _a.idOrganization;
75
75
  return __awaiter(_this, void 0, void 0, function () {
76
76
  var idMacroProyecto, proyectos;
77
- var _b, _c, _d;
78
- return __generator(this, function (_e) {
79
- switch (_e.label) {
77
+ var _b, _c, _d, _e;
78
+ return __generator(this, function (_f) {
79
+ switch (_f.label) {
80
80
  case 0:
81
- idMacroProyecto = (_d = dependencyStore[(_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.id;
81
+ idMacroProyecto = (_e = (_d = dependencyStore[(_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.id;
82
82
  return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
83
83
  case 1:
84
- proyectos = (_e.sent()).data;
84
+ proyectos = (_f.sent()).data;
85
85
  if (idMacroProyecto) {
86
86
  proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
87
87
  }
@@ -116,12 +116,12 @@ function CBRStepMapper(props) {
116
116
  var idOrganization = _a.idOrganization;
117
117
  return __awaiter(_this, void 0, void 0, function () {
118
118
  var idProyecto;
119
- var _b;
120
- return __generator(this, function (_c) {
121
- switch (_c.label) {
119
+ var _b, _c;
120
+ return __generator(this, function (_d) {
121
+ switch (_d.label) {
122
122
  case 0:
123
123
  if (!step.dependencies) return [3 /*break*/, 2];
124
- idProyecto = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.id;
124
+ idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
125
125
  if (!idProyecto) {
126
126
  return [2 /*return*/, null]; //null para indicar que falta la depedency
127
127
  }
@@ -130,7 +130,7 @@ function CBRStepMapper(props) {
130
130
  idProyecto +
131
131
  '&idOrganization=' +
132
132
  idOrganization)];
133
- case 1: return [2 /*return*/, (_c.sent()).data];
133
+ case 1: return [2 /*return*/, (_d.sent()).data];
134
134
  case 2: return [2 /*return*/, null];
135
135
  }
136
136
  });
@@ -78,9 +78,9 @@ function EntityValuePicker(_a) {
78
78
  var idOrganization = _a.idOrganization;
79
79
  return __awaiter(_this, void 0, void 0, function () {
80
80
  var urlPath, _i, _b, path, idEntityValue, currentValue, params, _c, _d, filter, currentValue, url, response;
81
- var _e, _f, _g;
82
- return __generator(this, function (_h) {
83
- switch (_h.label) {
81
+ var _e, _f, _g, _h, _j;
82
+ return __generator(this, function (_k) {
83
+ switch (_k.label) {
84
84
  case 0:
85
85
  urlPath = '';
86
86
  for (_i = 0, _b = step.path; _i < _b.length; _i++) {
@@ -88,17 +88,17 @@ function EntityValuePicker(_a) {
88
88
  idEntityValue = 'null';
89
89
  switch (path.type) {
90
90
  case EntityValueDataTypes.STEP:
91
- currentValue = dependencyStore[path.idStep];
91
+ currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
92
92
  if (!currentValue)
93
93
  return [2 /*return*/, null];
94
94
  if (typeof currentValue === 'string')
95
95
  idEntityValue = currentValue;
96
96
  else
97
- idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
97
+ idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
98
98
  break;
99
99
  case EntityValueDataTypes.VALUE:
100
100
  default:
101
- idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
101
+ idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
102
102
  break;
103
103
  }
104
104
  urlPath +=
@@ -111,12 +111,12 @@ function EntityValuePicker(_a) {
111
111
  filter = _d[_c];
112
112
  switch (filter.type) {
113
113
  case EntityValueDataTypes.STEP:
114
- currentValue = dependencyStore[filter.idStep];
114
+ currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
115
115
  if (currentValue) {
116
116
  if (typeof currentValue === 'string')
117
117
  params.set(filter.idProperty, currentValue);
118
118
  else
119
- params.set(filter.idProperty, (_g = currentValue._id) !== null && _g !== void 0 ? _g : currentValue.id);
119
+ params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
120
120
  }
121
121
  else if (filter.required) {
122
122
  return [2 /*return*/, null];
@@ -133,7 +133,7 @@ function EntityValuePicker(_a) {
133
133
  ? widgetInstance.get(url)
134
134
  : axiosInstance.get(url))];
135
135
  case 1:
136
- response = _h.sent();
136
+ response = _k.sent();
137
137
  return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
138
138
  }
139
139
  });
@@ -193,7 +193,7 @@ function EntityValuePickerStep(props) {
193
193
  if (!originalValues[step.id] && defaultValue) {
194
194
  props.setDependencyStore(function (dependencies) {
195
195
  var _a;
196
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = props.defaultValue, _a)));
196
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = { type: step.type, value: props.defaultValue }, _a)));
197
197
  });
198
198
  }
199
199
  }, []);
@@ -207,7 +207,10 @@ function EntityValuePickerStep(props) {
207
207
  if (dependencyStore[step.id] !== undefined) {
208
208
  props.setDependencyStore(function (dependencies) {
209
209
  var _a;
210
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = value !== null && value !== void 0 ? value : null, _a)));
210
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
211
+ type: step.type,
212
+ value: value !== null && value !== void 0 ? value : null,
213
+ }, _a)));
211
214
  });
212
215
  }
213
216
  field.onChange(value);
@@ -37,7 +37,7 @@ import { Controller } from 'react-hook-form';
37
37
  import StepTypes, { ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, MapperStyleTypes, OptionTypes, } from '../../../../constants/FormStepTypes';
38
38
  import RoundedButton from '../../../../shared/RoundedButton/RoundedButton';
39
39
  import { nanoid } from 'nanoid';
40
- import { calcStepDependencyValue } from '../../../Form/ColumnForm/ColumnForm';
40
+ import { calcStepDependencyValue, } from '../../../Form/ColumnForm/ColumnForm';
41
41
  import MapperElementComponent from './Element/MapperElement';
42
42
  import AYFFormStepTypes from '../../../../constants/AYFFormStepTypes';
43
43
  import CBRFormStepTypes from '../../../../constants/CBRFormStepTypes';
@@ -70,7 +70,10 @@ export function ElementsComponent(_a) {
70
70
  setDependencyStore(function (dependencyStore) {
71
71
  var _a;
72
72
  var _b;
73
- return (__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = (_b = elements.map(function (element) { return element.value; })) !== null && _b !== void 0 ? _b : null, _a)));
73
+ return (__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = {
74
+ type: step.type,
75
+ value: (_b = elements.map(function (element) { return element.value; })) !== null && _b !== void 0 ? _b : null,
76
+ }, _a)));
74
77
  });
75
78
  }
76
79
  others.onChange(elements);
@@ -185,7 +188,10 @@ function calcRecursiveData(element, newSteps, deps, customSteps, originalValues)
185
188
  var newId = element.ids[idDep];
186
189
  if (newId) {
187
190
  step.dependencies[i] = newId;
188
- deps[newId] = calcStepDependencyValue(newSteps[newId], originalValues);
191
+ deps[newId] = {
192
+ type: newSteps[newId].type,
193
+ value: calcStepDependencyValue(newSteps[newId], originalValues),
194
+ };
189
195
  }
190
196
  }
191
197
  }
@@ -263,7 +269,10 @@ function calcRecursiveData(element, newSteps, deps, customSteps, originalValues)
263
269
  var newId = element.ids[path.idStep];
264
270
  if (newId) {
265
271
  path.idStep = newId;
266
- deps[newId] = calcStepDependencyValue(newSteps[newId], originalValues);
272
+ deps[newId] = {
273
+ type: newSteps[newId].type,
274
+ value: calcStepDependencyValue(newSteps[newId], originalValues),
275
+ };
267
276
  }
268
277
  break;
269
278
  default:
@@ -277,7 +286,10 @@ function calcRecursiveData(element, newSteps, deps, customSteps, originalValues)
277
286
  var newId = element.ids[filter.idStep];
278
287
  if (newId) {
279
288
  filter.idStep = newId;
280
- deps[newId] = calcStepDependencyValue(newSteps[newId], originalValues);
289
+ deps[newId] = {
290
+ type: newSteps[newId].type,
291
+ value: calcStepDependencyValue(newSteps[newId], originalValues),
292
+ };
281
293
  }
282
294
  break;
283
295
  default:
@@ -77,44 +77,47 @@ export function SmartSelect(_a) {
77
77
  var _b, _c, _d, _e;
78
78
  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, 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", "getValueWarning", "getOptionSelected", "setDependencyStore"]);
79
79
  var _f = useState(true), first = _f[0], setFirst = _f[1];
80
- var _g = useState(), options = _g[0], setOptions = _g[1];
81
- var _h = useState(), error = _h[0], setError = _h[1];
82
- var _j = useState(false), loading = _j[0], setLoading = _j[1];
83
- var calcInvalidDeps = function () {
84
- var calcDependencies = function (idStep, deps) {
85
- if (deps === void 0) { deps = []; }
86
- var step = form.steps[idStep];
87
- if (step === null || step === void 0 ? void 0 : step.dependencies) {
88
- for (var _i = 0, _a = step.dependencies; _i < _a.length; _i++) {
89
- var dep = _a[_i];
90
- if (!deps.includes(dep)) {
91
- deps.push.apply(deps, __spreadArray(__spreadArray([], calcDependencies(dep, deps), false), [dep], false));
92
- }
80
+ var _g = useState(false), disabled = _g[0], setDisabled = _g[1];
81
+ var _h = useState(), options = _h[0], setOptions = _h[1];
82
+ var _j = useState(), error = _j[0], setError = _j[1];
83
+ var _k = useState(false), loading = _k[0], setLoading = _k[1];
84
+ var calcDependencies = function (idStep, deps) {
85
+ if (deps === void 0) { deps = []; }
86
+ var step = form.steps[idStep];
87
+ if (step === null || step === void 0 ? void 0 : step.dependencies) {
88
+ for (var _i = 0, _a = step.dependencies; _i < _a.length; _i++) {
89
+ var dep = _a[_i];
90
+ if (!deps.includes(dep)) {
91
+ deps.push.apply(deps, __spreadArray(__spreadArray([], calcDependencies(dep, deps), false), [dep], false));
93
92
  }
94
93
  }
95
- return deps;
96
- };
94
+ }
95
+ return deps;
96
+ };
97
+ var calcInvalidDeps = function () {
97
98
  var missingDeps = [];
98
99
  for (var _i = 0, _a = calcDependencies(step.id); _i < _a.length; _i++) {
99
100
  var idDep = _a[_i];
100
- if (dependencyStore[idDep] === null) {
101
+ var dependency = dependencyStore[idDep];
102
+ if ((dependency === null || dependency === void 0 ? void 0 : dependency.value) === null) {
101
103
  missingDeps.push(idDep);
102
104
  }
103
105
  }
104
106
  return missingDeps;
105
107
  };
106
108
  var calcOptions = function (currentValue, invalidDeps) { return __awaiter(_this, void 0, void 0, function () {
107
- var resp, currentOption, invalids, error_1;
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
109
+ var resp, currentOption, invalids, empty, error_1;
110
+ var _a;
111
+ return __generator(this, function (_b) {
112
+ switch (_b.label) {
110
113
  case 0:
111
114
  setOptions(undefined);
112
- _a.label = 1;
115
+ _b.label = 1;
113
116
  case 1:
114
- _a.trys.push([1, 3, , 4]);
117
+ _b.trys.push([1, 3, , 4]);
115
118
  return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(organization, step, dependencyStore, others.domain))];
116
119
  case 2:
117
- resp = _a.sent();
120
+ resp = _b.sent();
118
121
  if (resp !== null) {
119
122
  if (invalidDeps !== undefined && currentValue) {
120
123
  currentOption = resp.find(function (option) {
@@ -130,11 +133,32 @@ export function SmartSelect(_a) {
130
133
  setError(undefined);
131
134
  }
132
135
  }
136
+ if (resp.length === 0) {
137
+ setDependencyStore(function (dependencyStore) {
138
+ var _a;
139
+ return (__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = {
140
+ type: step.type,
141
+ value: currentValue,
142
+ empty: true,
143
+ }, _a)));
144
+ });
145
+ }
146
+ else if ((_a = dependencyStore[step.id]) === null || _a === void 0 ? void 0 : _a.empty) {
147
+ setDependencyStore(function (dependencyStore) {
148
+ var _a;
149
+ return (__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = {
150
+ type: step.type,
151
+ value: currentValue,
152
+ }, _a)));
153
+ });
154
+ }
133
155
  }
156
+ empty = calcDependencies(step.id).find(function (idDep) { var _a; return (_a = dependencyStore[idDep]) === null || _a === void 0 ? void 0 : _a.empty; });
157
+ setDisabled(!!empty);
134
158
  setOptions(resp);
135
159
  return [3 /*break*/, 4];
136
160
  case 3:
137
- error_1 = _a.sent();
161
+ error_1 = _b.sent();
138
162
  console.error(error_1);
139
163
  setOptions(null);
140
164
  return [3 /*break*/, 4];
@@ -208,6 +232,8 @@ export function SmartSelect(_a) {
208
232
  ? '55px'
209
233
  : '43px',
210
234
  }, onClick: function () {
235
+ if (disabled)
236
+ return;
211
237
  if (options === null && !(!editable || postview)) {
212
238
  handleMissingDep();
213
239
  }
@@ -215,13 +241,15 @@ export function SmartSelect(_a) {
215
241
  setLoading(true);
216
242
  }
217
243
  }, "data-testid": step.id }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, onFocus: function () {
244
+ if (disabled)
245
+ return;
218
246
  if (options === null && !(!editable || postview)) {
219
247
  handleMissingDep();
220
248
  }
221
249
  if (options === undefined && !(!editable || postview)) {
222
250
  setLoading(true);
223
251
  }
224
- }, disabled: options === null, loading: loading, options: options !== null && options !== void 0 ? options : undefined, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_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) {
252
+ }, disabled: options === null || disabled, hidden: disabled, loading: loading, options: options !== null && options !== void 0 ? options : undefined, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_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) {
225
253
  valueOverwrite
226
254
  ? onChange(valueOverwrite(value))
227
255
  : onChange(value);
@@ -244,7 +272,10 @@ function SmartSelectStep(props) {
244
272
  if (!originalValues[step.id] && defaultValue) {
245
273
  props.setDependencyStore(function (dependencies) {
246
274
  var _a;
247
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = props.defaultValue, _a)));
275
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
276
+ type: step.type,
277
+ value: props.defaultValue,
278
+ }, _a)));
248
279
  });
249
280
  }
250
281
  }, []);
@@ -258,7 +289,10 @@ function SmartSelectStep(props) {
258
289
  if (dependencyStore[step.id] !== undefined) {
259
290
  props.setDependencyStore(function (dependencies) {
260
291
  var _a;
261
- return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = value !== null && value !== void 0 ? value : null, _a)));
292
+ return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
293
+ type: step.type,
294
+ value: value !== null && value !== void 0 ? value : null,
295
+ }, _a)));
262
296
  });
263
297
  }
264
298
  field.onChange(value);
@@ -3,13 +3,14 @@ import { StepProps } from '../Step';
3
3
  import { GSmartSelect } from '../../../@Types/GenericFormSteps';
4
4
  import { Organization } from '../../../@Types';
5
5
  import { FormStep } from '../../../@Types/FormStep';
6
+ import { DependencyStore } from '../../Form/ColumnForm/ColumnForm';
6
7
  export interface SmartSelectStepProps extends Omit<StepProps, 'step'> {
7
8
  /** The SmartSelectStep to display */
8
9
  step: GSmartSelect;
9
10
  /** The icon to display */
10
11
  icon?: React.ReactNode;
11
12
  /** Function to call to get the options of the selector, return null if dependency is not met */
12
- getOptions: (organization: Organization, step: GSmartSelect, dependencyStore: Record<string, any>, domain?: string) => Promise<any[] | null>;
13
+ getOptions: (organization: Organization, step: GSmartSelect, dependencyStore: DependencyStore, domain?: string) => Promise<any[] | null>;
13
14
  /** Function to determine the currently selected option */
14
15
  getOptionSelected: (option: any, value: any) => boolean;
15
16
  /** Function to determine the current value in string format */
@@ -37,6 +37,7 @@ import AYFStepMapper from './AYFStepMapper';
37
37
  import EntityValuePickerStep from './EntityValueStep/EntityValuePickerStep';
38
38
  import MapperStep from './MapperStep/MapperStep';
39
39
  import CollapsibleStep from './CollapsibleStep/CollapsibleStep';
40
+ import ApiSelectorStep from './ApiSelectorStep/ApiSelectorStep';
40
41
  function StepComponent(_a) {
41
42
  var _b, _c;
42
43
  var step = _a.step, props = __rest(_a, ["step"]);
@@ -91,6 +92,9 @@ function StepComponent(_a) {
91
92
  case Types.ENTITYVALUEPICKER: {
92
93
  return (_jsx(EntityValuePickerStep, __assign({}, props, { step: step, editable: editable })));
93
94
  }
95
+ case Types.API_SELECTOR: {
96
+ return (_jsx(ApiSelectorStep, __assign({}, props, { step: step, editable: editable })));
97
+ }
94
98
  case Types.MAPPER: {
95
99
  return (_jsx(MapperStep, __assign({}, props, { step: step, editable: editable })));
96
100
  }
@@ -1,5 +1,5 @@
1
1
  import { FormSize } from '../../@Types/Form';
2
- import { CheckBox, ClassifierSelector, EntityValuePicker, FormSelector, FormStep } from '../../@Types/FormStep';
3
- export declare function calcFillerSize(step: FormSelector | ClassifierSelector | EntityValuePicker | CheckBox, steps: Record<string, FormStep>, values: Record<string, unknown>, size: FormSize): number;
2
+ import { ApiSelector, CheckBox, ClassifierSelector, EntityValuePicker, FormSelector, FormStep } from '../../@Types/FormStep';
3
+ export declare function calcFillerSize(step: FormSelector | ClassifierSelector | EntityValuePicker | ApiSelector | CheckBox, steps: Record<string, FormStep>, values: Record<string, unknown>, size: FormSize): number;
4
4
  export declare function recursivelyCheckOpenSize(idStep: string, steps: Record<string, FormStep>, values: Record<string, any>): number;
5
5
  export declare const calcStepWidth: (stepSize: 1 | 2 | 3 | 4, size: FormSize) => number;
@@ -1,4 +1,4 @@
1
- import Types, { ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../../constants/FormStepTypes';
1
+ import Types, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../../constants/FormStepTypes';
2
2
  export function calcFillerSize(step, steps, values, size) {
3
3
  var _a;
4
4
  var maxSize = (_a = step.maxSize) !== null && _a !== void 0 ? _a : size.blockNum;
@@ -43,7 +43,7 @@ export function recursivelyCheckOpenSize(idStep, steps, values) {
43
43
  }
44
44
  return size;
45
45
  }
46
- if (step.type === Types.ENTITYVALUEPICKER) {
46
+ else if (step.type === Types.ENTITYVALUEPICKER) {
47
47
  var size = step.size;
48
48
  if (value) {
49
49
  var currentOption = step.options[value];
@@ -58,12 +58,27 @@ export function recursivelyCheckOpenSize(idStep, steps, values) {
58
58
  }
59
59
  return size;
60
60
  }
61
+ else if (step.type === Types.API_SELECTOR) {
62
+ var size = step.size;
63
+ if (value) {
64
+ var currentOption = step.options[value];
65
+ if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
66
+ var optionSize = 0;
67
+ for (var _f = 0, _g = currentOption.steps; _f < _g.length; _f++) {
68
+ var pStepId = _g[_f];
69
+ optionSize += recursivelyCheckOpenSize(pStepId, steps, values);
70
+ }
71
+ size += optionSize;
72
+ }
73
+ }
74
+ return size;
75
+ }
61
76
  if (step.type === Types.CHECKBOX) {
62
77
  var size = step.size;
63
78
  var stepSteps = value ? step.steps : step.uncheckedSteps;
64
79
  var optionSize = 0;
65
- for (var _f = 0, _g = stepSteps !== null && stepSteps !== void 0 ? stepSteps : []; _f < _g.length; _f++) {
66
- var pStepId = _g[_f];
80
+ for (var _h = 0, _j = stepSteps !== null && stepSteps !== void 0 ? stepSteps : []; _h < _j.length; _h++) {
81
+ var pStepId = _j[_h];
67
82
  optionSize += recursivelyCheckOpenSize(pStepId, steps, values);
68
83
  }
69
84
  size += optionSize;
@@ -60,7 +60,10 @@ function TextInputStep(_a) {
60
60
  setTimer(setTimeout(function () {
61
61
  setDependencyStore(function (deps) {
62
62
  var _a;
63
- return (__assign(__assign({}, deps), (_a = {}, _a[step.id] = value, _a)));
63
+ return (__assign(__assign({}, deps), (_a = {}, _a[step.id] = {
64
+ type: step.type,
65
+ value: value,
66
+ }, _a)));
64
67
  });
65
68
  setTimer(null);
66
69
  }, 1000));
@@ -18,7 +18,8 @@ export declare enum StepTypes {
18
18
  CLASSIFIER_SELECTOR = "CLASSIFIER_SELECTOR",
19
19
  COLLAPSIBLE = "COLLAPSIBLE",
20
20
  MAPPER = "MAPPER",
21
- ENTITYVALUEPICKER = "ENTITYVALUEPICKER"
21
+ ENTITYVALUEPICKER = "ENTITYVALUEPICKER",
22
+ API_SELECTOR = "API_SELECTOR"
22
23
  }
23
24
  export declare enum OptionTypes {
24
25
  DEFAULT = "DEFAULT",
@@ -33,6 +34,10 @@ export declare enum EntityValueOptionTypes {
33
34
  HIDE = "ENTITY_VALUE_HIDE",
34
35
  NESTED = "ENTITY_VALUE_NESTED"
35
36
  }
37
+ export declare enum ApiSelectorOptionTypes {
38
+ HIDE = "API_SELECTOR_HIDE",
39
+ NESTED = "API_SELECTOR_NESTED"
40
+ }
36
41
  export declare enum RatingTypes {
37
42
  SCALE = "SCALE",
38
43
  SATISFACTION = "SATISFACTION",
@@ -48,3 +53,7 @@ export declare enum EntityValueDataTypes {
48
53
  STEP = "STEP",
49
54
  VALUE = "VALUE"
50
55
  }
56
+ export declare enum ApiSelectorParamTypes {
57
+ STEP = "STEP",
58
+ VALUE = "VALUE"
59
+ }
@@ -22,6 +22,7 @@ export var StepTypes;
22
22
  StepTypes["COLLAPSIBLE"] = "COLLAPSIBLE";
23
23
  StepTypes["MAPPER"] = "MAPPER";
24
24
  StepTypes["ENTITYVALUEPICKER"] = "ENTITYVALUEPICKER";
25
+ StepTypes["API_SELECTOR"] = "API_SELECTOR";
25
26
  })(StepTypes || (StepTypes = {}));
26
27
  export var OptionTypes;
27
28
  (function (OptionTypes) {
@@ -39,6 +40,11 @@ export var EntityValueOptionTypes;
39
40
  EntityValueOptionTypes["HIDE"] = "ENTITY_VALUE_HIDE";
40
41
  EntityValueOptionTypes["NESTED"] = "ENTITY_VALUE_NESTED";
41
42
  })(EntityValueOptionTypes || (EntityValueOptionTypes = {}));
43
+ export var ApiSelectorOptionTypes;
44
+ (function (ApiSelectorOptionTypes) {
45
+ ApiSelectorOptionTypes["HIDE"] = "API_SELECTOR_HIDE";
46
+ ApiSelectorOptionTypes["NESTED"] = "API_SELECTOR_NESTED";
47
+ })(ApiSelectorOptionTypes || (ApiSelectorOptionTypes = {}));
42
48
  export var RatingTypes;
43
49
  (function (RatingTypes) {
44
50
  RatingTypes["SCALE"] = "SCALE";
@@ -57,3 +63,8 @@ export var EntityValueDataTypes;
57
63
  EntityValueDataTypes["STEP"] = "STEP";
58
64
  EntityValueDataTypes["VALUE"] = "VALUE";
59
65
  })(EntityValueDataTypes || (EntityValueDataTypes = {}));
66
+ export var ApiSelectorParamTypes;
67
+ (function (ApiSelectorParamTypes) {
68
+ ApiSelectorParamTypes["STEP"] = "STEP";
69
+ ApiSelectorParamTypes["VALUE"] = "VALUE";
70
+ })(ApiSelectorParamTypes || (ApiSelectorParamTypes = {}));
@@ -27,6 +27,8 @@ interface StyleProps {
27
27
  helperTextColor?: string;
28
28
  /** If custom icon exists and should be displayed */
29
29
  showIcon?: boolean;
30
+ /** If the selector is completely hidden */
31
+ hidden?: boolean;
30
32
  }
31
33
  export interface RoundedSmartSelectProps extends Omit<TextFieldProps, 'color' | 'onFocus'>, StyleProps {
32
34
  /** Currently selected value */
@@ -62,5 +64,5 @@ export interface RoundedSmartSelectProps extends Omit<TextFieldProps, 'color' |
62
64
  changeListener?: (value: any) => void;
63
65
  onFocus?: any;
64
66
  }
65
- export default function RoundedSmartSelect({ options, value, handleUpdate, label, getValueString, color, errorColor, focusColor, helperTextColor, outlineColor, backgroundColor, cantEdit, loading, height, fontSize, required, changeListener, error, getOptionSelected, helperText, readOnly, borderRadius, fontWeight, icon, searchable, containerMargin, showIcon, inputRef, disabled, creatable, onBlur, name, onFocus, }: RoundedSmartSelectProps): JSX.Element;
67
+ export default function RoundedSmartSelect({ options, value, handleUpdate, label, getValueString, color, errorColor, focusColor, helperTextColor, outlineColor, backgroundColor, cantEdit, loading, height, fontSize, required, changeListener, error, getOptionSelected, helperText, readOnly, borderRadius, fontWeight, icon, searchable, containerMargin, showIcon, inputRef, disabled, hidden, creatable, onBlur, name, onFocus, }: RoundedSmartSelectProps): JSX.Element;
66
68
  export {};
@@ -34,9 +34,10 @@ var useTextfieldStyles = function (props) {
34
34
  var _a, _b, _c;
35
35
  return ({
36
36
  root: {
37
+ opacity: props.hidden ? 0.5 : 1,
37
38
  borderRadius: props.borderRadius,
38
39
  '& input, textarea': {
39
- cursor: props.cantEdit ? 'default' : 'text',
40
+ cursor: props.cantEdit || props.hidden ? 'default' : 'text',
40
41
  fontWeight: props.fontWeight,
41
42
  color: props.color,
42
43
  fontSize: props.fontSize,
@@ -95,7 +96,7 @@ var useTextfieldStyles = function (props) {
95
96
  },
96
97
  },
97
98
  '& .EF-MuiOutlinedInput-root:hover .EF-MuiOutlinedInput-notchedOutline': {
98
- borderColor: props.cantEdit
99
+ borderColor: props.cantEdit || props.hidden
99
100
  ? props.outlineColor
100
101
  : props.focusColor,
101
102
  },
@@ -141,7 +142,7 @@ var useTextfieldStyles = function (props) {
141
142
  };
142
143
  export default function RoundedSmartSelect(_a) {
143
144
  var _b;
144
- var options = _a.options, _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, 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;
145
+ var options = _a.options, _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, 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.hidden, hidden = _w === void 0 ? false : _w, _x = _a.creatable, creatable = _x === void 0 ? false : _x, onBlur = _a.onBlur, name = _a.name, onFocus = _a.onFocus;
145
146
  var props = {
146
147
  color: color,
147
148
  height: height,
@@ -154,6 +155,7 @@ export default function RoundedSmartSelect(_a) {
154
155
  readOnly: readOnly,
155
156
  fontSize: fontSize,
156
157
  fontWeight: fontWeight,
158
+ hidden: hidden,
157
159
  cantEdit: cantEdit,
158
160
  showIcon: showIcon && icon !== undefined,
159
161
  };
@@ -211,7 +213,7 @@ export default function RoundedSmartSelect(_a) {
211
213
  }
212
214
  }, renderOption: function (option) {
213
215
  return typeof option === 'string' ? option : option.label;
214
- }, 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 }))); }, noOptionsText: "No hay opciones" }));
216
+ }, renderInput: function (params) { return (_jsx(TextField, __assign({ classes: textFieldClasses }, params, { inputRef: inputRef, onBlur: onBlur, name: name, variant: "outlined", label: label, required: required, error: !hidden && error, helperText: hidden ? undefined : helperText }))); }, noOptionsText: "No hay opciones" }));
215
217
  }
216
218
  else {
217
219
  return (_jsxs(RoundedSelect, __assign({ onBlur: onBlur, onFocus: onFocus, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: function (event) {
@@ -220,7 +222,7 @@ export default function RoundedSmartSelect(_a) {
220
222
  }));
221
223
  }, onOpen: function () {
222
224
  //Show loading icon if loading
223
- }, value: getValueString(value), color: color, errorColor: errorColor, focusColor: focusColor, helperTextColor: helperTextColor, backgroundColor: backgroundColor, outlineColor: outlineColor, cantEdit: cantEdit, disabled: cantEdit || disabled, label: label, required: required, readOnly: readOnly, helperText: helperText, containerMargin: containerMargin, height: height, fontSize: fontSize, error: error, iconComponent: loading
225
+ }, value: getValueString(value), color: color, errorColor: errorColor, focusColor: focusColor, helperTextColor: helperTextColor, backgroundColor: backgroundColor, outlineColor: outlineColor, cantEdit: cantEdit, disabled: cantEdit || disabled, label: label, required: required, readOnly: readOnly, helperText: hidden ? undefined : helperText, containerMargin: containerMargin, height: height, fontSize: fontSize, error: !hidden && error, iconComponent: loading
224
226
  ? function () { return (_jsx("div", __assign({ style: {
225
227
  marginTop: 3,
226
228
  marginRight: 8,
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.125",
4
+ "version":"1.9.126-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",