@arquimedes.co/eureka-forms 2.0.86-test → 2.0.86

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.
@@ -148,7 +148,7 @@ export interface ValueEntityValuePickerPath {
148
148
  type: EntityValueDataTypes.VALUE;
149
149
  idEntityValue: string | null;
150
150
  }
151
- export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
151
+ export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter;
152
152
  export interface StepEntityValuePickerFilter {
153
153
  idProperty: string;
154
154
  type: EntityValueDataTypes.STEP;
@@ -161,10 +161,6 @@ export interface ValueEntityValuePickerFilter {
161
161
  type: EntityValueDataTypes.VALUE;
162
162
  value: any;
163
163
  }
164
- export interface IntegrationEntityValuePickerFilter {
165
- idProperty: string;
166
- type: EntityValueDataTypes.INTEGRATION;
167
- }
168
164
  export interface ApiSelector extends GSteps.GSmartSelect {
169
165
  type: FormStepTypes.API_SELECTOR;
170
166
  icon: string | null;
package/dist/App/App.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Classifier, Form } from '../@Types/Form';
3
3
  import './App.css';
4
- import { DependencyStore } from '../Form/Form';
5
4
  import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
6
5
  import { EditorState } from 'draft-js';
7
- import { IntegrationEntityValuePickerFilter } from '../@Types/FormStep';
8
6
  export interface AppProps {
9
7
  /** If the app is currently a widget */
10
8
  isWidget?: boolean;
@@ -52,8 +50,6 @@ export interface AppProps {
52
50
  handleConfirmed?: () => void;
53
51
  /** Function called to scroll to the top */
54
52
  scrollToTop?: () => void;
55
- /** Function to call to reload the form */
56
- calcEntityValueIntegrationFilter?: (filter: IntegrationEntityValuePickerFilter, store: DependencyStore) => Promise<string | null>;
57
53
  }
58
54
  export declare const IdFormContext: React.Context<string>;
59
55
  declare function AppComponent({ formData, valuesData, ...props }: AppProps): JSX.Element;
package/dist/App/App.js CHANGED
@@ -75,7 +75,6 @@ function App(_a) {
75
75
  fetchDownloadUrl: props.fetchDownloadUrl,
76
76
  customStepProps: (_g = props.customStepProps) !== null && _g !== void 0 ? _g : {},
77
77
  customClientInfoStep: props.customClientInfoStep,
78
- calcEntityValueIntegrationFilter: props.calcEntityValueIntegrationFilter,
79
78
  } }, { children: _jsx("div", __assign({ className: styles.container }, { children: _jsx(FormComponent, { form: form, reload: reload, branding: branding, apiKey: props.apiKey, isWidget: !!isWidget, customSteps: customSteps, containerRef: containerRef, setSubmit: props.setSubmit, customSubmit: props.customSubmit, scrollToTop: props.scrollToTop, customSubmitBtns: props.customSubmitBtns, customConfirmation: props.customConfirmation }) })) })));
80
79
  }
81
80
  }
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
3
- import { AppProps } from '../App/App';
4
- export interface CustomContextData extends Pick<AppProps, 'calcEntityValueIntegrationFilter'> {
3
+ export interface CustomContextData {
5
4
  sendLabel?: string;
6
5
  customStepProps: Record<string, unknown>;
7
6
  customSteps: Record<string, CustomStep>;
@@ -66,7 +66,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
66
  return to.concat(ar || Array.prototype.slice.call(from));
67
67
  };
68
68
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
69
- import React, { useContext } from 'react';
69
+ import React, { useContext, useMemo } from 'react';
70
70
  import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../constants/FormStepTypes';
71
71
  import StepComponent from '../../Step';
72
72
  import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
@@ -78,6 +78,7 @@ import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
78
78
  import { recursivelyCalcConditionSteps } from '../../StepHooks';
79
79
  import { evaluateCondition } from '../../StepFunctions';
80
80
  function ApiSelectorComponent(_a) {
81
+ var _this = this;
81
82
  var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
82
83
  var form = useContext(FormContext);
83
84
  function calcOptionId(option) {
@@ -88,6 +89,67 @@ function ApiSelectorComponent(_a) {
88
89
  var _a;
89
90
  return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
90
91
  }
92
+ var getApiOptions = useMemo(function () {
93
+ return function (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
94
+ function calcOptionId(option) {
95
+ var _a;
96
+ return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
97
+ }
98
+ var params, _i, _a, filter, currentValue, filterStep, url, response;
99
+ var _b, _c;
100
+ return __generator(this, function (_d) {
101
+ switch (_d.label) {
102
+ case 0:
103
+ params = new URLSearchParams({});
104
+ for (_i = 0, _a = step.queryParams; _i < _a.length; _i++) {
105
+ filter = _a[_i];
106
+ switch (filter.type) {
107
+ case ApiSelectorParamTypes.STEP: {
108
+ currentValue = (_b = dependencyStore[filter.idStep]) === null || _b === void 0 ? void 0 : _b.value;
109
+ filterStep = form.steps[filter.idStep];
110
+ if (currentValue) {
111
+ if (filterStep.type ===
112
+ FormStepTypes.API_SELECTOR) {
113
+ params.set(filter.key, currentValue[step.idAttribute]);
114
+ }
115
+ else if (typeof currentValue === 'string')
116
+ params.set(filter.key, currentValue);
117
+ else
118
+ params.set(filter.key, (_c = currentValue.label) !== null && _c !== void 0 ? _c : currentValue.id);
119
+ }
120
+ else if (filter.required) {
121
+ return [2 /*return*/, null];
122
+ }
123
+ break;
124
+ }
125
+ case ApiSelectorParamTypes.VALUE:
126
+ default:
127
+ params.set(filter.key, filter.value);
128
+ break;
129
+ }
130
+ }
131
+ url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
132
+ if (idOrganization &&
133
+ url.includes(process.env.REACT_APP_DOMAIN))
134
+ params.set('idOrganization', idOrganization);
135
+ if (!step.url.includes('?'))
136
+ url += '?';
137
+ url += params.toString();
138
+ return [4 /*yield*/, (idOrganization
139
+ ? widgetInstance.get(url)
140
+ : axiosInstance.get(url))];
141
+ case 1:
142
+ response = _d.sent();
143
+ return [2 /*return*/, response.data.filter(function (option) {
144
+ var _a;
145
+ return calcOptionId(option) &&
146
+ ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
147
+ ApiSelectorOptionTypes.HIDE;
148
+ })];
149
+ }
150
+ });
151
+ }); };
152
+ }, [form]);
91
153
  return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, __assign({}, others, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
92
154
  return calcOptionId(option) === calcOptionId(value);
93
155
  }, calcDepError: function (steps) {
@@ -137,56 +199,3 @@ function ApiSelectorComponent(_a) {
137
199
  } })) })));
138
200
  }
139
201
  export default ApiSelectorComponent;
140
- var getApiOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
141
- function calcOptionId(option) {
142
- var _a;
143
- return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
144
- }
145
- var params, _i, _a, filter, currentValue, url, response;
146
- var _b, _c;
147
- return __generator(this, function (_d) {
148
- switch (_d.label) {
149
- case 0:
150
- params = new URLSearchParams({});
151
- for (_i = 0, _a = step.queryParams; _i < _a.length; _i++) {
152
- filter = _a[_i];
153
- switch (filter.type) {
154
- case ApiSelectorParamTypes.STEP: {
155
- currentValue = (_b = dependencyStore[filter.idStep]) === null || _b === void 0 ? void 0 : _b.value;
156
- if (currentValue) {
157
- if (typeof currentValue === 'string')
158
- params.set(filter.key, currentValue);
159
- else
160
- params.set(filter.key, (_c = currentValue.label) !== null && _c !== void 0 ? _c : currentValue.id);
161
- }
162
- else if (filter.required) {
163
- return [2 /*return*/, null];
164
- }
165
- break;
166
- }
167
- case ApiSelectorParamTypes.VALUE:
168
- default:
169
- params.set(filter.key, filter.value);
170
- break;
171
- }
172
- }
173
- url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
174
- if (idOrganization && url.includes(process.env.REACT_APP_DOMAIN))
175
- params.set('idOrganization', idOrganization);
176
- if (!step.url.includes('?'))
177
- url += '?';
178
- url += params.toString();
179
- return [4 /*yield*/, (idOrganization
180
- ? widgetInstance.get(url)
181
- : axiosInstance.get(url))];
182
- case 1:
183
- response = _d.sent();
184
- return [2 /*return*/, response.data.filter(function (option) {
185
- var _a;
186
- return calcOptionId(option) &&
187
- ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
188
- ApiSelectorOptionTypes.HIDE;
189
- })];
190
- }
191
- });
192
- }); };
@@ -67,12 +67,10 @@ import { evaluateCondition } from '../../StepFunctions';
67
67
  import { recursivelyCalcConditionSteps, selectDependencies, } from '../../StepHooks';
68
68
  import { useAppSelector } from '../../../hooks';
69
69
  import MaterialEntityValueDialog from './MaterialEntityValueDialog/MaterialEntityValueDialog';
70
- import CustomContext from '../../../Contexts/CustomContext';
71
70
  function EntityValuePickerStep(_a) {
72
71
  var _b, _c;
73
72
  var step = _a.step, editable = _a.editable;
74
73
  var form = useContext(FormContext);
75
- var calcEntityValueIntegrationFilter = useContext(CustomContext).calcEntityValueIntegrationFilter;
76
74
  var _d = useState(), dialogs = _d[0], setDialogs = _d[1];
77
75
  var dialogsIdStepDeps = useMemo(function () {
78
76
  var ids = [];
@@ -98,9 +96,6 @@ function EntityValuePickerStep(_a) {
98
96
  : undefined;
99
97
  });
100
98
  }, []);
101
- var getEntityValueOptions = useMemo(function () {
102
- return generateGetEntityValueOptionsFunction(calcEntityValueIntegrationFilter);
103
- }, [calcEntityValueIntegrationFilter]);
104
99
  return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
105
100
  return option._id === value._id;
106
101
  }, calcDepError: function (steps) {
@@ -176,90 +171,65 @@ function EntityValuePickerStep(_a) {
176
171
  } }) }))] }));
177
172
  }
178
173
  export default EntityValuePickerStep;
179
- var generateGetEntityValueOptionsFunction = function (calcEntityValueIntegrationFilter) {
180
- return function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
181
- var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, _d, currentValue, value, url, response;
182
- var _e, _f, _g, _h, _j;
183
- return __generator(this, function (_k) {
184
- switch (_k.label) {
185
- case 0:
186
- if (!idOrganization)
187
- return [2 /*return*/, null];
188
- urlPath = '';
189
- for (_i = 0, _a = step.path; _i < _a.length; _i++) {
190
- path = _a[_i];
191
- idEntityValue = 'null';
192
- switch (path.type) {
193
- case EntityValueDataTypes.STEP: {
194
- currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
195
- if (!currentValue)
196
- return [2 /*return*/, null];
197
- if (typeof currentValue === 'string')
198
- idEntityValue = currentValue;
199
- else
200
- idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
201
- break;
202
- }
203
- case EntityValueDataTypes.VALUE:
204
- default:
205
- idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
206
- break;
207
- }
208
- urlPath +=
209
- '/' +
210
- path.idEntity +
211
- (idEntityValue ? '/' + idEntityValue : '');
212
- }
213
- params = new URLSearchParams({});
214
- _b = 0, _c = step.filters;
215
- _k.label = 1;
216
- case 1:
217
- if (!(_b < _c.length)) return [3 /*break*/, 8];
218
- filter = _c[_b];
219
- _d = filter.type;
220
- switch (_d) {
221
- case EntityValueDataTypes.STEP: return [3 /*break*/, 2];
222
- case EntityValueDataTypes.INTEGRATION: return [3 /*break*/, 3];
223
- case EntityValueDataTypes.VALUE: return [3 /*break*/, 6];
224
- }
225
- return [3 /*break*/, 6];
226
- case 2:
227
- {
228
- currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
229
- if (currentValue) {
174
+ var getEntityValueOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
175
+ var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, currentValue, url, response;
176
+ var _d, _e, _f, _g, _h;
177
+ return __generator(this, function (_j) {
178
+ switch (_j.label) {
179
+ case 0:
180
+ if (!idOrganization)
181
+ return [2 /*return*/, null];
182
+ urlPath = '';
183
+ for (_i = 0, _a = step.path; _i < _a.length; _i++) {
184
+ path = _a[_i];
185
+ idEntityValue = 'null';
186
+ switch (path.type) {
187
+ case EntityValueDataTypes.STEP: {
188
+ currentValue = (_d = dependencyStore[path.idStep]) === null || _d === void 0 ? void 0 : _d.value;
189
+ if (!currentValue)
190
+ return [2 /*return*/, null];
230
191
  if (typeof currentValue === 'string')
231
- params.set(filter.idProperty, currentValue);
192
+ idEntityValue = currentValue;
232
193
  else
233
- params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
194
+ idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
195
+ break;
234
196
  }
235
- else if (filter.required) {
236
- return [2 /*return*/, null];
197
+ case EntityValueDataTypes.VALUE:
198
+ default:
199
+ idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
200
+ break;
201
+ }
202
+ urlPath +=
203
+ '/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
204
+ }
205
+ params = new URLSearchParams({});
206
+ for (_b = 0, _c = step.filters; _b < _c.length; _b++) {
207
+ filter = _c[_b];
208
+ switch (filter.type) {
209
+ case EntityValueDataTypes.STEP: {
210
+ currentValue = (_g = dependencyStore[filter.idStep]) === null || _g === void 0 ? void 0 : _g.value;
211
+ if (currentValue) {
212
+ if (typeof currentValue === 'string')
213
+ params.set(filter.idProperty, currentValue);
214
+ else
215
+ params.set(filter.idProperty, (_h = currentValue._id) !== null && _h !== void 0 ? _h : currentValue.id);
216
+ }
217
+ else if (filter.required) {
218
+ return [2 /*return*/, null];
219
+ }
220
+ break;
237
221
  }
238
- return [3 /*break*/, 7];
222
+ case EntityValueDataTypes.VALUE:
223
+ default:
224
+ params.set(filter.idProperty, filter.value);
225
+ break;
239
226
  }
240
- _k.label = 3;
241
- case 3:
242
- if (!calcEntityValueIntegrationFilter) return [3 /*break*/, 5];
243
- return [4 /*yield*/, calcEntityValueIntegrationFilter(filter, dependencyStore)];
244
- case 4:
245
- value = _k.sent();
246
- if (value)
247
- params.set(filter.idProperty, value);
248
- _k.label = 5;
249
- case 5: return [3 /*break*/, 7];
250
- case 6:
251
- params.set(filter.idProperty, filter.value);
252
- return [3 /*break*/, 7];
253
- case 7:
254
- _b++;
255
- return [3 /*break*/, 1];
256
- case 8:
257
- url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
258
- return [4 /*yield*/, widgetInstance.get(url)];
259
- case 9:
260
- response = _k.sent();
261
- 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; })];
262
- }
263
- });
264
- }); };
265
- };
227
+ }
228
+ url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
229
+ return [4 /*yield*/, widgetInstance.get(url)];
230
+ case 1:
231
+ response = _j.sent();
232
+ 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; })];
233
+ }
234
+ });
235
+ }); };
@@ -26,11 +26,11 @@ export declare const GlobalSlice: import("@reduxjs/toolkit").Slice<GlobalState,
26
26
  formStyle: FormStyle;
27
27
  preview: boolean;
28
28
  idOrganization: string;
29
- internal: boolean;
30
29
  confirmation: {
31
30
  confirmationMessage: EurekaDraft;
32
31
  showLink: boolean;
33
32
  };
33
+ internal: boolean;
34
34
  dependencies: import("../Form/Form").DependencyStore;
35
35
  values: import("./SiteSlice").ValuesStore;
36
36
  idCurrentSection: string | null;
@@ -56,8 +56,7 @@ export declare enum MapperStyleTypes {
56
56
  }
57
57
  export declare enum EntityValueDataTypes {
58
58
  STEP = "STEP",
59
- VALUE = "VALUE",
60
- INTEGRATION = "INTEGRATION"
59
+ VALUE = "VALUE"
61
60
  }
62
61
  export declare enum ApiSelectorParamTypes {
63
62
  STEP = "STEP",
@@ -67,7 +67,6 @@ export var EntityValueDataTypes;
67
67
  (function (EntityValueDataTypes) {
68
68
  EntityValueDataTypes["STEP"] = "STEP";
69
69
  EntityValueDataTypes["VALUE"] = "VALUE";
70
- EntityValueDataTypes["INTEGRATION"] = "INTEGRATION";
71
70
  })(EntityValueDataTypes || (EntityValueDataTypes = {}));
72
71
  export var ApiSelectorParamTypes;
73
72
  (function (ApiSelectorParamTypes) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version":"2.0.86-test",
4
+ "version": "2.0.86",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",