@arquimedes.co/eureka-forms 1.9.118-test → 1.9.119-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.
- package/dist/@Types/Branding.d.ts +13 -0
- package/dist/@Types/Branding.js +1 -0
- package/dist/@Types/Form.d.ts +2 -0
- package/dist/@Types/FormStep.d.ts +37 -2
- package/dist/@Types/Organization.d.ts +3 -11
- package/dist/App.js +26 -16
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +8 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +8 -2
- package/dist/FormComponents/Form/Form.d.ts +3 -1
- package/dist/FormComponents/Form/Form.js +5 -5
- package/dist/FormComponents/Section/Section.d.ts +3 -2
- package/dist/FormComponents/Step/@Construction/CBRElementStep/CBRElementStep.js +6 -6
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +4 -1
- package/dist/FormComponents/Step/@Construction/CBRPropertyStep/CBRPropertyStep.js +6 -6
- package/dist/FormComponents/Step/AYFStepMapper.js +13 -16
- package/dist/FormComponents/Step/ApiSelectorStep/ApiSelectorStep.d.ts +15 -0
- package/dist/FormComponents/Step/ApiSelectorStep/ApiSelectorStep.js +35 -0
- package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +4 -0
- package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +213 -0
- package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +25 -0
- package/dist/FormComponents/Step/CBRStepMapper.js +10 -10
- package/dist/FormComponents/Step/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +14 -11
- package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/MaterialMapperStep.js +17 -5
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +60 -26
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.d.ts +2 -1
- package/dist/FormComponents/Step/Step.js +4 -0
- package/dist/FormComponents/Step/StepFunctions.d.ts +2 -2
- package/dist/FormComponents/Step/StepFunctions.js +19 -4
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +4 -1
- package/dist/constants/FormStepTypes.d.ts +10 -1
- package/dist/constants/FormStepTypes.js +11 -0
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +3 -1
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +8 -6
- package/package.json +1 -1
package/dist/FormComponents/Step/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js
ADDED
|
@@ -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 (
|
|
79
|
-
switch (
|
|
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 = (
|
|
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 (
|
|
121
|
-
switch (
|
|
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*/, (
|
|
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 (
|
|
83
|
-
switch (
|
|
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 = (
|
|
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 = (
|
|
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, (
|
|
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 =
|
|
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] =
|
|
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] =
|
|
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] =
|
|
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] =
|
|
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] =
|
|
289
|
+
deps[newId] = {
|
|
290
|
+
type: newSteps[newId].type,
|
|
291
|
+
value: calcStepDependencyValue(newSteps[newId], originalValues),
|
|
292
|
+
};
|
|
281
293
|
}
|
|
282
294
|
break;
|
|
283
295
|
default:
|
package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js
CHANGED
|
@@ -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(),
|
|
81
|
-
var _h = useState(),
|
|
82
|
-
var _j = useState(
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
-
|
|
115
|
+
_b.label = 1;
|
|
113
116
|
case 1:
|
|
114
|
-
|
|
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 =
|
|
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 =
|
|
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] =
|
|
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] =
|
|
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:
|
|
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;
|