@arquimedes.co/eureka-forms 2.0.85 → 2.0.86-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.
@@ -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;
151
+ export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
152
152
  export interface StepEntityValuePickerFilter {
153
153
  idProperty: string;
154
154
  type: EntityValueDataTypes.STEP;
@@ -161,6 +161,10 @@ 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
+ }
164
168
  export interface ApiSelector extends GSteps.GSmartSelect {
165
169
  type: FormStepTypes.API_SELECTOR;
166
170
  icon: string | null;
package/dist/App/App.d.ts CHANGED
@@ -1,8 +1,10 @@
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';
4
5
  import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
5
6
  import { EditorState } from 'draft-js';
7
+ import { IntegrationEntityValuePickerFilter } from '../@Types/FormStep';
6
8
  export interface AppProps {
7
9
  /** If the app is currently a widget */
8
10
  isWidget?: boolean;
@@ -50,6 +52,8 @@ export interface AppProps {
50
52
  handleConfirmed?: () => void;
51
53
  /** Function called to scroll to the top */
52
54
  scrollToTop?: () => void;
55
+ /** Function to call to reload the form */
56
+ calcEntityValueIntegrationFilter?: (filter: IntegrationEntityValuePickerFilter, store: DependencyStore) => Promise<string | null>;
53
57
  }
54
58
  export declare const IdFormContext: React.Context<string>;
55
59
  declare function AppComponent({ formData, valuesData, ...props }: AppProps): JSX.Element;
package/dist/App/App.js CHANGED
@@ -75,6 +75,7 @@ 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,
78
79
  } }, { 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 }) })) })));
79
80
  }
80
81
  }
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
3
- export interface CustomContextData {
3
+ import { AppProps } from '../App/App';
4
+ export interface CustomContextData extends Pick<AppProps, 'calcEntityValueIntegrationFilter'> {
4
5
  sendLabel?: string;
5
6
  customStepProps: Record<string, unknown>;
6
7
  customSteps: Record<string, CustomStep>;
@@ -67,10 +67,12 @@ 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';
70
71
  function EntityValuePickerStep(_a) {
71
72
  var _b, _c;
72
73
  var step = _a.step, editable = _a.editable;
73
74
  var form = useContext(FormContext);
75
+ var calcEntityValueIntegrationFilter = useContext(CustomContext).calcEntityValueIntegrationFilter;
74
76
  var _d = useState(), dialogs = _d[0], setDialogs = _d[1];
75
77
  var dialogsIdStepDeps = useMemo(function () {
76
78
  var ids = [];
@@ -96,6 +98,9 @@ function EntityValuePickerStep(_a) {
96
98
  : undefined;
97
99
  });
98
100
  }, []);
101
+ var getEntityValueOptions = useMemo(function () {
102
+ return generateGetEntityValueOptionsFunction(calcEntityValueIntegrationFilter);
103
+ }, [calcEntityValueIntegrationFilter]);
99
104
  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) {
100
105
  return option._id === value._id;
101
106
  }, calcDepError: function (steps) {
@@ -171,65 +176,90 @@ function EntityValuePickerStep(_a) {
171
176
  } }) }))] }));
172
177
  }
173
178
  export default EntityValuePickerStep;
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];
191
- if (typeof currentValue === 'string')
192
- idEntityValue = currentValue;
193
- else
194
- idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
195
- break;
196
- }
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) {
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];
212
197
  if (typeof currentValue === 'string')
213
- params.set(filter.idProperty, currentValue);
198
+ idEntityValue = currentValue;
214
199
  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];
200
+ idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
201
+ break;
219
202
  }
220
- break;
203
+ case EntityValueDataTypes.VALUE:
204
+ default:
205
+ idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
206
+ break;
221
207
  }
222
- case EntityValueDataTypes.VALUE:
223
- default:
224
- params.set(filter.idProperty, filter.value);
225
- break;
208
+ urlPath +=
209
+ '/' +
210
+ path.idEntity +
211
+ (idEntityValue ? '/' + idEntityValue : '');
226
212
  }
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
- }); };
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) {
230
+ if (typeof currentValue === 'string')
231
+ params.set(filter.idProperty, currentValue);
232
+ else
233
+ params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
234
+ }
235
+ else if (filter.required) {
236
+ return [2 /*return*/, null];
237
+ }
238
+ return [3 /*break*/, 7];
239
+ }
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
+ };
@@ -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;
29
30
  confirmation: {
30
31
  confirmationMessage: EurekaDraft;
31
32
  showLink: boolean;
32
33
  };
33
- internal: boolean;
34
34
  dependencies: import("../Form/Form").DependencyStore;
35
35
  values: import("./SiteSlice").ValuesStore;
36
36
  idCurrentSection: string | null;
@@ -56,7 +56,8 @@ export declare enum MapperStyleTypes {
56
56
  }
57
57
  export declare enum EntityValueDataTypes {
58
58
  STEP = "STEP",
59
- VALUE = "VALUE"
59
+ VALUE = "VALUE",
60
+ INTEGRATION = "INTEGRATION"
60
61
  }
61
62
  export declare enum ApiSelectorParamTypes {
62
63
  STEP = "STEP",
@@ -67,6 +67,7 @@ export var EntityValueDataTypes;
67
67
  (function (EntityValueDataTypes) {
68
68
  EntityValueDataTypes["STEP"] = "STEP";
69
69
  EntityValueDataTypes["VALUE"] = "VALUE";
70
+ EntityValueDataTypes["INTEGRATION"] = "INTEGRATION";
70
71
  })(EntityValueDataTypes || (EntityValueDataTypes = {}));
71
72
  export var ApiSelectorParamTypes;
72
73
  (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.85",
4
+ "version":"2.0.86-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",