@arquimedes.co/eureka-forms 2.0.36-test → 2.0.37-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@Types/Condition.d.ts +60 -0
- package/dist/@Types/Condition.js +1 -0
- package/dist/@Types/FormStep.d.ts +25 -10
- package/dist/@Types/GenericFormSteps.d.ts +2 -0
- package/dist/Form/FormFunctions.js +11 -11
- package/dist/Form/FormHooks.d.ts +0 -6
- package/dist/Form/FormHooks.js +0 -7
- package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +35 -0
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +36 -7
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +1 -3
- package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +35 -0
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +0 -1
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +0 -1
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +35 -4
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -1
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +33 -21
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +4 -0
- package/dist/FormSteps/Step.js +5 -2
- package/dist/FormSteps/StepFunctions.d.ts +3 -0
- package/dist/FormSteps/StepFunctions.js +157 -1
- package/dist/FormSteps/StepHooks.d.ts +12 -1
- package/dist/FormSteps/StepHooks.js +106 -3
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +1 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +0 -1
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +7 -3
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +0 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +0 -1
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +0 -1
- package/dist/constants/ConditionTypes.d.ts +22 -0
- package/dist/constants/ConditionTypes.js +25 -0
- package/dist/constants/FormStepTypes.d.ts +3 -0
- package/dist/constants/FormStepTypes.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import ConditionTypes, { ExpressionTypes, OperatorTypes } from '../constants/ConditionTypes';
|
|
2
|
+
import FormStepTypes from '../constants/FormStepTypes';
|
|
3
|
+
export type Condition = ExpressionCondition | FormStepCondition;
|
|
4
|
+
export interface ExpressionCondition<Type extends Condition = Condition> {
|
|
5
|
+
type: ConditionTypes.EXPRESSION;
|
|
6
|
+
conditions: (Type | ExpressionCondition<Type>)[];
|
|
7
|
+
expression: ExpressionTypes;
|
|
8
|
+
}
|
|
9
|
+
export type FormStepCondition = ExistanceFormStepCondition | CheckBoxFormStepCondition | ClassifierSelectorFormStepCondition | DatePickerFormStepCondition | EntityValuePickerFormStepCondition | RatingFormStepCondition | SelectorFormStepCondition | TextAreaFormStepCondition | TextInputFormStepCondition;
|
|
10
|
+
interface BaseFormStepCondition {
|
|
11
|
+
type: ConditionTypes.FORM_STEP;
|
|
12
|
+
operator: OperatorTypes;
|
|
13
|
+
stepType: FormStepTypes;
|
|
14
|
+
idStep: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ExistanceFormStepCondition extends BaseFormStepCondition {
|
|
17
|
+
operator: OperatorTypes.EXISTS | OperatorTypes.NOTEXISTS;
|
|
18
|
+
}
|
|
19
|
+
export interface CheckBoxFormStepCondition extends BaseFormStepCondition {
|
|
20
|
+
stepType: FormStepTypes.CHECKBOX;
|
|
21
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
22
|
+
value: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ClassifierSelectorFormStepCondition extends BaseFormStepCondition {
|
|
25
|
+
stepType: FormStepTypes.CLASSIFIER_SELECTOR;
|
|
26
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
27
|
+
idRoot: string;
|
|
28
|
+
idValue: string;
|
|
29
|
+
}
|
|
30
|
+
export interface DatePickerFormStepCondition extends BaseFormStepCondition {
|
|
31
|
+
stepType: FormStepTypes.DATEPICKER;
|
|
32
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL | OperatorTypes.LESS | OperatorTypes.MORE;
|
|
33
|
+
value: Date;
|
|
34
|
+
}
|
|
35
|
+
export interface EntityValuePickerFormStepCondition extends BaseFormStepCondition {
|
|
36
|
+
stepType: FormStepTypes.ENTITYVALUEPICKER;
|
|
37
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
38
|
+
values: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface RatingFormStepCondition extends BaseFormStepCondition {
|
|
41
|
+
stepType: FormStepTypes.RATING;
|
|
42
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL | OperatorTypes.LESS | OperatorTypes.MORE;
|
|
43
|
+
value: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SelectorFormStepCondition extends BaseFormStepCondition {
|
|
46
|
+
stepType: FormStepTypes.SELECTOR;
|
|
47
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL;
|
|
48
|
+
value: string;
|
|
49
|
+
}
|
|
50
|
+
export interface TextAreaFormStepCondition extends BaseFormStepCondition {
|
|
51
|
+
stepType: FormStepTypes.TEXTAREA;
|
|
52
|
+
operator: OperatorTypes.INCLUDES | OperatorTypes.NOTINCLUDES;
|
|
53
|
+
values: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface TextInputFormStepCondition extends BaseFormStepCondition {
|
|
56
|
+
stepType: FormStepTypes.TEXTINPUT;
|
|
57
|
+
operator: OperatorTypes.EQUAL | OperatorTypes.NOTEQUAL | OperatorTypes.INCLUDES | OperatorTypes.NOTINCLUDES;
|
|
58
|
+
value: string;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
|
|
2
|
+
import { Condition } from './Condition';
|
|
2
3
|
import * as GSteps from './GenericFormSteps';
|
|
3
4
|
export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
|
|
4
5
|
export interface Title extends GSteps.GBaseStep {
|
|
@@ -57,23 +58,19 @@ export interface FormSelector extends GSteps.GBaseStep {
|
|
|
57
58
|
maxSize?: number;
|
|
58
59
|
defaultValue?: string;
|
|
59
60
|
}
|
|
60
|
-
export type FormSelectorOption = DefaultFormSelectorOption | NestedStepOption
|
|
61
|
+
export type FormSelectorOption = DefaultFormSelectorOption | NestedStepOption;
|
|
61
62
|
interface DefaultFormSelectorOption {
|
|
62
63
|
label: string;
|
|
63
64
|
value: string;
|
|
64
65
|
type: OptionTypes.DEFAULT;
|
|
66
|
+
condition?: Condition;
|
|
65
67
|
}
|
|
66
68
|
export interface NestedStepOption {
|
|
67
69
|
label: string;
|
|
68
70
|
value: string;
|
|
69
71
|
type: OptionTypes.NESTED;
|
|
70
72
|
steps: string[];
|
|
71
|
-
|
|
72
|
-
interface AddSectionOption {
|
|
73
|
-
label: string;
|
|
74
|
-
value: string;
|
|
75
|
-
type: OptionTypes.ADD_SECTION;
|
|
76
|
-
idSection: string;
|
|
73
|
+
condition?: Condition;
|
|
77
74
|
}
|
|
78
75
|
export interface ClassifierSelector extends GSteps.GBaseStep {
|
|
79
76
|
type: Types.CLASSIFIER_SELECTOR;
|
|
@@ -86,11 +83,17 @@ export interface ClassifierSelector extends GSteps.GBaseStep {
|
|
|
86
83
|
size: 1 | 2 | 3 | 4;
|
|
87
84
|
maxSize?: number;
|
|
88
85
|
}
|
|
89
|
-
export type FormClassifierSelectorOption = NestedStepClassifierOption | HideValueOption;
|
|
86
|
+
export type FormClassifierSelectorOption = DefaultClassifierOption | NestedStepClassifierOption | HideValueOption;
|
|
87
|
+
interface DefaultClassifierOption {
|
|
88
|
+
type: ClassifierOptionTypes.DEFAULT;
|
|
89
|
+
idClassifier: string;
|
|
90
|
+
condition?: Condition;
|
|
91
|
+
}
|
|
90
92
|
interface NestedStepClassifierOption {
|
|
91
93
|
type: ClassifierOptionTypes.NESTED;
|
|
92
94
|
idClassifier: string;
|
|
93
95
|
steps: string[];
|
|
96
|
+
condition?: Condition;
|
|
94
97
|
}
|
|
95
98
|
interface HideValueOption {
|
|
96
99
|
type: ClassifierOptionTypes.HIDE;
|
|
@@ -105,11 +108,17 @@ export interface EntityValuePicker extends GSteps.GSmartSelect {
|
|
|
105
108
|
options: Record<string, FormEntityValuePickerOption>;
|
|
106
109
|
maxSize?: number;
|
|
107
110
|
}
|
|
108
|
-
export type FormEntityValuePickerOption = NestedEntityValuePickerOption | HideFormEntityValuePickerOption;
|
|
111
|
+
export type FormEntityValuePickerOption = DefaultEntityValuePickerOption | NestedEntityValuePickerOption | HideFormEntityValuePickerOption;
|
|
112
|
+
interface DefaultEntityValuePickerOption {
|
|
113
|
+
type: EntityValueOptionTypes.DEFAULT;
|
|
114
|
+
idEntityValue: string;
|
|
115
|
+
condition?: Condition;
|
|
116
|
+
}
|
|
109
117
|
interface NestedEntityValuePickerOption {
|
|
110
118
|
type: EntityValueOptionTypes.NESTED;
|
|
111
119
|
idEntityValue: string;
|
|
112
120
|
steps: string[];
|
|
121
|
+
condition?: Condition;
|
|
113
122
|
}
|
|
114
123
|
interface HideFormEntityValuePickerOption {
|
|
115
124
|
type: EntityValueOptionTypes.HIDE;
|
|
@@ -153,11 +162,17 @@ export interface ApiSelector extends GSteps.GSmartSelect {
|
|
|
153
162
|
maxSize?: number;
|
|
154
163
|
options: Record<string, ApiSelectorOption>;
|
|
155
164
|
}
|
|
156
|
-
export type ApiSelectorOption = NestedApiSelectorOption | HideApiSelectorOption;
|
|
165
|
+
export type ApiSelectorOption = DefaultApiSelectorOption | NestedApiSelectorOption | HideApiSelectorOption;
|
|
166
|
+
interface DefaultApiSelectorOption {
|
|
167
|
+
type: ApiSelectorOptionTypes.DEFAULT;
|
|
168
|
+
idOption: string;
|
|
169
|
+
condition?: Condition;
|
|
170
|
+
}
|
|
157
171
|
interface NestedApiSelectorOption {
|
|
158
172
|
type: ApiSelectorOptionTypes.NESTED;
|
|
159
173
|
idOption: string;
|
|
160
174
|
steps: string[];
|
|
175
|
+
condition?: Condition;
|
|
161
176
|
}
|
|
162
177
|
interface HideApiSelectorOption {
|
|
163
178
|
type: ApiSelectorOptionTypes.HIDE;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Condition } from './Condition';
|
|
1
2
|
export interface GBaseStep {
|
|
2
3
|
id: string;
|
|
3
4
|
idSection: string;
|
|
@@ -5,6 +6,7 @@ export interface GBaseStep {
|
|
|
5
6
|
editable?: boolean;
|
|
6
7
|
partial?: boolean;
|
|
7
8
|
dependencies?: string[];
|
|
9
|
+
condition?: Condition;
|
|
8
10
|
}
|
|
9
11
|
export interface GTitle extends GBaseStep {
|
|
10
12
|
title: string;
|
|
@@ -21,6 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
21
21
|
import { convertFromRaw, convertToRaw } from 'draft-js';
|
|
22
22
|
import StepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
|
|
23
23
|
import { calcRecursiveData } from '../App/AppFunctions';
|
|
24
|
+
import { calcStepDeps } from '../FormSteps/StepHooks';
|
|
24
25
|
/**
|
|
25
26
|
* Function that cals the value of a step to output on submit
|
|
26
27
|
*/
|
|
@@ -131,19 +132,18 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
131
132
|
if (addDependents === void 0) { addDependents = true; }
|
|
132
133
|
for (var _i = 0, _c = Object.values(steps); _i < _c.length; _i++) {
|
|
133
134
|
var step = _c[_i];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
135
|
+
var idDeps = calcStepDeps(step);
|
|
136
|
+
for (var _d = 0, idDeps_1 = idDeps; _d < idDeps_1.length; _d++) {
|
|
137
|
+
var idDep = idDeps_1[_d];
|
|
138
|
+
if (dependencies[idDep] === undefined &&
|
|
139
|
+
(addDependents || allSteps[idDep]))
|
|
140
|
+
dependencies[idDep] = calcStepDependency(idDep, allSteps, values, customSteps);
|
|
141
|
+
if (addDependents)
|
|
142
|
+
dependencies[idDep].dependents.push(step);
|
|
143
143
|
}
|
|
144
144
|
if (step.type === StepTypes.ENTITYVALUEPICKER) {
|
|
145
|
-
for (var
|
|
146
|
-
var dep =
|
|
145
|
+
for (var _e = 0, _f = __spreadArray(__spreadArray([], step.path, true), step.filters, true); _e < _f.length; _e++) {
|
|
146
|
+
var dep = _f[_e];
|
|
147
147
|
if (dep.type !== EntityValueDataTypes.STEP)
|
|
148
148
|
continue;
|
|
149
149
|
if ((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.includes(dep.idStep))
|
package/dist/Form/FormHooks.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { RootState } from '../Utils/store';
|
|
3
2
|
import { Form } from '../@Types';
|
|
4
|
-
export declare const selectCurrentValues: ((state: RootState) => Record<string, any>) & import("reselect").OutputSelectorFields<(args_0: string | null, args_1: Record<string, Record<string, any>>) => Record<string, any>, {
|
|
5
|
-
clearCache: () => void;
|
|
6
|
-
}> & {
|
|
7
|
-
clearCache: () => void;
|
|
8
|
-
};
|
|
9
3
|
export declare function useWidthStats(containerRef: React.RefObject<HTMLDivElement>, form: Form, postview: boolean, internal: boolean): void;
|
package/dist/Form/FormHooks.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { createSelector } from 'reselect';
|
|
2
1
|
import { useCallback, useLayoutEffect } from 'react';
|
|
3
2
|
import { updateWidthStats } from '../States/WidthStatsSlice';
|
|
4
3
|
import { useAppDispatch } from '../hooks';
|
|
5
|
-
export var selectCurrentValues = createSelector([
|
|
6
|
-
function (state) { return state.site.idCurrentSection; },
|
|
7
|
-
function (state) {
|
|
8
|
-
return state.site.values.sections;
|
|
9
|
-
},
|
|
10
|
-
], function (idCurrent, values) { var _a; return (_a = values[idCurrent !== null && idCurrent !== void 0 ? idCurrent : '']) !== null && _a !== void 0 ? _a : {}; });
|
|
11
4
|
export function useWidthStats(containerRef, form, postview, internal) {
|
|
12
5
|
var calcWidthStats = useCallback(function (currentWidth) {
|
|
13
6
|
var currentBreakPoint = form.size.blockNum;
|
|
@@ -56,6 +56,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
};
|
|
59
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
+
if (ar || !(i in from)) {
|
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
+
ar[i] = from[i];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
+
};
|
|
59
68
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
60
69
|
import React, { useContext } from 'react';
|
|
61
70
|
import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../constants/FormStepTypes';
|
|
@@ -66,6 +75,8 @@ import axiosInstance from '../../../Utils/AxiosAPI';
|
|
|
66
75
|
import InputIcon from '../../../Shared/InputIcon/InputIcon';
|
|
67
76
|
import FormContext from '../../../Contexts/FormContext';
|
|
68
77
|
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
78
|
+
import { recursivelyCalcConditionSteps } from '../../StepHooks';
|
|
79
|
+
import { evaluateCondition } from '../../StepFunctions';
|
|
69
80
|
function ApiSelectorComponent(_a) {
|
|
70
81
|
var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
|
|
71
82
|
var form = useContext(FormContext);
|
|
@@ -87,6 +98,30 @@ function ApiSelectorComponent(_a) {
|
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
return undefined;
|
|
101
|
+
}, filterOptions: function (options, dependencies) {
|
|
102
|
+
var filteredOptions = [];
|
|
103
|
+
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
104
|
+
var value = options_1[_i];
|
|
105
|
+
var option = step.options[calcOptionId(value)];
|
|
106
|
+
if ((option === null || option === void 0 ? void 0 : option.type) === ApiSelectorOptionTypes.HIDE)
|
|
107
|
+
continue;
|
|
108
|
+
if (!option ||
|
|
109
|
+
!option.condition ||
|
|
110
|
+
evaluateCondition(option.condition, dependencies))
|
|
111
|
+
filteredOptions.push(value);
|
|
112
|
+
}
|
|
113
|
+
return filteredOptions;
|
|
114
|
+
}, getOptionsConditionsIdSteps: function () {
|
|
115
|
+
var _a;
|
|
116
|
+
var dependencies = __spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true);
|
|
117
|
+
for (var _i = 0, _b = Object.values(step.options); _i < _b.length; _i++) {
|
|
118
|
+
var option = _b[_i];
|
|
119
|
+
if (option.type !== ApiSelectorOptionTypes.HIDE &&
|
|
120
|
+
option.condition) {
|
|
121
|
+
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return dependencies;
|
|
90
125
|
}, getValueString: function (value) { return calcOptionLabel(value); }, renderNestedSteps: function (value) {
|
|
91
126
|
if (!value)
|
|
92
127
|
return _jsx(_Fragment, {});
|
|
@@ -9,6 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
22
|
import React, { useContext, useMemo } from 'react';
|
|
14
23
|
import { ClassifierOptionTypes } from '../../../constants/FormStepTypes';
|
|
@@ -16,10 +25,10 @@ import StepComponent from '../../Step';
|
|
|
16
25
|
import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
17
26
|
import FormContext from '../../../Contexts/FormContext';
|
|
18
27
|
import { useAppSelector } from '../../../hooks';
|
|
19
|
-
import { useFormStep } from '../../StepHooks';
|
|
28
|
+
import { recursivelyCalcConditionSteps, selectDependencies, useFormStep, } from '../../StepHooks';
|
|
20
29
|
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
21
30
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
22
|
-
import { calcDefaultValue } from '../../StepFunctions';
|
|
31
|
+
import { calcDefaultValue, evaluateCondition } from '../../StepFunctions';
|
|
23
32
|
function ClassifierSelectorStep(_a) {
|
|
24
33
|
var _b, _c, _d, _e;
|
|
25
34
|
var step = _a.step, editable = _a.editable;
|
|
@@ -30,6 +39,21 @@ function ClassifierSelectorStep(_a) {
|
|
|
30
39
|
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
31
40
|
},
|
|
32
41
|
}), ref = _f.ref, value = _f.value, onChange = _f.onChange, error = _f.error, field = _f.field;
|
|
42
|
+
var idDependencies = useMemo(function () {
|
|
43
|
+
var _a;
|
|
44
|
+
var dependencies = __spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true);
|
|
45
|
+
for (var _i = 0, _b = Object.values(step.options); _i < _b.length; _i++) {
|
|
46
|
+
var option = _b[_i];
|
|
47
|
+
if (option.type !== ClassifierOptionTypes.HIDE &&
|
|
48
|
+
option.condition) {
|
|
49
|
+
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return dependencies;
|
|
53
|
+
}, []);
|
|
54
|
+
var dependencies = useAppSelector(function (state) {
|
|
55
|
+
return selectDependencies(state, idDependencies);
|
|
56
|
+
});
|
|
33
57
|
var _g = useAppSelector(function (state) { return state.global; }), formStyle = _g.formStyle, postview = _g.postview, preview = _g.preview;
|
|
34
58
|
var form = useContext(FormContext);
|
|
35
59
|
if (!step.idClassifier)
|
|
@@ -40,10 +64,15 @@ function ClassifierSelectorStep(_a) {
|
|
|
40
64
|
var options = useMemo(function () {
|
|
41
65
|
var _a;
|
|
42
66
|
return (_a = classifier.children) === null || _a === void 0 ? void 0 : _a.filter(function (idClassifier) {
|
|
43
|
-
var _a
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
((
|
|
67
|
+
var _a;
|
|
68
|
+
var option = step.options[idClassifier];
|
|
69
|
+
if ((option === null || option === void 0 ? void 0 : option.type) === ClassifierOptionTypes.HIDE ||
|
|
70
|
+
!((_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier])) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return (!option ||
|
|
74
|
+
!(option === null || option === void 0 ? void 0 : option.condition) ||
|
|
75
|
+
evaluateCondition(option.condition, dependencies));
|
|
47
76
|
}).map(function (idClassifier) {
|
|
48
77
|
var _a, _b, _c;
|
|
49
78
|
var classifier = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier];
|
|
@@ -54,7 +83,7 @@ function ClassifierSelectorStep(_a) {
|
|
|
54
83
|
: classifier === null || classifier === void 0 ? void 0 : classifier.name,
|
|
55
84
|
};
|
|
56
85
|
});
|
|
57
|
-
}, []);
|
|
86
|
+
}, idDependencies.map(function (id) { return dependencies[id].value; }));
|
|
58
87
|
var mapNestedOption = function () {
|
|
59
88
|
if (value) {
|
|
60
89
|
var currentOption = step.options[value.value];
|
|
@@ -43,9 +43,7 @@ function Collapsible(_a) {
|
|
|
43
43
|
setOpen(true);
|
|
44
44
|
}
|
|
45
45
|
}, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return errors[dep]; })) !== null && _c !== void 0 ? _c : []);
|
|
46
|
-
return (_jsxs("div", __assign({ style: {
|
|
47
|
-
breakInside: 'avoid',
|
|
48
|
-
} }, { children: [_jsxs("div", __assign({ className: styles.container, style: {
|
|
46
|
+
return (_jsxs("div", __assign({ style: { maxWidth: '100%' } }, { children: [_jsxs("div", __assign({ className: styles.container, style: {
|
|
49
47
|
color: formStyle.textColor,
|
|
50
48
|
borderColor: formStyle.primaryColor,
|
|
51
49
|
} }, { children: [_jsx("div", __assign({ className: styles.collapsibleLabel, onClick: function () {
|
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
49
58
|
import React, { useContext } from 'react';
|
|
50
59
|
import FormStepTypes, { EntityValueDataTypes, EntityValueOptionTypes, } from '../../../constants/FormStepTypes';
|
|
@@ -54,6 +63,8 @@ import widgetInstance from '../../../Utils/AxiosWidget';
|
|
|
54
63
|
import InputIcon from '../../../Shared/InputIcon/InputIcon';
|
|
55
64
|
import FormContext from '../../../Contexts/FormContext';
|
|
56
65
|
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
66
|
+
import { evaluateCondition } from '../../StepFunctions';
|
|
67
|
+
import { recursivelyCalcConditionSteps } from '../../StepHooks';
|
|
57
68
|
function EntityValuePickerStep(_a) {
|
|
58
69
|
var step = _a.step, editable = _a.editable;
|
|
59
70
|
var form = useContext(FormContext);
|
|
@@ -67,6 +78,30 @@ function EntityValuePickerStep(_a) {
|
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
return undefined;
|
|
81
|
+
}, filterOptions: function (options, dependencies) {
|
|
82
|
+
var filteredOptions = [];
|
|
83
|
+
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
84
|
+
var value = options_1[_i];
|
|
85
|
+
var option = step.options[value._id];
|
|
86
|
+
if ((option === null || option === void 0 ? void 0 : option.type) === EntityValueOptionTypes.HIDE)
|
|
87
|
+
continue;
|
|
88
|
+
if (!option ||
|
|
89
|
+
!option.condition ||
|
|
90
|
+
evaluateCondition(option.condition, dependencies))
|
|
91
|
+
filteredOptions.push(value);
|
|
92
|
+
}
|
|
93
|
+
return filteredOptions;
|
|
94
|
+
}, getOptionsConditionsIdSteps: function () {
|
|
95
|
+
var _a;
|
|
96
|
+
var dependencies = __spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true);
|
|
97
|
+
for (var _i = 0, _b = Object.values(step.options); _i < _b.length; _i++) {
|
|
98
|
+
var option = _b[_i];
|
|
99
|
+
if (option.type !== EntityValueOptionTypes.HIDE &&
|
|
100
|
+
option.condition) {
|
|
101
|
+
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return dependencies;
|
|
70
105
|
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value._id; }, renderNestedSteps: function (value) {
|
|
71
106
|
if (!value)
|
|
72
107
|
return _jsx(_Fragment, {});
|
|
@@ -209,7 +209,6 @@ function FileUploadStep(_a) {
|
|
|
209
209
|
return '';
|
|
210
210
|
};
|
|
211
211
|
return (_jsxs("div", __assign({ className: styles.container + (error || !!fieldError ? ' EF-error' : ''), style: {
|
|
212
|
-
breakInside: 'avoid',
|
|
213
212
|
minHeight: editable === false || postview ? undefined : '100px',
|
|
214
213
|
}, "data-testid": step.id }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label })), step.description && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor } }, { children: step.description }))), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: function (e) {
|
|
215
214
|
var files = e.target.files;
|
|
@@ -50,7 +50,6 @@ function RatingStep(_a) {
|
|
|
50
50
|
};
|
|
51
51
|
return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: styles.container, style: {
|
|
52
52
|
paddingBottom: step.description || step.required ? 0 : 15,
|
|
53
|
-
breakInside: 'avoid',
|
|
54
53
|
} }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') })), _jsx("div", __assign({ className: styles.ratingContainer }, { children: _jsx(Rating, { name: step.id, type: step.ratingType, isMobile: widthStats.isMobile, focusColor: (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f', unSelectedColor: (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8', disabled: !editable || postview, value: value, onChange: onChange, inputRef: ref }) })), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
|
|
55
54
|
color: !!error && value === null
|
|
56
55
|
? (_d = formStyle.errorColor) !== null && _d !== void 0 ? _d : '#cc2936'
|
|
@@ -9,17 +9,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React, { useContext } from 'react';
|
|
22
|
+
import React, { useContext, useMemo } from 'react';
|
|
14
23
|
import { OptionTypes } from '../../../constants/FormStepTypes';
|
|
15
24
|
import StepComponent from '../../Step';
|
|
16
25
|
import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
17
26
|
import FormContext from '../../../Contexts/FormContext';
|
|
18
27
|
import { useAppSelector } from '../../../hooks';
|
|
19
|
-
import { useFormStep } from '../../StepHooks';
|
|
28
|
+
import { recursivelyCalcConditionSteps, selectDependencies, useFormStep, } from '../../StepHooks';
|
|
20
29
|
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
21
30
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
22
|
-
import { calcDefaultValue } from '../../StepFunctions';
|
|
31
|
+
import { calcDefaultValue, evaluateCondition } from '../../StepFunctions';
|
|
23
32
|
function SelectorStep(_a) {
|
|
24
33
|
var _b, _c, _d;
|
|
25
34
|
var step = _a.step, editable = _a.editable;
|
|
@@ -32,6 +41,20 @@ function SelectorStep(_a) {
|
|
|
32
41
|
}), ref = _e.ref, value = _e.value, onChange = _e.onChange, error = _e.error, field = _e.field;
|
|
33
42
|
var form = useContext(FormContext);
|
|
34
43
|
var _f = useAppSelector(function (state) { return state.global; }), postview = _f.postview, formStyle = _f.formStyle;
|
|
44
|
+
var idDependencies = useMemo(function () {
|
|
45
|
+
var _a;
|
|
46
|
+
var dependencies = __spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true);
|
|
47
|
+
for (var _i = 0, _b = Object.values(step.options); _i < _b.length; _i++) {
|
|
48
|
+
var option = _b[_i];
|
|
49
|
+
if (option.condition) {
|
|
50
|
+
dependencies.push.apply(dependencies, recursivelyCalcConditionSteps(option.condition));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return dependencies;
|
|
54
|
+
}, []);
|
|
55
|
+
var dependencies = useAppSelector(function (state) {
|
|
56
|
+
return selectDependencies(state, idDependencies);
|
|
57
|
+
});
|
|
35
58
|
var mapNestedOption = function () {
|
|
36
59
|
var currentOptionIndex = null;
|
|
37
60
|
var currentOption = null;
|
|
@@ -50,7 +73,15 @@ function SelectorStep(_a) {
|
|
|
50
73
|
}) }));
|
|
51
74
|
}
|
|
52
75
|
};
|
|
53
|
-
|
|
76
|
+
var filteredOptions = useMemo(function () {
|
|
77
|
+
return step.options.filter(function (option) {
|
|
78
|
+
if (!option.condition ||
|
|
79
|
+
evaluateCondition(option.condition, dependencies))
|
|
80
|
+
return true;
|
|
81
|
+
return false;
|
|
82
|
+
});
|
|
83
|
+
}, idDependencies.map(function (id) { return dependencies[id].value; }));
|
|
84
|
+
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { value: value, inputRef: ref, handleUpdate: onChange, disabled: false, loading: false, options: filteredOptions, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_b = formStyle.stepBackgroundColor) !== null && _b !== void 0 ? _b : 'white', label: step.label, required: step.required, height: '31px', searchable: step.searchable, icon: undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", getOptionSelected: function (option, value) {
|
|
54
85
|
return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
|
|
55
86
|
}, helperText: (_d = (_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : step.description, error: !!error })) })), value && mapNestedOption()] }));
|
|
56
87
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SmartSelectStepProps } from '../SmartSelectStep';
|
|
3
3
|
import { GSmartSelect } from '../../../@Types/GenericFormSteps';
|
|
4
|
-
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
4
|
+
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, filterOptions, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, getOptionsConditionsIdSteps, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
5
5
|
export default SmartSelectStep;
|