@arquimedes.co/eureka-forms 2.0.86-test → 2.0.90-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 (31) hide show
  1. package/dist/@Types/Draft/DraftEntityData.d.ts +5 -1
  2. package/dist/@Types/FormStep.d.ts +4 -11
  3. package/dist/@Types/GenericFormSteps.d.ts +2 -0
  4. package/dist/App/App.d.ts +0 -4
  5. package/dist/App/App.js +0 -1
  6. package/dist/Contexts/CustomContext.d.ts +1 -2
  7. package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +2 -1
  8. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +63 -54
  9. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +1 -0
  10. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +4 -6
  11. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +57 -87
  12. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +4 -4
  13. package/dist/Icons/@IconTypes.d.ts +7 -0
  14. package/dist/Icons/@IconTypes.js +1 -0
  15. package/dist/Icons/CalendarIcon.d.ts +4 -0
  16. package/dist/Icons/CalendarIcon.js +17 -0
  17. package/dist/Icons/LocationIcon.d.ts +4 -0
  18. package/dist/Icons/LocationIcon.js +17 -0
  19. package/dist/Icons/PersonIcon.d.ts +4 -0
  20. package/dist/Icons/PersonIcon.js +17 -0
  21. package/dist/Shared/InputIcon/InputIcon.js +24 -2
  22. package/dist/States/GlobalSlice.d.ts +1 -1
  23. package/dist/Utils/DraftFunctions.d.ts +34 -2
  24. package/dist/Utils/DraftFunctions.js +198 -12
  25. package/dist/constants/Draft/DraftEntityDataTypes.d.ts +2 -1
  26. package/dist/constants/Draft/DraftEntityDataTypes.js +1 -0
  27. package/dist/constants/FormStepTypes.d.ts +1 -2
  28. package/dist/constants/FormStepTypes.js +0 -1
  29. package/dist/constants/IconTypes.d.ts +4 -1
  30. package/dist/constants/IconTypes.js +3 -0
  31. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { DraftEntityDataTypes, DraftEntityDataMappingTypes } from '../../constan
3
3
  import { DraftEntityMap } from './Draft';
4
4
  import { Condition } from '../Condition';
5
5
  import { TicketPropertyTypes } from '../../constants/TicketPropertyTypes';
6
- export type DraftEntityData = CompanyDraftEntityData | ConditionMetDraftEntityData | DateDraftEntityData | TicketDraftEntityData | MappableDraftEntityData;
6
+ export type DraftEntityData = CompanyDraftEntityData | ConditionMetDraftEntityData | DateDraftEntityData | TicketDraftEntityData | MappableDraftEntityData | FormStepDraftEntityData;
7
7
  export interface BaseDraftEntityData {
8
8
  type: DraftEntityDataTypes | DraftEntityDataMappingTypes;
9
9
  prefix?: string;
@@ -47,4 +47,8 @@ export interface EntityValueMappingDraftEntityData extends BaseDraftEntityData {
47
47
  idEntity: string;
48
48
  idProperty: string;
49
49
  }
50
+ export interface FormStepDraftEntityData extends BaseDraftEntityData {
51
+ type: DraftEntityDataTypes.FORM_STEP;
52
+ idStep: string;
53
+ }
50
54
  export {};
@@ -1,4 +1,5 @@
1
1
  import FormStepTypes, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
2
+ import IconTypes from '../constants/IconTypes';
2
3
  import { Condition } from './Condition';
3
4
  import { EurekaDraft } from './Draft/Draft';
4
5
  import * as GSteps from './GenericFormSteps';
@@ -123,18 +124,15 @@ export interface EntityValuePickerDialog {
123
124
  }
124
125
  interface DefaultEntityValuePickerOption {
125
126
  type: EntityValueOptionTypes.DEFAULT;
126
- idEntityValue: string;
127
127
  condition?: Condition;
128
128
  }
129
129
  interface NestedEntityValuePickerOption {
130
130
  type: EntityValueOptionTypes.NESTED;
131
- idEntityValue: string;
132
131
  steps: string[];
133
132
  condition?: Condition;
134
133
  }
135
134
  interface HideFormEntityValuePickerOption {
136
135
  type: EntityValueOptionTypes.HIDE;
137
- idEntityValue: string;
138
136
  }
139
137
  export type EntityValuePickerPath = StepEntityValuePickerPath | ValueEntityValuePickerPath;
140
138
  export interface StepEntityValuePickerPath {
@@ -148,7 +146,7 @@ export interface ValueEntityValuePickerPath {
148
146
  type: EntityValueDataTypes.VALUE;
149
147
  idEntityValue: string | null;
150
148
  }
151
- export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
149
+ export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter;
152
150
  export interface StepEntityValuePickerFilter {
153
151
  idProperty: string;
154
152
  type: EntityValueDataTypes.STEP;
@@ -161,13 +159,9 @@ export interface ValueEntityValuePickerFilter {
161
159
  type: EntityValueDataTypes.VALUE;
162
160
  value: any;
163
161
  }
164
- export interface IntegrationEntityValuePickerFilter {
165
- idProperty: string;
166
- type: EntityValueDataTypes.INTEGRATION;
167
- }
168
162
  export interface ApiSelector extends GSteps.GSmartSelect {
169
163
  type: FormStepTypes.API_SELECTOR;
170
- icon: string | null;
164
+ icon?: IconTypes;
171
165
  url: string;
172
166
  pathParams: ApiSelectorParam[];
173
167
  queryParams: ApiSelectorParam[];
@@ -177,16 +171,15 @@ export interface ApiSelector extends GSteps.GSmartSelect {
177
171
  /** Only has maxSize if level === 0 */
178
172
  maxSize?: number;
179
173
  options: Record<string, ApiSelectorOption>;
174
+ defaultValue?: any;
180
175
  }
181
176
  export type ApiSelectorOption = DefaultApiSelectorOption | NestedApiSelectorOption | HideApiSelectorOption;
182
177
  interface DefaultApiSelectorOption {
183
178
  type: ApiSelectorOptionTypes.DEFAULT;
184
- idOption: string;
185
179
  condition?: Condition;
186
180
  }
187
181
  interface NestedApiSelectorOption {
188
182
  type: ApiSelectorOptionTypes.NESTED;
189
- idOption: string;
190
183
  steps: string[];
191
184
  condition?: Condition;
192
185
  }
@@ -40,6 +40,8 @@ export interface GTextInput extends GBaseStep {
40
40
  required: boolean;
41
41
  showIcon?: boolean;
42
42
  size: 1 | 2 | 3 | 4;
43
+ maxLength?: number;
44
+ defaultValue?: string;
43
45
  }
44
46
  export interface GDatePicker extends GBaseStep {
45
47
  label: string;
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>;
@@ -39,9 +39,10 @@ function ConfirmationDialog(_a) {
39
39
  var widthStats = useAppSelector(function (state) { return state.widthStats; });
40
40
  var editorState = useMemo(function () {
41
41
  return EditorState.createWithContent(convertFromRaw(mapDraftEntities({
42
+ form: form,
42
43
  dependencies: dependencies,
43
44
  ticket: { caseNumber: confirmation.case },
44
- }, JSON.parse(JSON.stringify(global.confirmation.confirmationMessage)))));
45
+ }, global.confirmation.confirmationMessage)));
45
46
  }, [global.confirmation, dependencies, form]);
46
47
  var hasText = editorState.getCurrentContent().hasText();
47
48
  var renderIcon = function () {
@@ -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
- }); };
@@ -1,6 +1,7 @@
1
1
  .container {
2
2
  display: flex;
3
3
  flex-direction: column;
4
+ max-width: 100%;
4
5
  }
5
6
  .checkboxLbl,
6
7
  .overflowLbl {
@@ -18,19 +18,17 @@ import styles from './MaterialEntityValueDialog.module.css';
18
18
  import RoundedButton from '../../../../Shared/RoundedButton/RoundedButton';
19
19
  import { useAppSelector } from '../../../../hooks';
20
20
  import { EditorState, convertFromRaw } from 'draft-js';
21
- import { useMemo } from 'react';
21
+ import { useContext, useMemo } from 'react';
22
22
  import { mapDraftEntities } from '../../../../Utils/DraftFunctions';
23
23
  import { Editor } from 'react-draft-wysiwyg';
24
+ import FormContext from '../../../../Contexts/FormContext';
24
25
  function MaterialEntityValueDialog(_a) {
25
26
  var type = _a.type, entity = _a.entity, message = _a.message, entityValue = _a.entityValue, handleClose = _a.handleClose;
26
27
  var formStyle = useAppSelector(function (state) { return state.global.formStyle; });
28
+ var form = useContext(FormContext);
27
29
  var dependencies = useAppSelector(function (state) { return state.site.dependencies; });
28
30
  var editorState = useMemo(function () {
29
- return EditorState.createWithContent(convertFromRaw(mapDraftEntities({
30
- dependencies: dependencies,
31
- entity: entity,
32
- entityValue: entityValue,
33
- }, JSON.parse(JSON.stringify(message)))));
31
+ return EditorState.createWithContent(convertFromRaw(mapDraftEntities({ form: form, dependencies: dependencies, entity: entity, entityValue: entityValue }, message)));
34
32
  }, [message, dependencies]);
35
33
  return (_jsx(Dialog, __assign({ PaperProps: {
36
34
  style: {
@@ -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
+ }); };
@@ -19,11 +19,11 @@ import { selectBreakPoint, useAppSelector } from '../../../hooks';
19
19
  import { useFormStep } from '../../StepHooks';
20
20
  function TextInputStep(_a) {
21
21
  var _b;
22
- var icon = _a.icon, step = _a.step, editable = _a.editable, maxLength = _a.maxLength, defaultValue = _a.defaultValue, _c = _a.validation, validation = _c === void 0 ? step.validation : _c;
22
+ var icon = _a.icon, step = _a.step, editable = _a.editable, maxLength = _a.maxLength, _c = _a.defaultValue, defaultValue = _c === void 0 ? step.defaultValue : _c, _d = _a.validation, validation = _d === void 0 ? step.validation : _d;
23
23
  var currentBreakPoint = useAppSelector(selectBreakPoint);
24
- var _d = useAppSelector(function (state) { return state.global; }), formStyle = _d.formStyle, postview = _d.postview;
24
+ var _e = useAppSelector(function (state) { return state.global; }), formStyle = _e.formStyle, postview = _e.postview;
25
25
  var form = useContext(FormContext);
26
- var _e = useFormStep(step, {
26
+ var _f = useFormStep(step, {
27
27
  defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : '',
28
28
  debounce: true,
29
29
  rules: {
@@ -38,7 +38,7 @@ function TextInputStep(_a) {
38
38
  }
39
39
  : undefined,
40
40
  },
41
- }), ref = _e.ref, value = _e.value, onChange = _e.onChange, error = _e.error, field = _e.field;
41
+ }), ref = _f.ref, value = _f.value, onChange = _f.onChange, error = _f.error, field = _f.field;
42
42
  return (_jsx("div", __assign({ className: styles.container, style: {
43
43
  width: currentBreakPoint <= step.size
44
44
  ? '100%'
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface IconProps {
3
+ fill?: string;
4
+ contrast?: string;
5
+ style?: React.CSSProperties;
6
+ className?: string;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from './@IconTypes';
3
+ declare function CalendarIcon({ className, style, fill }: IconProps): JSX.Element;
4
+ export default CalendarIcon;
@@ -0,0 +1,17 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ function CalendarIcon(_a) {
14
+ var className = _a.className, style = _a.style, fill = _a.fill;
15
+ return (_jsx("svg", __assign({ fill: fill, style: style, className: className, xmlns: "http://www.w3.org/2000/svg", height: "24", viewBox: "-1 -1 26 26", width: "24" }, { children: _jsx("path", { d: "M20 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H7V2c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 18H5c-.55 0-1-.45-1-1V8h16v12c0 .55-.45 1-1 1z" }) })));
16
+ }
17
+ export default CalendarIcon;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from './@IconTypes';
3
+ declare function LocationIcon({ className, style, fill }: IconProps): JSX.Element;
4
+ export default LocationIcon;
@@ -0,0 +1,17 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ function LocationIcon(_a) {
14
+ var className = _a.className, style = _a.style, fill = _a.fill;
15
+ return (_jsx("svg", __assign({ fill: fill, style: style, className: className, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M12 2C8.13 2 5 5.13 5 9c0 4.17 4.42 9.92 6.24 12.11.4.48 1.13.48 1.53 0C14.58 18.92 19 13.17 19 9c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z" }) })));
16
+ }
17
+ export default LocationIcon;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from './@IconTypes';
3
+ declare const PersonIcon: ({ className, style, fill }: IconProps) => JSX.Element;
4
+ export default PersonIcon;
@@ -0,0 +1,17 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ var PersonIcon = function (_a) {
14
+ var className = _a.className, style = _a.style, fill = _a.fill;
15
+ return (_jsxs("svg", __assign({ fill: fill, style: style, className: className, version: "1.1", viewBox: "-42 0 512 512", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "m210.351562 246.632812c33.882813 0 63.222657-12.152343 87.195313-36.128906 23.972656-23.972656 36.125-53.304687 36.125-87.191406 0-33.875-12.152344-63.210938-36.128906-87.191406-23.976563-23.96875-53.3125-36.121094-87.191407-36.121094-33.886718 0-63.21875 12.152344-87.191406 36.125s-36.128906 53.308594-36.128906 87.1875c0 33.886719 12.15625 63.222656 36.132812 87.195312 23.976563 23.96875 53.3125 36.125 87.1875 36.125zm0 0" }), _jsx("path", { d: "m426.128906 393.703125c-.691406-9.976563-2.089844-20.859375-4.148437-32.351563-2.078125-11.578124-4.753907-22.523437-7.957031-32.527343-3.308594-10.339844-7.808594-20.550781-13.371094-30.335938-5.773438-10.15625-12.554688-19-20.164063-26.277343-7.957031-7.613282-17.699219-13.734376-28.964843-18.199219-11.226563-4.441407-23.667969-6.691407-36.976563-6.691407-5.226563 0-10.28125 2.144532-20.042969 8.5-6.007812 3.917969-13.035156 8.449219-20.878906 13.460938-6.707031 4.273438-15.792969 8.277344-27.015625 11.902344-10.949219 3.542968-22.066406 5.339844-33.039063 5.339844-10.972656 0-22.085937-1.796876-33.046874-5.339844-11.210938-3.621094-20.296876-7.625-26.996094-11.898438-7.769532-4.964844-14.800782-9.496094-20.898438-13.46875-9.75-6.355468-14.808594-8.5-20.035156-8.5-13.3125 0-25.75 2.253906-36.972656 6.699219-11.257813 4.457031-21.003906 10.578125-28.96875 18.199219-7.605469 7.28125-14.390625 16.121094-20.15625 26.273437-5.558594 9.785157-10.058594 19.992188-13.371094 30.339844-3.199219 10.003906-5.875 20.945313-7.953125 32.523437-2.058594 11.476563-3.457031 22.363282-4.148437 32.363282-.679688 9.796875-1.023438 19.964844-1.023438 30.234375 0 26.726562 8.496094 48.363281 25.25 64.320312 16.546875 15.746094 38.441406 23.734375 65.066406 23.734375h246.53125c26.625 0 48.511719-7.984375 65.0625-23.734375 16.757813-15.945312 25.253906-37.585937 25.253906-64.324219-.003906-10.316406-.351562-20.492187-1.035156-30.242187zm0 0" })] })));
16
+ };
17
+ export default PersonIcon;
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
+ import CalendarIcon from '../../Icons/CalendarIcon';
24
25
  import LeakIcon from '../../Icons/Construction/LeakIcon';
25
26
  import ProjectIcon from '../../Icons/Construction/ProjectIcon';
26
27
  import PropertyIcon from '../../Icons/Construction/PropertyIcon';
@@ -29,6 +30,9 @@ import DocumentIcon from '../../Icons/DocumentIcon';
29
30
  import CheckListIcon from '../../Icons/Entities/CheckListIcon';
30
31
  import GenericEntityIcon from '../../Icons/Entities/GenericEntityIcon';
31
32
  import HandShakeIcon from '../../Icons/Entities/HandshakeIcon';
33
+ import SupplierIcon from '../../Icons/Entities/SupplierIcon';
34
+ import LocationIcon from '../../Icons/LocationIcon';
35
+ import PersonIcon from '../../Icons/PersonIcon';
32
36
  import IconTypes from '../../constants/IconTypes';
33
37
  function InputIcon(_a) {
34
38
  var icon = _a.icon, _b = _a.fill, fill = _b === void 0 ? '#757575' : _b, others = __rest(_a, ["icon", "fill"]);
@@ -51,6 +55,12 @@ function InputIcon(_a) {
51
55
  height: 23,
52
56
  width: 23,
53
57
  }, fill: fill }, others)));
58
+ case IconTypes.PERSON:
59
+ return (_jsx(PersonIcon, __assign({ style: {
60
+ display: 'flex',
61
+ height: 23,
62
+ width: 23,
63
+ }, fill: fill }, others)));
54
64
  case IconTypes.LEAK:
55
65
  return (_jsx(LeakIcon, __assign({ style: {
56
66
  display: 'flex',
@@ -72,12 +82,24 @@ function InputIcon(_a) {
72
82
  }, fill: fill }, others)));
73
83
  case IconTypes.CHECKLIST:
74
84
  return (_jsx(CheckListIcon, __assign({ style: {
85
+ display: 'flex',
86
+ height: 23,
87
+ width: 23,
88
+ }, fill: fill }, others)));
89
+ case IconTypes.SUPPLIER:
90
+ return (_jsx(SupplierIcon, __assign({ style: {
75
91
  display: 'flex',
76
92
  height: 24,
77
93
  width: 24,
78
94
  }, fill: fill }, others)));
79
- case IconTypes.SUPPLIER:
80
- return (_jsx(CheckListIcon, __assign({ style: {
95
+ case IconTypes.CALENDAR:
96
+ return (_jsx(CalendarIcon, __assign({ style: {
97
+ display: 'flex',
98
+ height: 23,
99
+ width: 23,
100
+ }, fill: fill }, others)));
101
+ case IconTypes.LOCATION:
102
+ return (_jsx(LocationIcon, __assign({ style: {
81
103
  display: 'flex',
82
104
  height: 23,
83
105
  width: 23,
@@ -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;
@@ -1,7 +1,11 @@
1
- import { RawDraftContentState } from 'draft-js';
1
+ import { RawDraftContentBlock, RawDraftContentState } from 'draft-js';
2
2
  import { EurekaDraft } from '../@Types/Draft/Draft';
3
+ import { DraftEntityData } from '../@Types/Draft/DraftEntityData';
3
4
  import { DependencyStore } from '../Form/Form';
5
+ import { FormStep } from '../@Types/FormStep';
6
+ import { Form } from '../@Types';
4
7
  interface FormCache {
8
+ form: Form;
5
9
  dependencies: DependencyStore;
6
10
  ticket?: {
7
11
  caseNumber: string;
@@ -20,5 +24,33 @@ interface FormCache {
20
24
  }
21
25
  export declare function stringToDraft(text: string): RawDraftContentState;
22
26
  export declare const getRawText: (draft?: RawDraftContentState, text?: string) => RawDraftContentState;
23
- export declare function mapDraftEntities(cache: FormCache, draft: EurekaDraft): RawDraftContentState;
27
+ export declare function mapDraftEntities(cache: FormCache, draft: EurekaDraft, mapToId?: boolean): RawDraftContentState;
28
+ type MappedBlock = {
29
+ text: string;
30
+ inlineStyleRanges?: RawDraftContentBlock['inlineStyleRanges'];
31
+ };
32
+ export declare const draftEntityMapper: (cache: FormCache, entityData: DraftEntityData, mapToId?: boolean) => MappedBlock;
33
+ type DraftBlock = EurekaDraft['blocks'][0];
34
+ /**
35
+ * The function will generate text for given draftjs editorContent.
36
+ */
37
+ export declare function draftToString(cache: FormCache, draft: EurekaDraft, mapToId?: boolean): string;
38
+ /**
39
+ * Function to check if a block is of type list.
40
+ */
41
+ export declare function isList(blockType: DraftBlock['type']): boolean;
42
+ /**
43
+ * Function will return text for Entity.
44
+ */
45
+ export declare function getEntityText(entityMap: EurekaDraft['entityMap'], entityKey: number, blockText: string): string;
46
+ /**
47
+ * Function to check if the block is an atomic entity block.
48
+ */
49
+ export declare function isAtomicBlock(block: DraftBlock): boolean;
50
+ /**
51
+ * The function returns true if the string passed to it has no content.
52
+ */
53
+ export declare function isEmptyString(str: string): boolean;
54
+ export declare function getDepthPadding(depth: number): string;
55
+ export declare function formStepToString(step: FormStep, value: any | undefined, mapToId?: boolean): string | null;
24
56
  export {};
@@ -6,6 +6,7 @@ import { getLocale } from '../Form/Form';
6
6
  import { TicketPropertyTypes } from '../constants/TicketPropertyTypes';
7
7
  import { format } from 'date-fns';
8
8
  import EntityPropertyTypes from '../constants/EntityPropertyTypes';
9
+ import FormStepTypes, { RatingTypes } from '../constants/FormStepTypes';
9
10
  export function stringToDraft(text) {
10
11
  var draftStructure = {
11
12
  blocks: [],
@@ -48,16 +49,18 @@ export var getRawText = function (draft, text) {
48
49
  };
49
50
  }
50
51
  };
51
- export function mapDraftEntities(cache, draft) {
52
+ export function mapDraftEntities(cache, draft, mapToId) {
53
+ if (mapToId === void 0) { mapToId = false; }
52
54
  var newBlocks = [];
53
- var blocks = draft.blocks, entityMap = draft.entityMap;
55
+ var _a = JSON.parse(JSON.stringify(draft)), blocks = _a.blocks, entityMap = _a.entityMap;
54
56
  for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
55
57
  var block = blocks_1[_i];
56
- newBlocks.push.apply(newBlocks, setBlockEntities(cache, block, entityMap));
58
+ newBlocks.push.apply(newBlocks, setBlockEntities(cache, block, entityMap, mapToId));
57
59
  }
58
60
  return { blocks: blocks, entityMap: entityMap };
59
61
  }
60
- function setBlockEntities(cache, block, entityMap) {
62
+ function setBlockEntities(cache, block, entityMap, mapToId) {
63
+ if (mapToId === void 0) { mapToId = false; }
61
64
  //Con esta funcion saca el texto remplazado de la entidad
62
65
  var entities = block.entityRanges.sort(function (s1, s2) { return s2.offset - s1.offset; });
63
66
  var newEntities = [];
@@ -67,7 +70,7 @@ function setBlockEntities(cache, block, entityMap) {
67
70
  var entityEnd = entity.offset + entity.length - 1;
68
71
  var entityData = entityMap[entity.key];
69
72
  if (entityData.type === DraftEntityTypes.EUREKA) {
70
- var mappedBlock = handleEntityMapper(cache, entityData.data);
73
+ var mappedBlock = draftEntityMapper(cache, entityData.data, mapToId);
71
74
  var entityText = mappedBlock.text;
72
75
  var entitySizeDelta = entityText.length - entity.length;
73
76
  for (var _a = 0, styles_1 = styles; _a < styles_1.length; _a++) {
@@ -159,14 +162,15 @@ function setBlockEntities(cache, block, entityMap) {
159
162
  block.entityRanges = newEntities;
160
163
  return [block];
161
164
  }
162
- var handleEntityMapper = function (cache, entityData) {
165
+ export var draftEntityMapper = function (cache, entityData, mapToId) {
163
166
  var _a;
167
+ if (mapToId === void 0) { mapToId = false; }
164
168
  if (entityData.condition &&
165
169
  entityData.type !== DraftEntityDataTypes.CONDITION_MET) {
166
170
  if (!evaluateCondition(entityData.condition, cache.dependencies))
167
171
  return { text: '' };
168
172
  }
169
- var value = entityMapper(cache, entityData);
173
+ var value = entityMapper(cache, entityData, mapToId);
170
174
  if (!(value === null || value === void 0 ? void 0 : value.text) && entityData.fallback) {
171
175
  value = { text: entityData.fallback };
172
176
  }
@@ -181,8 +185,9 @@ var handleEntityMapper = function (cache, entityData) {
181
185
  inlineStyleRanges: value === null || value === void 0 ? void 0 : value.inlineStyleRanges,
182
186
  };
183
187
  };
184
- var entityMapper = function (cache, entityData) {
185
- var _a, _b, _c, _d, _e, _f;
188
+ var entityMapper = function (cache, entityData, mapToId) {
189
+ var _a, _b, _c, _d, _e, _f, _g;
190
+ if (mapToId === void 0) { mapToId = false; }
186
191
  switch (entityData.type) {
187
192
  case DraftEntityDataTypes.CONDITION_MET: {
188
193
  if (evaluateCondition(entityData.condition, cache.dependencies)) {
@@ -223,14 +228,23 @@ var entityMapper = function (cache, entityData) {
223
228
  block.text += ' ';
224
229
  var offset = block.text.length;
225
230
  block.text += nested.text;
226
- for (var _i = 0, _g = nested.inlineStyleRanges; _i < _g.length; _i++) {
227
- var style = _g[_i];
231
+ for (var _i = 0, _h = nested.inlineStyleRanges; _i < _h.length; _i++) {
232
+ var style = _h[_i];
228
233
  style.offset += offset;
229
234
  (_e = block.inlineStyleRanges) === null || _e === void 0 ? void 0 : _e.push(style);
230
235
  }
231
236
  }
232
237
  return block;
233
238
  }
239
+ case DraftEntityDataTypes.FORM_STEP: {
240
+ var step = cache.form.steps[entityData.idStep];
241
+ if (!step)
242
+ return null;
243
+ var text = formStepToString(step, (_f = cache.dependencies[step.id]) === null || _f === void 0 ? void 0 : _f.value, mapToId);
244
+ if (text === null)
245
+ return null;
246
+ return { text: text, inlineStyleRanges: [] };
247
+ }
234
248
  case DraftEntityDataTypes.DATE: {
235
249
  var millis = entityData.days * 86400000 +
236
250
  entityData.hours * 3600000 +
@@ -238,7 +252,7 @@ var entityMapper = function (cache, entityData) {
238
252
  var subtract = false;
239
253
  var date = new Date(new Date().getTime() + (subtract ? -millis : millis));
240
254
  return {
241
- text: format(date, (_f = entityData.format) !== null && _f !== void 0 ? _f : 'Pp', {
255
+ text: format(date, (_g = entityData.format) !== null && _g !== void 0 ? _g : 'Pp', {
242
256
  locale: getLocale(),
243
257
  }),
244
258
  };
@@ -280,3 +294,175 @@ function calcEntityProperty(property, value) {
280
294
  }
281
295
  return null;
282
296
  }
297
+ /**
298
+ * The function will generate text for given draftjs editorContent.
299
+ */
300
+ export function draftToString(cache, draft, mapToId) {
301
+ if (mapToId === void 0) { mapToId = false; }
302
+ var text = [];
303
+ if (draft) {
304
+ var _a = JSON.parse(JSON.stringify(draft)), blocks_2 = _a.blocks, entityMap_1 = _a.entityMap;
305
+ if (blocks_2 && blocks_2.length > 0) {
306
+ blocks_2.forEach(function (block) {
307
+ var content = getBlockText(cache, block, entityMap_1, blocks_2.length === 1, mapToId);
308
+ if (isList(block.type)) {
309
+ content = getDepthPadding(block.depth) + content;
310
+ }
311
+ text.push(content);
312
+ });
313
+ }
314
+ }
315
+ var response = text.join('');
316
+ if (response === '\n') {
317
+ return '';
318
+ }
319
+ return response;
320
+ }
321
+ /**
322
+ * Function will return text for the block.
323
+ */
324
+ function getBlockText(cache, block, entityMap, skipNextLine, mapToId) {
325
+ if (skipNextLine === void 0) { skipNextLine = false; }
326
+ if (mapToId === void 0) { mapToId = false; }
327
+ var blockMarkdown = [];
328
+ blockMarkdown.push(getBlockContentText(cache, block, entityMap, mapToId));
329
+ if (!isAtomicBlock(block) && !skipNextLine)
330
+ blockMarkdown.push('\n');
331
+ return blockMarkdown.join('');
332
+ }
333
+ /**
334
+ * Function will return the text for block content.
335
+ */
336
+ function getBlockContentText(cache, block, entityMap, mapToId) {
337
+ if (mapToId === void 0) { mapToId = false; }
338
+ if (isAtomicBlock(block)) {
339
+ return getEntityText(entityMap, block.entityRanges[0].key, block.text);
340
+ }
341
+ setBlockEntities(cache, block, entityMap, mapToId);
342
+ return block.text.replace('\n', '\\s\\s\n');
343
+ }
344
+ /**
345
+ * Function to check if a block is of type list.
346
+ */
347
+ export function isList(blockType) {
348
+ return (blockType === 'unordered-list-item' || blockType === 'ordered-list-item');
349
+ }
350
+ /**
351
+ * Function will return text for Entity.
352
+ */
353
+ export function getEntityText(entityMap, entityKey, blockText) {
354
+ var entity = entityMap[entityKey];
355
+ if (entity && entity.type === 'EUREKA') {
356
+ return blockText;
357
+ }
358
+ return '';
359
+ }
360
+ /**
361
+ * Function to check if the block is an atomic entity block.
362
+ */
363
+ export function isAtomicBlock(block) {
364
+ if (block.entityRanges.length > 0 && isEmptyString(block.text)) {
365
+ return true;
366
+ }
367
+ return false;
368
+ }
369
+ /**
370
+ * The function returns true if the string passed to it has no content.
371
+ */
372
+ export function isEmptyString(str) {
373
+ if (str === undefined ||
374
+ str === null ||
375
+ str.length === 0 ||
376
+ str.trim().length === 0) {
377
+ return true;
378
+ }
379
+ return false;
380
+ }
381
+ export function getDepthPadding(depth) {
382
+ var padding = '';
383
+ for (var i = 0; i < depth * 4; i += 1) {
384
+ padding += ' ';
385
+ }
386
+ return padding;
387
+ }
388
+ export function formStepToString(step, value, mapToId) {
389
+ if (mapToId === void 0) { mapToId = false; }
390
+ if (value === undefined || value === null)
391
+ return null;
392
+ switch (step.type) {
393
+ case FormStepTypes.TIMEPICKER: {
394
+ var time = value;
395
+ var parts = [];
396
+ if (time.days) {
397
+ parts.push("".concat(time.days, " d\u00EDa").concat(time.days > 1 ? 's' : ''));
398
+ }
399
+ if (time.hours) {
400
+ parts.push("".concat(time.hours, " hora").concat(time.hours > 1 ? 's' : ''));
401
+ }
402
+ if (time.minutes) {
403
+ parts.push("".concat(time.minutes, " minuto").concat(time.minutes > 1 ? 's' : ''));
404
+ }
405
+ if (parts.length === 0)
406
+ return time.working
407
+ ? 'horario hábil más cercano'
408
+ : 'inmediatamente';
409
+ if (time.working) {
410
+ var isMultiple = parts.length > 1 || parts[0].includes('s');
411
+ return parts.join(', ') + (isMultiple ? ' hábiles' : 'hábil');
412
+ }
413
+ return parts.join(', ');
414
+ }
415
+ case FormStepTypes.TEXTAREA:
416
+ return value.value;
417
+ case FormStepTypes.TEXTINPUT:
418
+ case FormStepTypes.SELECTOR:
419
+ return value;
420
+ case FormStepTypes.DATEPICKER:
421
+ return new Date(value).toUTCString();
422
+ case FormStepTypes.CHECKBOX:
423
+ return value ? 'Sí' : 'No';
424
+ case FormStepTypes.ENTITYVALUEPICKER:
425
+ if (mapToId && value._id)
426
+ return value._id;
427
+ if (value.label)
428
+ return value.label;
429
+ return null;
430
+ case FormStepTypes.CLASSIFIER_SELECTOR:
431
+ return value;
432
+ case FormStepTypes.API_SELECTOR:
433
+ if (mapToId && value[step.idAttribute])
434
+ return value[step.idAttribute];
435
+ if (value[step.labelAttribute])
436
+ return value[step.labelAttribute];
437
+ return null;
438
+ case FormStepTypes.FILEUPLOAD: {
439
+ return value
440
+ .map(function (file) { var _a; return (_a = file.fileName) !== null && _a !== void 0 ? _a : 'Archivo'; })
441
+ .join(', ');
442
+ }
443
+ case FormStepTypes.RATING:
444
+ switch (step.ratingType) {
445
+ case RatingTypes.LIKE:
446
+ return value ? 'Si' : 'No';
447
+ case RatingTypes.SATISFACTION:
448
+ switch (value) {
449
+ case 1:
450
+ return 'Muy Insatisfecho';
451
+ case 2:
452
+ return 'Insatisfecho';
453
+ case 3:
454
+ return 'Satisfecho';
455
+ case 4:
456
+ return 'Muy Satisfecho';
457
+ default:
458
+ return null;
459
+ }
460
+ default:
461
+ break;
462
+ }
463
+ return value;
464
+ default:
465
+ break;
466
+ }
467
+ return null;
468
+ }
@@ -3,7 +3,8 @@ export declare enum DraftEntityDataTypes {
3
3
  NESTED = "NESTED",
4
4
  TICKET = "TICKET",
5
5
  COMPANY = "COMPANY",
6
- CONDITION_MET = "CONDITION_MET"
6
+ CONDITION_MET = "CONDITION_MET",
7
+ FORM_STEP = "FORM_STEP"
7
8
  }
8
9
  export declare enum DraftEntityDataMappingTypes {
9
10
  ENTITYVALUE_MAPPING = "ENTITYVALUE_MAPPING"
@@ -5,6 +5,7 @@ export var DraftEntityDataTypes;
5
5
  DraftEntityDataTypes["TICKET"] = "TICKET";
6
6
  DraftEntityDataTypes["COMPANY"] = "COMPANY";
7
7
  DraftEntityDataTypes["CONDITION_MET"] = "CONDITION_MET";
8
+ DraftEntityDataTypes["FORM_STEP"] = "FORM_STEP";
8
9
  })(DraftEntityDataTypes || (DraftEntityDataTypes = {}));
9
10
  export var DraftEntityDataMappingTypes;
10
11
  (function (DraftEntityDataMappingTypes) {
@@ -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) {
@@ -3,10 +3,13 @@ export declare enum IconTypes {
3
3
  PROPERTY = "PROPERTY",
4
4
  SPACE = "SPACE",
5
5
  LEAK = "LEAK",
6
+ PERSON = "PERSON",
6
7
  DOCUMENT = "DOCUMENT",
7
8
  HANDSHAKE = "HANDSHAKE",
8
9
  CHECKLIST = "CHECKLIST",
9
10
  SUPPLIER = "SUPPLIER",
10
- GENERIC = "GENERIC"
11
+ GENERIC = "GENERIC",
12
+ LOCATION = "LOCATION",
13
+ CALENDAR = "CALENDAR"
11
14
  }
12
15
  export default IconTypes;
@@ -4,10 +4,13 @@ export var IconTypes;
4
4
  IconTypes["PROPERTY"] = "PROPERTY";
5
5
  IconTypes["SPACE"] = "SPACE";
6
6
  IconTypes["LEAK"] = "LEAK";
7
+ IconTypes["PERSON"] = "PERSON";
7
8
  IconTypes["DOCUMENT"] = "DOCUMENT";
8
9
  IconTypes["HANDSHAKE"] = "HANDSHAKE";
9
10
  IconTypes["CHECKLIST"] = "CHECKLIST";
10
11
  IconTypes["SUPPLIER"] = "SUPPLIER";
11
12
  IconTypes["GENERIC"] = "GENERIC";
13
+ IconTypes["LOCATION"] = "LOCATION";
14
+ IconTypes["CALENDAR"] = "CALENDAR";
12
15
  })(IconTypes || (IconTypes = {}));
13
16
  export default IconTypes;
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.90-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",