@arquimedes.co/eureka-forms 1.9.50-test → 1.9.52-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/Form.d.ts +9 -13
- package/dist/@Types/FormStep.d.ts +6 -1
- package/dist/App.js +3 -3
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +5 -2
- package/dist/FormComponents/Form/Form.js +9 -11
- package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +4 -4
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +8 -7
- package/dist/FormComponents/Step/CollapsibleStep/CollapsibleStep.d.ts +9 -0
- package/dist/FormComponents/Step/CollapsibleStep/CollapsibleStep.js +37 -0
- package/dist/FormComponents/Step/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.d.ts +4 -0
- package/dist/FormComponents/Step/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +75 -0
- package/dist/FormComponents/Step/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.module.css +62 -0
- package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/Element/MapperElement.js +2 -2
- package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/MaterialMapperStep.js +10 -2
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +2 -2
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +2 -2
- package/dist/FormComponents/Step/Step.js +4 -0
- package/dist/constants/FormStepTypes.d.ts +1 -0
- package/dist/constants/FormStepTypes.js +1 -0
- package/package.json +1 -1
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { FormStyleTypes, FormTypes } from '../constants/FormStepTypes';
|
|
2
2
|
import { FormStep } from './FormStep';
|
|
3
3
|
export interface Form {
|
|
4
|
-
apiKey
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
name?: string;
|
|
5
6
|
sections: Record<string, Section>;
|
|
6
7
|
steps: Record<string, FormStep>;
|
|
7
|
-
firstSection: string;
|
|
8
|
-
name: string;
|
|
9
|
-
type: FormTypes;
|
|
10
|
-
description: string;
|
|
11
|
-
isInternal: boolean;
|
|
12
|
-
isPublic: boolean;
|
|
13
|
-
hasCaptcha: boolean;
|
|
14
|
-
url: string;
|
|
15
|
-
isStandAlone: boolean;
|
|
16
|
-
style: FormStyle;
|
|
17
|
-
classifiers: Record<string, ParentClassifier>;
|
|
18
|
-
terms: Term[];
|
|
19
8
|
size: FormSize;
|
|
9
|
+
firstSection: string;
|
|
10
|
+
type?: FormTypes;
|
|
11
|
+
hasCaptcha?: boolean;
|
|
12
|
+
isStandAlone?: boolean;
|
|
13
|
+
style?: FormStyle;
|
|
14
|
+
classifiers?: Record<string, ParentClassifier>;
|
|
15
|
+
terms?: Term[];
|
|
20
16
|
}
|
|
21
17
|
export interface FormSize {
|
|
22
18
|
blockNum: 1 | 2 | 3 | 4;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes } from '../constants/FormStepTypes';
|
|
2
2
|
import * as GSteps from './GenericFormSteps';
|
|
3
|
-
export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | EntityValuePicker | Mapper;
|
|
3
|
+
export type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | Mapper;
|
|
4
4
|
export interface Title extends GSteps.GBaseStep {
|
|
5
5
|
type: Types.TITLE;
|
|
6
6
|
title: string;
|
|
@@ -36,6 +36,11 @@ export interface TextInput extends GSteps.GTextInput {
|
|
|
36
36
|
export interface DatePicker extends GSteps.GDatePicker {
|
|
37
37
|
type: Types.DATEPICKER;
|
|
38
38
|
}
|
|
39
|
+
export interface Collapsible extends GSteps.GBaseStep {
|
|
40
|
+
type: Types.COLLAPSIBLE;
|
|
41
|
+
label: string;
|
|
42
|
+
steps: string[];
|
|
43
|
+
}
|
|
39
44
|
export interface FormSelector extends GSteps.GBaseStep {
|
|
40
45
|
type: Types.SELECTOR;
|
|
41
46
|
label: string;
|
package/dist/App.js
CHANGED
|
@@ -161,7 +161,7 @@ function App(_a) {
|
|
|
161
161
|
LogRocket.default.identify(organizationInfo.idOrganization + '/' + apiKey, {
|
|
162
162
|
name: organizationInfo.name +
|
|
163
163
|
'/' +
|
|
164
|
-
(form ? form === null || form === void 0 ? void 0 : form.name : '404'),
|
|
164
|
+
((form === null || form === void 0 ? void 0 : form.name) ? form === null || form === void 0 ? void 0 : form.name : '404'),
|
|
165
165
|
});
|
|
166
166
|
return [3 /*break*/, 4];
|
|
167
167
|
case 3:
|
|
@@ -406,7 +406,7 @@ var mapOriginalValues = function (originalValues, form) {
|
|
|
406
406
|
return newValues;
|
|
407
407
|
};
|
|
408
408
|
var mapOriginalValue = function (step, value, form) {
|
|
409
|
-
var _a, _b;
|
|
409
|
+
var _a, _b, _c;
|
|
410
410
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
411
411
|
case StepTypes.TEXTAREA: {
|
|
412
412
|
if (step.hasTextEditor) {
|
|
@@ -421,7 +421,7 @@ var mapOriginalValue = function (step, value, form) {
|
|
|
421
421
|
return value;
|
|
422
422
|
}
|
|
423
423
|
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
424
|
-
var classifier = form.classifiers[(
|
|
424
|
+
var classifier = (_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[(_c = step.idClassifier) !== null && _c !== void 0 ? _c : ''];
|
|
425
425
|
if (classifier) {
|
|
426
426
|
var option = classifier.children.find(function (child) { return child._id == value; });
|
|
427
427
|
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
@@ -159,12 +159,12 @@ function ColumnForm(_a) {
|
|
|
159
159
|
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
|
|
160
160
|
reload();
|
|
161
161
|
setShowConfirmation(undefined);
|
|
162
|
-
} })), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, sendLabel: sendLabel, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps, setDependencyStore: setDependencyStore, dependencyStore: dependencyStore, setFocus: setFocus }, others),
|
|
162
|
+
} })), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, sendLabel: sendLabel, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps, setDependencyStore: setDependencyStore, dependencyStore: dependencyStore, setFocus: setFocus }, others), idSection)); }), form.terms &&
|
|
163
163
|
(!internal || (internal && postview)) &&
|
|
164
164
|
(originalValues === null || originalValues === void 0 ? void 0 : originalValues['INTERNAL_CREATING_AGENT']) === undefined && (_jsx("div", __assign({ className: styles.termsContainer, style: {
|
|
165
165
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
166
166
|
form.size.blockNum,
|
|
167
|
-
} }, { children: form.terms.map(function (term
|
|
167
|
+
} }, { children: form.terms.map(function (term) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, term.id)); }) }))), !postview && others.editable && (_jsxs(React.Fragment, { children: [form.hasCaptcha && !internal && (_jsx(ReCAPTCHA, { ref: recaptchaRef, sitekey: "6LcL22kkAAAAAEotDeAFbRATob-u5vbibbCyWL2p", size: 'invisible', badge: 'bottomright' })), !customSubmit && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "form__submit", className: styles.submitBtn, onClick: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
168
168
|
var valid, captcha;
|
|
169
169
|
return __generator(this, function (_a) {
|
|
170
170
|
switch (_a.label) {
|
|
@@ -256,6 +256,9 @@ var calcValue = function (idStep, steps, values, customSteps, value) {
|
|
|
256
256
|
case Types.CLASSIFIER_SELECTOR: {
|
|
257
257
|
return value.value;
|
|
258
258
|
}
|
|
259
|
+
case Types.COLLAPSIBLE: {
|
|
260
|
+
return !!value;
|
|
261
|
+
}
|
|
259
262
|
case Types.MAPPER: {
|
|
260
263
|
var elements = value === null || value === void 0 ? void 0 : value.filter(function (element) { return element.deleted !== true; });
|
|
261
264
|
var mappedValues = [];
|
|
@@ -48,10 +48,10 @@ export var getLocale = function () {
|
|
|
48
48
|
navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
|
|
49
49
|
};
|
|
50
50
|
function FormComponent(_a) {
|
|
51
|
-
var _b, _c;
|
|
51
|
+
var _b, _c, _d, _e, _f, _g;
|
|
52
52
|
var form = _a.form, isWidget = _a.isWidget, internal = _a.internal, postview = _a.postview, organization = _a.organization, containerRef = _a.containerRef, others = __rest(_a, ["form", "isWidget", "internal", "postview", "organization", "containerRef"]);
|
|
53
|
-
var
|
|
54
|
-
var
|
|
53
|
+
var _h = useState(false), loaded = _h[0], setLoaded = _h[1];
|
|
54
|
+
var _j = useState(undefined), widthStats = _j[0], setWidthStats = _j[1];
|
|
55
55
|
/** Calcs the currentBreakPoint and if is mobile */
|
|
56
56
|
var handleResize = function () {
|
|
57
57
|
var _a;
|
|
@@ -88,7 +88,7 @@ function FormComponent(_a) {
|
|
|
88
88
|
if ((postview || internal || !form.isStandAlone) &&
|
|
89
89
|
widthStats !== undefined) {
|
|
90
90
|
return (_jsx("div", __assign({ style: {
|
|
91
|
-
backgroundColor: internal
|
|
91
|
+
backgroundColor: internal || !form.style
|
|
92
92
|
? InternalFormStyle.backgroundColor
|
|
93
93
|
: form.style.backgroundColor,
|
|
94
94
|
minHeight: form.isStandAlone && !isWidget ? '100vh' : '100%',
|
|
@@ -96,16 +96,16 @@ function FormComponent(_a) {
|
|
|
96
96
|
setLoaded(true);
|
|
97
97
|
}, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal
|
|
98
98
|
? InternalFormStyle
|
|
99
|
-
: __assign(__assign({}, InternalFormStyle), form.style) })) })) })));
|
|
99
|
+
: __assign(__assign({}, InternalFormStyle), ((_c = form.style) !== null && _c !== void 0 ? _c : {})) })) })) })));
|
|
100
100
|
}
|
|
101
101
|
else if (organization && widthStats !== undefined) {
|
|
102
102
|
//Standalone cant have widget
|
|
103
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (
|
|
103
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_d = organization.styles) === null || _d === void 0 ? void 0 : _d.primaryColor }), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
|
|
104
104
|
? styles.fullScreenStandAloneForm
|
|
105
105
|
: styles.standAloneFormCard, style: {
|
|
106
|
-
backgroundColor: form.style.backgroundColor,
|
|
106
|
+
backgroundColor: (_f = (_e = form.style) === null || _e === void 0 ? void 0 : _e.backgroundColor) !== null && _f !== void 0 ? _f : InternalFormStyle.backgroundColor,
|
|
107
107
|
visibility: loaded ? 'visible' : 'hidden',
|
|
108
|
-
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style, organization: organization, handleLoaded: function () {
|
|
108
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: (_g = form.style) !== null && _g !== void 0 ? _g : InternalFormStyle, organization: organization, handleLoaded: function () {
|
|
109
109
|
setLoaded(true);
|
|
110
110
|
} })) })) }))] }));
|
|
111
111
|
}
|
|
@@ -126,12 +126,10 @@ function FormTypeComponent(_a) {
|
|
|
126
126
|
var props = __rest(_a, []);
|
|
127
127
|
var renderTypes = function () {
|
|
128
128
|
switch (props.form.type) {
|
|
129
|
-
case FormTypes.COLUMN: {
|
|
130
|
-
return _jsx(ColumnForm, __assign({}, props));
|
|
131
|
-
}
|
|
132
129
|
case FormTypes.STEPPER: {
|
|
133
130
|
return _jsx(StepperForm, __assign({}, props));
|
|
134
131
|
}
|
|
132
|
+
case FormTypes.COLUMN:
|
|
135
133
|
default: {
|
|
136
134
|
return _jsx(ColumnForm, __assign({}, props));
|
|
137
135
|
}
|
|
@@ -34,20 +34,20 @@ function MaterialSection(_a) {
|
|
|
34
34
|
widthStats.currentBreakPoint < form.size.blockNum
|
|
35
35
|
? 'center'
|
|
36
36
|
: 'normal',
|
|
37
|
-
} }, { children: section.steps.map(function (idStep
|
|
37
|
+
} }, { children: section.steps.map(function (idStep) {
|
|
38
38
|
var step = form.steps[idStep];
|
|
39
39
|
//If partial is active only display steps with originalValues
|
|
40
40
|
if (postview &&
|
|
41
41
|
partial &&
|
|
42
42
|
originalValues[idStep] === undefined) {
|
|
43
|
-
return _jsx("div", {},
|
|
43
|
+
return _jsx("div", {}, idStep);
|
|
44
44
|
}
|
|
45
45
|
else if (step) {
|
|
46
|
-
return (_createElement(StepComponent, __assign({}, others, { widthStats: widthStats, form: form, step: step, key:
|
|
46
|
+
return (_createElement(StepComponent, __assign({}, others, { widthStats: widthStats, form: form, step: step, key: idStep, level: 0 })));
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
console.error('Step not found:', idStep);
|
|
50
|
-
return _jsx("div", {},
|
|
50
|
+
return _jsx("div", {}, idStep);
|
|
51
51
|
}
|
|
52
52
|
}) })));
|
|
53
53
|
}
|
|
@@ -30,14 +30,15 @@ import { Controller } from 'react-hook-form';
|
|
|
30
30
|
import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
|
|
31
31
|
import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
32
32
|
function ClassifierSelector(_a) {
|
|
33
|
+
var _b;
|
|
33
34
|
var step = _a.step, form = _a.form, level = _a.level, errors = _a.errors, value = _a.value, onBlur = _a.onBlur, control = _a.control, editable = _a.editable, onChange = _a.onChange, postview = _a.postview, inputRef = _a.inputRef, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "errors", "value", "onBlur", "control", "editable", "onChange", "postview", "inputRef", "formStyle", "getValues", "widthStats", "handleSizeChange"]);
|
|
34
|
-
var
|
|
35
|
+
var _c = useState(level === 0
|
|
35
36
|
? calcFillerSize(step, form.steps, getValues(), form.size)
|
|
36
|
-
: 0), fillerSize =
|
|
37
|
+
: 0), fillerSize = _c[0], setFillerSize = _c[1];
|
|
37
38
|
if (!step.idClassifier) {
|
|
38
39
|
return _jsx("div", {});
|
|
39
40
|
}
|
|
40
|
-
var classifier = form.classifiers[step.idClassifier];
|
|
41
|
+
var classifier = (_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[step.idClassifier];
|
|
41
42
|
if (!classifier) {
|
|
42
43
|
return _jsx("div", {});
|
|
43
44
|
}
|
|
@@ -49,11 +50,11 @@ function ClassifierSelector(_a) {
|
|
|
49
50
|
: classifier === null || classifier === void 0 ? void 0 : classifier._id]) === null || _a === void 0 ? void 0 : _a.type) !== ClassifierOptionTypes.HIDE;
|
|
50
51
|
})
|
|
51
52
|
.map(function (classifier) {
|
|
52
|
-
var _a;
|
|
53
|
+
var _a, _b;
|
|
53
54
|
return typeof classifier === 'string'
|
|
54
55
|
? {
|
|
55
56
|
value: classifier,
|
|
56
|
-
label: (_a = form.classifiers[classifier]) === null ||
|
|
57
|
+
label: (_b = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[classifier]) === null || _b === void 0 ? void 0 : _b.name,
|
|
57
58
|
}
|
|
58
59
|
: { value: classifier._id, label: classifier.name };
|
|
59
60
|
});
|
|
@@ -83,9 +84,9 @@ function ClassifierSelector(_a) {
|
|
|
83
84
|
if (value) {
|
|
84
85
|
var currentOption = step.options[value.value];
|
|
85
86
|
if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ClassifierOptionTypes.NESTED) {
|
|
86
|
-
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep
|
|
87
|
+
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
|
|
87
88
|
var subStep = form.steps[idStep];
|
|
88
|
-
return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, formStyle: formStyle, errors: errors, form: form, control: control, step: subStep, key:
|
|
89
|
+
return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, widthStats: widthStats, getValues: getValues, formStyle: formStyle, errors: errors, form: form, control: control, step: subStep, key: idStep, level: level + 1, handleSizeChange: function () {
|
|
89
90
|
sizeChange();
|
|
90
91
|
} })));
|
|
91
92
|
}) }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Collapsible } from '../../../@Types/FormStep';
|
|
3
|
+
import { StepProps } from '../Step';
|
|
4
|
+
export interface CollapsibleStepProps extends StepProps {
|
|
5
|
+
/** The CollapsibleStep to display */
|
|
6
|
+
step: Collapsible;
|
|
7
|
+
}
|
|
8
|
+
declare function CollapsibleStep({ step, formStyle, ...others }: CollapsibleStepProps): JSX.Element;
|
|
9
|
+
export default CollapsibleStep;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
25
|
+
import MaterialCollapsibleStep from './MaterialTitleStep/MaterialCollapsibleStep';
|
|
26
|
+
function CollapsibleStep(_a) {
|
|
27
|
+
var step = _a.step, formStyle = _a.formStyle, others = __rest(_a, ["step", "formStyle"]);
|
|
28
|
+
if (step.steps.length === 0)
|
|
29
|
+
return _jsx(_Fragment, {});
|
|
30
|
+
switch (formStyle.type) {
|
|
31
|
+
case FormStyleTypes.MATERIAL:
|
|
32
|
+
default: {
|
|
33
|
+
return (_jsx(MaterialCollapsibleStep, __assign({ step: step, formStyle: formStyle }, others)));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default CollapsibleStep;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { createElement as _createElement } from "react";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import React, { useEffect } from 'react';
|
|
26
|
+
import styles from './MaterialCollapsibleStep.module.css';
|
|
27
|
+
import { Controller } from 'react-hook-form';
|
|
28
|
+
import StepComponent from '../../Step';
|
|
29
|
+
import ExpandMoreRoundedIcon from '@material-ui/icons/ExpandMoreRounded';
|
|
30
|
+
import ExpandLessRoundedIcon from '@material-ui/icons/ExpandLessRounded';
|
|
31
|
+
function Collapsible(_a) {
|
|
32
|
+
var _b, _c, _d, _e;
|
|
33
|
+
var step = _a.step, open = _a.open, setOpen = _a.setOpen, formStyle = _a.formStyle, widthStats = _a.widthStats, form = _a.form, errors = _a.errors, clearErrors = _a.clearErrors, others = __rest(_a, ["step", "open", "setOpen", "formStyle", "widthStats", "form", "errors", "clearErrors"]);
|
|
34
|
+
var contentRef = React.useRef(null);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!open && ((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.find(function (dep) { return !!errors[dep]; }))) {
|
|
38
|
+
setOpen('TRUE');
|
|
39
|
+
}
|
|
40
|
+
}, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return errors[dep]; })) !== null && _c !== void 0 ? _c : []);
|
|
41
|
+
return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: styles.container, style: {
|
|
42
|
+
color: formStyle.textColor,
|
|
43
|
+
borderColor: formStyle.primaryColor,
|
|
44
|
+
} }, { children: [_jsx("div", __assign({ className: styles.collapsibleLabel, onClick: function () {
|
|
45
|
+
setOpen(!open);
|
|
46
|
+
} }, { children: step.label })), _jsx("div", __assign({ className: styles.expand, onClick: function () {
|
|
47
|
+
setOpen(!open);
|
|
48
|
+
} }, { children: _jsx("div", __assign({ className: styles.expandIcon }, { children: open ? (_jsx(ExpandLessRoundedIcon, { fontSize: "inherit" })) : (_jsx(ExpandMoreRoundedIcon, { fontSize: "inherit" })) })) }))] })), _jsx("div", __assign({ className: styles.content, style: {
|
|
49
|
+
height: open === 'TRUE'
|
|
50
|
+
? 'auto'
|
|
51
|
+
: open
|
|
52
|
+
? (_e = (_d = contentRef.current) === null || _d === void 0 ? void 0 : _d.offsetHeight) !== null && _e !== void 0 ? _e : 'auto'
|
|
53
|
+
: 0,
|
|
54
|
+
} }, { children: _jsx("div", __assign({ className: styles.contentContainer, ref: contentRef }, { children: step.steps.map(function (idSubStep) {
|
|
55
|
+
var subStep = form.steps[idSubStep];
|
|
56
|
+
return (_createElement(StepComponent, __assign({}, others, { clearErrors: clearErrors, errors: errors, formStyle: formStyle, form: form, widthStats: widthStats, step: subStep, key: idSubStep, handleSizeChange: function () { } })));
|
|
57
|
+
}) })) })), _jsx("div", { className: styles.separator, style: {
|
|
58
|
+
backgroundColor: formStyle.primaryColor,
|
|
59
|
+
} })] }));
|
|
60
|
+
}
|
|
61
|
+
function CollapsibleStep(props) {
|
|
62
|
+
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: props.postview ? false : true, render: function (_a) {
|
|
63
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
64
|
+
return (_jsx(Collapsible, __assign({}, props, { open: value, setOpen: function (open) {
|
|
65
|
+
var _a;
|
|
66
|
+
if (!open) {
|
|
67
|
+
var deps = (_a = props.step.dependencies) === null || _a === void 0 ? void 0 : _a.filter(function (dep) { return !!props.errors[dep]; });
|
|
68
|
+
if (deps)
|
|
69
|
+
props.clearErrors(deps);
|
|
70
|
+
}
|
|
71
|
+
onChange(open);
|
|
72
|
+
} })));
|
|
73
|
+
} }));
|
|
74
|
+
}
|
|
75
|
+
export default CollapsibleStep;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
width: 900px;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
margin-top: 5px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.collapsibleLabel {
|
|
10
|
+
margin-top: 10px;
|
|
11
|
+
margin-bottom: 10px;
|
|
12
|
+
margin-left: 10px;
|
|
13
|
+
font-size: 20px;
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
cursor: default;
|
|
16
|
+
text-align: start;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
19
|
+
-webkit-user-select: none; /* Safari */
|
|
20
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
21
|
+
-moz-user-select: none; /* Old versions of Firefox */
|
|
22
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
23
|
+
-o-user-select: none;
|
|
24
|
+
user-select: none; /* Non-prefixed version, currently */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.content {
|
|
28
|
+
width: 100%;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
transition: height ease 0.9s;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.contentContainer {
|
|
34
|
+
margin-left: auto;
|
|
35
|
+
margin-right: auto;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-flow: row wrap;
|
|
38
|
+
height: fit-content;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
width: 100%;
|
|
41
|
+
overflow-x: hidden;
|
|
42
|
+
overflow-y: hidden;
|
|
43
|
+
}
|
|
44
|
+
.expand {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
margin-left: 2px;
|
|
49
|
+
}
|
|
50
|
+
.expandIcon {
|
|
51
|
+
height: 24px;
|
|
52
|
+
width: 24px;
|
|
53
|
+
font-size: 24px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.separator {
|
|
58
|
+
height: 1px;
|
|
59
|
+
width: calc(100% - 20px);
|
|
60
|
+
margin-left: 10px;
|
|
61
|
+
border-radius: 20px;
|
|
62
|
+
}
|
|
@@ -29,11 +29,11 @@ function MapperElementComponent(_a) {
|
|
|
29
29
|
if (element.deleted) {
|
|
30
30
|
return _jsx("div", {});
|
|
31
31
|
}
|
|
32
|
-
return (_jsx(PillElementContainer, __assign({ handleDelete: handleDelete }, others, { step: step, size: form.size }, { children: step.rootSteps.map(function (idSubStep
|
|
32
|
+
return (_jsx(PillElementContainer, __assign({ handleDelete: handleDelete }, others, { step: step, size: form.size }, { children: step.rootSteps.map(function (idSubStep) {
|
|
33
33
|
var subStep = form.steps[element.ids[idSubStep]];
|
|
34
34
|
if (!subStep)
|
|
35
35
|
return _jsx("div", {});
|
|
36
|
-
return (_createElement(StepComponent, __assign({}, others, { form: form, step: subStep, key:
|
|
36
|
+
return (_createElement(StepComponent, __assign({}, others, { form: form, step: subStep, key: idSubStep, level: level + 1 })));
|
|
37
37
|
}) })));
|
|
38
38
|
}
|
|
39
39
|
export default MapperElementComponent;
|
|
@@ -112,11 +112,11 @@ function Elements(_a) {
|
|
|
112
112
|
margin: step.description
|
|
113
113
|
? '10px 0px'
|
|
114
114
|
: '0px 0px 5px 0px',
|
|
115
|
-
} }, { children: step.description }))), elements.map(function (
|
|
115
|
+
} }, { children: step.description }))), elements.map(function (element, index) { return (_jsx(MapperElementComponent, __assign({ num: index, element: element, formStyle: formStyle, step: step, form: __assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) }), editable: editable, postview: postview, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore, handleDelete: function () {
|
|
116
116
|
var tempElements = __spreadArray([], elements, true);
|
|
117
117
|
tempElements[index].deleted = true;
|
|
118
118
|
onChange(tempElements);
|
|
119
|
-
} }, others),
|
|
119
|
+
} }, others), element.id)); }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className: styles.hiddenInput }), step.creatable !== false && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel, color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
120
120
|
if (editable && !postview) {
|
|
121
121
|
handleAddElement();
|
|
122
122
|
}
|
|
@@ -187,6 +187,14 @@ function calcRecursiveData(element, newSteps, deps, originalValues) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
break;
|
|
190
|
+
case StepTypes.COLLAPSIBLE: {
|
|
191
|
+
for (var i = 0; i < step.steps.length; i++) {
|
|
192
|
+
var idStep_4 = step.steps[i];
|
|
193
|
+
var newId = element.ids[idStep_4];
|
|
194
|
+
step.steps[i] = newId;
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
190
198
|
case StepTypes.ENTITYVALUEPICKER:
|
|
191
199
|
for (var _h = 0, _j = step.filters; _h < _j.length; _h++) {
|
|
192
200
|
var filter = _j[_h];
|
|
@@ -41,9 +41,9 @@ function MaterialRatingStep(_a) {
|
|
|
41
41
|
currentOption = step.nestedSteps[value - 1];
|
|
42
42
|
}
|
|
43
43
|
if (currentOption && currentOption.length > 0) {
|
|
44
|
-
return (_jsx(React.Fragment, { children: currentOption.map(function (idSubStep
|
|
44
|
+
return (_jsx(React.Fragment, { children: currentOption.map(function (idSubStep) {
|
|
45
45
|
var subStep = form.steps[idSubStep];
|
|
46
|
-
return (_createElement(StepComponent, __assign({}, others, { form: form, postview: postview, editable: editable, formStyle: formStyle, errors: errors, widthStats: widthStats, step: subStep, key:
|
|
46
|
+
return (_createElement(StepComponent, __assign({}, others, { form: form, postview: postview, editable: editable, formStyle: formStyle, errors: errors, widthStats: widthStats, step: subStep, key: idSubStep, level: level + 1 })));
|
|
47
47
|
}) }));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -67,9 +67,9 @@ function Selector(_a) {
|
|
|
67
67
|
}
|
|
68
68
|
if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === OptionTypes.NESTED &&
|
|
69
69
|
currentOptionIndex !== null) {
|
|
70
|
-
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idSubStep
|
|
70
|
+
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idSubStep) {
|
|
71
71
|
var subStep = form.steps[idSubStep];
|
|
72
|
-
return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, formStyle: formStyle, form: form, getValues: getValues, errors: errors, control: control, widthStats: widthStats, step: subStep, key:
|
|
72
|
+
return (_createElement(StepComponent, __assign({}, others, { postview: postview, editable: editable, formStyle: formStyle, form: form, getValues: getValues, errors: errors, control: control, widthStats: widthStats, step: subStep, key: idSubStep, level: level + 1, handleSizeChange: function () {
|
|
73
73
|
sizeChange();
|
|
74
74
|
} })));
|
|
75
75
|
}) }));
|
|
@@ -36,6 +36,7 @@ import RatingStep from './RatingStep/RatingStep';
|
|
|
36
36
|
import AYFStepMapper from './AYFStepMapper';
|
|
37
37
|
import EntityValuePickerStep from './EntityValueStep/EntityValueStep';
|
|
38
38
|
import MapperStep from './MapperStep/MapperStep';
|
|
39
|
+
import CollapsibleStep from './CollapsibleStep/CollapsibleStep';
|
|
39
40
|
function StepComponent(_a) {
|
|
40
41
|
var _b;
|
|
41
42
|
var step = _a.step, props = __rest(_a, ["step"]);
|
|
@@ -74,6 +75,9 @@ function StepComponent(_a) {
|
|
|
74
75
|
case Types.RATING: {
|
|
75
76
|
return _jsx(RatingStep, __assign({ step: step }, props));
|
|
76
77
|
}
|
|
78
|
+
case Types.COLLAPSIBLE: {
|
|
79
|
+
return _jsx(CollapsibleStep, __assign({ step: step }, props));
|
|
80
|
+
}
|
|
77
81
|
case Types.ENTITYVALUEPICKER: {
|
|
78
82
|
return (_jsx(EntityValuePickerStep, __assign({ step: step }, props)));
|
|
79
83
|
}
|
|
@@ -19,6 +19,7 @@ export var StepTypes;
|
|
|
19
19
|
StepTypes["SEPARATOR"] = "SEPARATOR";
|
|
20
20
|
StepTypes["SELECTOR"] = "SELECTOR";
|
|
21
21
|
StepTypes["CLASSIFIER_SELECTOR"] = "CLASSIFIER_SELECTOR";
|
|
22
|
+
StepTypes["COLLAPSIBLE"] = "COLLAPSIBLE";
|
|
22
23
|
StepTypes["MAPPER"] = "MAPPER";
|
|
23
24
|
StepTypes["ENTITYVALUEPICKER"] = "ENTITYVALUEPICKER";
|
|
24
25
|
})(StepTypes || (StepTypes = {}));
|
package/package.json
CHANGED