@arquimedes.co/eureka-forms 2.0.62-test → 2.0.65-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/App/App.d.ts CHANGED
@@ -36,7 +36,7 @@ export interface AppProps {
36
36
  /** Custom submit function, when passed it is called */
37
37
  submit?: (submit: () => Promise<Record<string, any> | void>) => Promise<void>;
38
38
  /** Custom submit buttons */
39
- customSubmitBtns?: (onSubmit: () => Promise<Record<string, any> | void>, loading: boolean) => JSX.Element;
39
+ customSubmitBtns?: null | ((onSubmit: () => Promise<Record<string, any> | void>, loading: boolean) => JSX.Element);
40
40
  /** Function to call on postview to fetch the download url of a file */
41
41
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
42
42
  /** Function to call after the confimation dialog has been closed */
@@ -3,7 +3,6 @@ import { FormStep, Mapper } from '../@Types/FormStep';
3
3
  import { SiteState, ValuesStore } from '../States/SiteSlice';
4
4
  import { CustomStep } from '../FormSteps/CustomStep';
5
5
  import { MapperElement } from '../@Types/MapperElement';
6
- import { Condition } from '../@Types/Condition';
7
6
  import { MapperValue } from '../FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep';
8
7
  export declare const calcValuesStore: (idOrganization: string, form: Readonly<Form>, originalValues?: Record<string, any>, postview?: boolean, customSteps?: Record<string, CustomStep>) => Promise<ValuesStore>;
9
8
  export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>, path?: string) => {
@@ -13,7 +12,5 @@ export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<str
13
12
  /** Record of all the new steps created */
14
13
  steps: Record<string, FormStep>;
15
14
  };
16
- export declare function calcRecursiveData<Type>(element: Readonly<MapperElement<Type>>, newSteps: Record<string, FormStep>, customSteps: Record<string, CustomStep>): void;
17
- export declare const calcRecursiveCondition: (condition: Condition, ids: Record<string, string>) => void;
18
15
  export declare const mapOriginalValue: (idOrganization: string, step: FormStep, value: any, values: ValuesStore, form?: Readonly<Form>, path?: string) => Promise<any>;
19
16
  export declare const calcInitialSections: (form: Form) => Pick<SiteState, 'previousSections' | 'idCurrentSection' | 'nextSections'>;
@@ -57,9 +57,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  import { nanoid } from 'nanoid';
58
58
  import FormStepTypes, { EntityValueOptionTypes, FormTypes, } from '../constants/FormStepTypes';
59
59
  import { getRawText, stringToDraft } from '../Utils/DraftFunctions';
60
- import { calcSubSteps } from '../FormSteps/StepFunctions';
61
60
  import ConditionTypes from '../constants/ConditionTypes';
62
61
  import widgetInstance from '../Utils/AxiosWidget';
62
+ import { calcRecursiveData } from '../Utils/FormStepFunctions';
63
63
  export var calcValuesStore = function (idOrganization, form, originalValues, postview, customSteps) {
64
64
  if (originalValues === void 0) { originalValues = {}; }
65
65
  if (postview === void 0) { postview = false; }
@@ -162,50 +162,6 @@ export var addMapperStep = function (step, customSteps, path) {
162
162
  }
163
163
  return { element: element, mappers: mappers, steps: steps };
164
164
  };
165
- export function calcRecursiveData(element, newSteps, customSteps) {
166
- if (!newSteps)
167
- return;
168
- for (var _i = 0, _a = Object.entries(newSteps); _i < _a.length; _i++) {
169
- var _b = _a[_i], idStep = _b[0], step = _b[1];
170
- step.id = idStep;
171
- if (step.dependencies) {
172
- for (var i = 0; i < step.dependencies.length; i++) {
173
- var idDep = step.dependencies[i];
174
- var newId = element.ids[idDep];
175
- if (newId) {
176
- step.dependencies[i] = newId;
177
- }
178
- }
179
- }
180
- var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
181
- if (custom === null || custom === void 0 ? void 0 : custom.calcRecursiveData) {
182
- custom.calcRecursiveData(step, element.ids);
183
- }
184
- if (step.condition) {
185
- calcRecursiveCondition(step.condition, element.ids);
186
- }
187
- calcSubSteps(step.id, newSteps, function (idStep) { var _a; return (_a = element.ids[idStep]) !== null && _a !== void 0 ? _a : idStep; });
188
- }
189
- }
190
- export var calcRecursiveCondition = function (condition, ids) {
191
- switch (condition.type) {
192
- case ConditionTypes.EXPRESSION:
193
- for (var _i = 0, _a = condition.conditions; _i < _a.length; _i++) {
194
- var subCondition = _a[_i];
195
- calcRecursiveCondition(subCondition, ids);
196
- }
197
- break;
198
- case ConditionTypes.FORM_STEP: {
199
- var newId = ids[condition.idStep];
200
- if (newId) {
201
- condition.idStep = newId;
202
- }
203
- break;
204
- }
205
- default:
206
- break;
207
- }
208
- };
209
165
  export var mapOriginalValue = function (idOrganization, step, value, values, form, path) {
210
166
  if (path === void 0) { path = ''; }
211
167
  return __awaiter(void 0, void 0, void 0, function () {
@@ -20,8 +20,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  };
21
21
  import { convertFromRaw, convertToRaw } from 'draft-js';
22
22
  import FormStepTypes, { EntityValueDataTypes, } from '../constants/FormStepTypes';
23
- import { calcRecursiveData } from '../App/AppFunctions';
24
23
  import { calcStepDeps } from '../FormSteps/StepHooks';
24
+ import { calcRecursiveData } from '../Utils/FormStepFunctions';
25
25
  /**
26
26
  * Function that cals the value of a step to output on submit
27
27
  */
@@ -120,6 +120,6 @@ function ColumnForm(_a) {
120
120
  }
121
121
  });
122
122
  }); }, []);
123
- return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [!customSubmitBtns && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsx(CustomBtn, { onClick: submit, width: "calc(100% - 70px)", label: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
123
+ return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [customSubmitBtns === undefined && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsx(CustomBtn, { onClick: submit, width: "calc(100% - 70px)", label: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
124
124
  }
125
125
  export default ColumnForm;
@@ -106,7 +106,7 @@ var getElementOptions = function (idOrganization, step, dependencyStore) { retur
106
106
  case 1:
107
107
  response = (_d.sent()).data;
108
108
  father_1 = (_c = dependencyStore[step.dependencies[1]]) === null || _c === void 0 ? void 0 : _c.value;
109
- if (father_1 !== undefined && father_1.id === undefined) {
109
+ if (father_1 && father_1.id === undefined) {
110
110
  return [2 /*return*/, null];
111
111
  }
112
112
  return [2 /*return*/, response.filter(function (locativa) {
@@ -90,7 +90,7 @@ function MapperComponent(_a) {
90
90
  margin: step.description
91
91
  ? '10px 0px'
92
92
  : '0px 0px 5px 0px',
93
- } }, { children: step.description }))), mapElements(), _jsx("input", { id: step.id, ref: inputRef, className: 'hidden-input', readOnly: true, value: inputValue }), step.creatable !== false &&
93
+ } }, { children: step.description }))), mapElements(), _jsx("input", { id: step.id + '-input', ref: inputRef, className: 'hidden-input', readOnly: true, value: inputValue }), step.creatable !== false &&
94
94
  (!step.max ||
95
95
  elements.filter(function (elem) { return !elem.deleted; }).length < step.max) && (_jsxs("div", __assign({ className: styles.btnContainer }, { children: [!customAdd && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel +
96
96
  (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
@@ -21,7 +21,15 @@ function TimePickerStep(_a) {
21
21
  var _d = useFormStep(step, {
22
22
  defaultValue: defaultValue,
23
23
  rules: {
24
- required: step ? 'Este campo es obligatorio' : undefined,
24
+ validate: function (value) {
25
+ if (step.required) {
26
+ if (!value ||
27
+ !(value.hours || value.minutes || value.days)) {
28
+ return 'Este campo es obligatorio';
29
+ }
30
+ }
31
+ return true;
32
+ },
25
33
  },
26
34
  }), ref = _d.ref, value = _d.value, onChange = _d.onChange, error = _d.error, field = _d.field;
27
35
  return (_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedTimePicker, __assign({}, field, { value: value, onChange: onChange, inputRef: ref, cantEdit: !editable || postview, errorColor: formStyle.errorColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, helperTextColor: formStyle.descriptionTextColor, backgroundColor: formStyle.stepBackgroundColor, fontWeight: 400, label: step.label, helperText: (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : step.description, error: !!error, required: step.required, pickDays: step.pickDays, pickHours: step.pickHours, pickMinutes: step.pickMinutes, working: step.working })) })));
@@ -0,0 +1,15 @@
1
+ import { AYFFormStep } from '../@Types/AYFFormStep';
2
+ import { CBRFormStep } from '../@Types/CBRFormStep';
3
+ import { Condition } from '../@Types/Condition';
4
+ import { FormStep } from '../@Types/FormStep';
5
+ import { MapperElement } from '../@Types/MapperElement';
6
+ import { CustomStep } from '../FormSteps/CustomStep';
7
+ export declare function calcRecursiveData<Type>(element: Readonly<MapperElement<Type>>, newSteps: Record<string, FormStep>, customSteps: Record<string, CustomStep>): void;
8
+ export declare const calcRecursiveCondition: (condition: Condition, ids: Record<string, string>) => void;
9
+ /**
10
+ * Utility function to calc the substeps of a step
11
+ * @param step step to calc the substeps
12
+ * @param idModifier optional modifier for the ids of the substeps and all other properties
13
+ * @returns list of the ids of the substeps of the step, if modifier returns modified steps
14
+ */
15
+ export declare const calcSubSteps: (idStep: string, allSteps: Record<string, FormStep | CBRFormStep | AYFFormStep>, idModifier?: ((idSubStep: string) => string) | undefined) => string[];
@@ -0,0 +1,166 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import AYFFormStepTypes from '../constants/AYFFormStepTypes';
11
+ import CBRFormStepTypes from '../constants/CBRFormStepTypes';
12
+ import ConditionTypes from '../constants/ConditionTypes';
13
+ import FormStepTypes, { ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
14
+ export function calcRecursiveData(element, newSteps, customSteps) {
15
+ if (!newSteps)
16
+ return;
17
+ for (var _i = 0, _a = Object.entries(newSteps); _i < _a.length; _i++) {
18
+ var _b = _a[_i], idStep = _b[0], step = _b[1];
19
+ step.id = idStep;
20
+ if (step.dependencies) {
21
+ for (var i = 0; i < step.dependencies.length; i++) {
22
+ var idDep = step.dependencies[i];
23
+ var newId = element.ids[idDep];
24
+ if (newId) {
25
+ step.dependencies[i] = newId;
26
+ }
27
+ }
28
+ }
29
+ var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
30
+ if (custom === null || custom === void 0 ? void 0 : custom.calcRecursiveData) {
31
+ custom.calcRecursiveData(step, element.ids);
32
+ }
33
+ if (step.condition) {
34
+ calcRecursiveCondition(step.condition, element.ids);
35
+ }
36
+ // calcSubSteps(
37
+ // step.id,
38
+ // newSteps,
39
+ // (idStep: string): string => element.ids[idStep] ?? idStep
40
+ // );
41
+ }
42
+ }
43
+ export var calcRecursiveCondition = function (condition, ids) {
44
+ switch (condition.type) {
45
+ case ConditionTypes.EXPRESSION:
46
+ for (var _i = 0, _a = condition.conditions; _i < _a.length; _i++) {
47
+ var subCondition = _a[_i];
48
+ calcRecursiveCondition(subCondition, ids);
49
+ }
50
+ break;
51
+ case ConditionTypes.FORM_STEP: {
52
+ var newId = ids[condition.idStep];
53
+ if (newId) {
54
+ condition.idStep = newId;
55
+ }
56
+ break;
57
+ }
58
+ default:
59
+ break;
60
+ }
61
+ };
62
+ /**
63
+ * Utility function to calc the substeps of a step
64
+ * @param step step to calc the substeps
65
+ * @param idModifier optional modifier for the ids of the substeps and all other properties
66
+ * @returns list of the ids of the substeps of the step, if modifier returns modified steps
67
+ */
68
+ export var calcSubSteps = function (idStep, allSteps, idModifier) {
69
+ var _a;
70
+ var step = allSteps[idStep];
71
+ var subSteps = [];
72
+ if (!step)
73
+ return [];
74
+ var handleSteps = function (steps) {
75
+ for (var i = 0; i < steps.length; i++) {
76
+ var idSubStep = steps[i];
77
+ if (idModifier)
78
+ steps[i] = idModifier(steps[i]);
79
+ subSteps.push.apply(subSteps, __spreadArray([idSubStep], calcSubSteps(idSubStep, allSteps, idModifier), false));
80
+ }
81
+ };
82
+ switch (step.type) {
83
+ case FormStepTypes.SELECTOR: {
84
+ for (var _i = 0, _b = step.options; _i < _b.length; _i++) {
85
+ var option = _b[_i];
86
+ if (option.type === OptionTypes.NESTED) {
87
+ handleSteps(option.steps);
88
+ }
89
+ }
90
+ break;
91
+ }
92
+ case FormStepTypes.CLASSIFIER_SELECTOR:
93
+ for (var _c = 0, _d = Object.keys(step.options); _c < _d.length; _c++) {
94
+ var idOption = _d[_c];
95
+ var option = step.options[idOption];
96
+ if (option.type === ClassifierOptionTypes.NESTED) {
97
+ handleSteps(option.steps);
98
+ }
99
+ }
100
+ break;
101
+ case FormStepTypes.RATING:
102
+ if (step.nestedSteps) {
103
+ for (var _e = 0, _f = step.nestedSteps; _e < _f.length; _e++) {
104
+ var steps = _f[_e];
105
+ handleSteps(steps);
106
+ }
107
+ }
108
+ break;
109
+ case FormStepTypes.COLLAPSIBLE: {
110
+ handleSteps(step.steps);
111
+ break;
112
+ }
113
+ case FormStepTypes.CHECKBOX: {
114
+ if (step.steps)
115
+ handleSteps(step.steps);
116
+ if (step.uncheckedSteps)
117
+ handleSteps(step.uncheckedSteps);
118
+ break;
119
+ }
120
+ case FormStepTypes.ENTITYVALUEPICKER:
121
+ if (idModifier) {
122
+ for (var _g = 0, _h = step.path; _g < _h.length; _g++) {
123
+ var path = _h[_g];
124
+ if (path.type === EntityValueDataTypes.STEP) {
125
+ path.idStep = idModifier(path.idStep);
126
+ }
127
+ }
128
+ for (var _j = 0, _k = step.filters; _j < _k.length; _j++) {
129
+ var filter = _k[_j];
130
+ if (filter.type === EntityValueDataTypes.STEP) {
131
+ filter.idStep = idModifier(filter.idStep);
132
+ }
133
+ }
134
+ }
135
+ for (var _l = 0, _m = Object.keys((_a = step.options) !== null && _a !== void 0 ? _a : {}); _l < _m.length; _l++) {
136
+ var idOption = _m[_l];
137
+ var option = step.options[idOption];
138
+ if (option.type === EntityValueOptionTypes.NESTED) {
139
+ handleSteps(option.steps);
140
+ }
141
+ }
142
+ break;
143
+ case CBRFormStepTypes.CBR_LOCATIVAS:
144
+ {
145
+ var elementStep = step;
146
+ if (elementStep.subStep) {
147
+ if (idModifier)
148
+ elementStep.subStep = idModifier(elementStep.subStep);
149
+ subSteps.push(elementStep.subStep);
150
+ }
151
+ }
152
+ break;
153
+ case AYFFormStepTypes.AYF_ICA_CITY: {
154
+ var cityStep = step;
155
+ if (cityStep.idNitStep) {
156
+ if (idModifier)
157
+ cityStep.idNitStep = idModifier(cityStep.idNitStep);
158
+ subSteps.push(cityStep.idNitStep);
159
+ }
160
+ break;
161
+ }
162
+ default:
163
+ break;
164
+ }
165
+ return subSteps;
166
+ };
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.62-test",
4
+ "version":"2.0.65-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",
@@ -81,7 +81,7 @@
81
81
  "@typescript-eslint/eslint-plugin": "^6.13.1",
82
82
  "@typescript-eslint/parser": "^6.13.1",
83
83
  "chromatic": "^10.0.0",
84
- "cypress": "^13.7.1",
84
+ "cypress": "^13.8.1",
85
85
  "dotenv-webpack": "^8.0.1",
86
86
  "eslint": "^8.55.0",
87
87
  "eslint-config-prettier": "^9.1.0",