@arquimedes.co/eureka-forms 1.9.97-test → 1.9.99-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.d.ts +2 -1
- package/dist/App.js +23 -22
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +1 -1
- package/dist/FormComponents/Section/Section.d.ts +1 -0
- package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +6 -5
- package/dist/FormComponents/Step/MapperStep/MaterialMapperStep/MaterialMapperStep.js +38 -33
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +13 -2
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Classifier, Form } from './@Types/Form';
|
|
3
|
-
import { FormStep } from './@Types/FormStep';
|
|
3
|
+
import { FormStep, Mapper } from './@Types/FormStep';
|
|
4
4
|
export interface AppProps {
|
|
5
5
|
/** If the app is currently a widget */
|
|
6
6
|
isWidget?: boolean;
|
|
@@ -49,4 +49,5 @@ export interface CustomStep {
|
|
|
49
49
|
}
|
|
50
50
|
declare function App({ apiKey, domain, preview, partial, formData, postview, editable, isWidget, internal, valuesData, customSend, customSteps, classifiers, handleConfirmed, customStepProps, ...others }: AppProps): JSX.Element;
|
|
51
51
|
export default App;
|
|
52
|
+
export declare const addInitialMapper: (newValues: Record<string, any>, step: Mapper) => void;
|
|
52
53
|
export declare const mapOriginalValue: (step: FormStep, value: any, form?: Form) => any;
|
package/dist/App.js
CHANGED
|
@@ -380,32 +380,33 @@ var mapOriginalValues = function (originalValues, form) {
|
|
|
380
380
|
newValues[idValue] = originalValues[idValue];
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return newValues;
|
|
386
|
-
};
|
|
387
|
-
var addInitialMappers = function (newValues, steps) {
|
|
388
|
-
for (var _i = 0, _a = Object.values(steps); _i < _a.length; _i++) {
|
|
389
|
-
var step = _a[_i];
|
|
383
|
+
for (var _f = 0, _g = Object.values(form.steps); _f < _g.length; _f++) {
|
|
384
|
+
var step = _g[_f];
|
|
390
385
|
if (step.type !== StepTypes.MAPPER || newValues[step.id])
|
|
391
386
|
continue;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
387
|
+
addInitialMapper(newValues, step);
|
|
388
|
+
}
|
|
389
|
+
return newValues;
|
|
390
|
+
};
|
|
391
|
+
export var addInitialMapper = function (newValues, step) {
|
|
392
|
+
var idElement = nanoid();
|
|
393
|
+
var newElement = {
|
|
394
|
+
ids: {},
|
|
395
|
+
id: idElement,
|
|
396
|
+
};
|
|
397
|
+
var newSteps = {};
|
|
398
|
+
for (var _i = 0, _a = Object.keys(step.steps); _i < _a.length; _i++) {
|
|
399
|
+
var idStep = _a[_i];
|
|
400
|
+
var baseStep = JSON.parse(JSON.stringify(step.steps[idStep]));
|
|
401
|
+
var newIdStep = step.id + '-' + idStep + '-' + idElement;
|
|
402
|
+
baseStep.id = newIdStep;
|
|
403
|
+
newElement.ids[idStep] = newIdStep;
|
|
404
|
+
newSteps[newIdStep] = baseStep;
|
|
405
|
+
if (baseStep.type === StepTypes.MAPPER) {
|
|
406
|
+
addInitialMapper(newValues, baseStep);
|
|
405
407
|
}
|
|
406
|
-
addInitialMappers(newValues, step.steps);
|
|
407
|
-
newValues[step.id] = [newElement];
|
|
408
408
|
}
|
|
409
|
+
newValues[step.id] = [newElement];
|
|
409
410
|
};
|
|
410
411
|
export var mapOriginalValue = function (step, value, form) {
|
|
411
412
|
var _a, _b, _c, _d;
|
|
@@ -165,7 +165,7 @@ function ColumnForm(_a) {
|
|
|
165
165
|
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 () {
|
|
166
166
|
reload();
|
|
167
167
|
setShowConfirmation(undefined);
|
|
168
|
-
} })), 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 &&
|
|
168
|
+
} })), 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, setValue: setValue }, others), idSection)); }), form.terms &&
|
|
169
169
|
(!internal || (internal && postview)) &&
|
|
170
170
|
(originalValues === null || originalValues === void 0 ? void 0 : originalValues['INTERNAL_CREATING_AGENT']) === undefined && (_jsx("div", __assign({ className: styles.termsContainer, style: {
|
|
171
171
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
@@ -27,6 +27,7 @@ export interface RecursiveData {
|
|
|
27
27
|
dependencyStore: Record<string, any>;
|
|
28
28
|
setDependencyStore: React.Dispatch<React.SetStateAction<Record<string, any>>>;
|
|
29
29
|
setFocus: (id: string) => void;
|
|
30
|
+
setValue: (id: string, value: any) => void;
|
|
30
31
|
}
|
|
31
32
|
export interface SectionComponentProps extends RecursiveData {
|
|
32
33
|
/** The custom send label to display */
|
|
@@ -17,14 +17,15 @@ function PillMapperElement(_a) {
|
|
|
17
17
|
var step = _a.step, form = _a.form, num = _a.num, loading = _a.loading, element = _a.element, children = _a.children, editable = _a.editable, postview = _a.postview, formStyle = _a.formStyle, handleDelete = _a.handleDelete, widthStats = _a.widthStats, customElementModifiers = _a.customElementModifiers;
|
|
18
18
|
var size = form.size;
|
|
19
19
|
var calcName = (customElementModifiers !== null && customElementModifiers !== void 0 ? customElementModifiers : {}).calcName;
|
|
20
|
+
var name = calcName
|
|
21
|
+
? calcName(element)
|
|
22
|
+
: step.unitLabel
|
|
23
|
+
? step.unitLabel + ' ' + (num + 1).toString()
|
|
24
|
+
: '';
|
|
20
25
|
return (_jsx("div", __assign({ className: widthStats.isMobile ? styles.mobileContainer : styles.container }, { children: _jsxs("div", __assign({ className: styles.contentContainer, style: {
|
|
21
26
|
width: (size.blockSize + size.spacingSize) *
|
|
22
27
|
((_c = (_b = step.style) === null || _b === void 0 ? void 0 : _b.size) !== null && _c !== void 0 ? _c : size.blockNum - 1),
|
|
23
|
-
} }, { children: [_jsx("div", __assign({ className: styles.titleLbl, style: { color: formStyle.textColor } }, { children: loading
|
|
24
|
-
? ''
|
|
25
|
-
: (calcName
|
|
26
|
-
? calcName(element)
|
|
27
|
-
: step.unitLabel + ' ' + (num + 1)) + ':' })), step.deletable !== false && (_jsx("div", __assign({ className: !editable || postview
|
|
28
|
+
} }, { children: [_jsx("div", __assign({ className: styles.titleLbl, style: { color: formStyle.textColor } }, { children: loading ? '' : name })), step.deletable !== false && (_jsx("div", __assign({ className: !editable || postview
|
|
28
29
|
? styles.disabledDeleteBtn
|
|
29
30
|
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: function () {
|
|
30
31
|
if (editable && !postview) {
|
|
@@ -30,6 +30,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { createElement as _createElement } from "react";
|
|
33
34
|
import React, { useState, useEffect, cloneElement } from 'react';
|
|
34
35
|
import styles from './MaterialMapperStep.module.css';
|
|
35
36
|
import { Controller } from 'react-hook-form';
|
|
@@ -40,46 +41,44 @@ import { calcStepDependencyValue } from '../../../Form/ColumnForm/ColumnForm';
|
|
|
40
41
|
import MapperElementComponent from './Element/MapperElement';
|
|
41
42
|
import AYFFormStepTypes from '../../../../constants/AYFFormStepTypes';
|
|
42
43
|
import CBRFormStepTypes from '../../../../constants/CBRFormStepTypes';
|
|
44
|
+
import { addInitialMapper } from '../../../../App';
|
|
43
45
|
export function ElementsComponent(_a) {
|
|
44
46
|
var _b, _c;
|
|
45
47
|
var step = _a.step, form = _a.form, errors = _a.errors, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, elements = _a.elements, formStyle = _a.formStyle, customAdd = _a.customAdd, _d = _a.loading, loading = _d === void 0 ? false : _d, dependencyStore = _a.dependencyStore, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["step", "form", "errors", "inputRef", "editable", "postview", "elements", "formStyle", "customAdd", "loading", "dependencyStore", "setDependencyStore"]);
|
|
46
48
|
var _e = useState(true), firstRender = _e[0], setFirstRender = _e[1];
|
|
47
49
|
/** Mapper Steps to pass down */
|
|
48
|
-
var _f = useState()
|
|
49
|
-
var onChange = function (elements) {
|
|
50
|
+
var _f = useState((function () {
|
|
50
51
|
var _a;
|
|
51
|
-
var
|
|
52
|
+
var newSteps = {};
|
|
53
|
+
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
|
|
54
|
+
var element = elements_1[_i];
|
|
55
|
+
var elemSteps = {};
|
|
56
|
+
for (var _b = 0, _c = Object.keys(step.steps); _b < _c.length; _b++) {
|
|
57
|
+
var idStep = _c[_b];
|
|
58
|
+
var baseStep = JSON.parse(JSON.stringify((_a = step.steps[idStep]) !== null && _a !== void 0 ? _a : '{}'));
|
|
59
|
+
var newIdStep = element.ids[idStep];
|
|
60
|
+
baseStep.id = newIdStep;
|
|
61
|
+
elemSteps[newIdStep] = baseStep;
|
|
62
|
+
newSteps[newIdStep] = baseStep;
|
|
63
|
+
}
|
|
64
|
+
calcRecursiveData(element, elemSteps, {}, others.customSteps, others.originalValues);
|
|
65
|
+
}
|
|
66
|
+
return newSteps;
|
|
67
|
+
})()), localSteps = _f[0], setLocalSteps = _f[1];
|
|
68
|
+
var onChange = function (elements) {
|
|
52
69
|
if (dependencyStore[step.id] !== undefined && customAdd) {
|
|
53
|
-
setDependencyStore(
|
|
70
|
+
setDependencyStore(function (dependencyStore) {
|
|
71
|
+
var _a;
|
|
72
|
+
var _b;
|
|
73
|
+
return (__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = (_b = elements.map(function (element) { return element.value; })) !== null && _b !== void 0 ? _b : null, _a)));
|
|
74
|
+
});
|
|
54
75
|
}
|
|
55
76
|
others.onChange(elements);
|
|
56
77
|
};
|
|
57
78
|
useEffect(function () {
|
|
58
|
-
var _a;
|
|
59
79
|
if (firstRender) {
|
|
60
|
-
if (elements.length
|
|
61
|
-
|
|
62
|
-
var deps = __assign({}, dependencyStore);
|
|
63
|
-
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
|
|
64
|
-
var element = elements_1[_i];
|
|
65
|
-
var elemSteps = {};
|
|
66
|
-
for (var _b = 0, _c = Object.keys(step.steps); _b < _c.length; _b++) {
|
|
67
|
-
var idStep = _c[_b];
|
|
68
|
-
var baseStep = JSON.parse(JSON.stringify((_a = step.steps[idStep]) !== null && _a !== void 0 ? _a : '{}'));
|
|
69
|
-
var newIdStep = element.ids[idStep];
|
|
70
|
-
baseStep.id = newIdStep;
|
|
71
|
-
elemSteps[newIdStep] = baseStep;
|
|
72
|
-
newSteps[newIdStep] = baseStep;
|
|
73
|
-
}
|
|
74
|
-
calcRecursiveData(element, elemSteps, deps, others.customSteps, others.originalValues);
|
|
75
|
-
}
|
|
76
|
-
setDependencyStore(deps);
|
|
77
|
-
setLocalSteps(__assign(__assign({}, localSteps), newSteps));
|
|
78
|
-
}
|
|
79
|
-
else if (elements.length === 0 && !postview && editable) {
|
|
80
|
-
if (customAdd)
|
|
81
|
-
setLocalSteps({});
|
|
82
|
-
else
|
|
80
|
+
if (elements.length === 0 && !postview && editable) {
|
|
81
|
+
if (!customAdd)
|
|
83
82
|
handleAddElement();
|
|
84
83
|
}
|
|
85
84
|
setFirstRender(false);
|
|
@@ -96,6 +95,7 @@ export function ElementsComponent(_a) {
|
|
|
96
95
|
value: value,
|
|
97
96
|
};
|
|
98
97
|
var newSteps = {};
|
|
98
|
+
var newValues = {};
|
|
99
99
|
for (var _i = 0, _a = Object.keys(step.steps); _i < _a.length; _i++) {
|
|
100
100
|
var idStep = _a[_i];
|
|
101
101
|
var baseStep = JSON.parse(JSON.stringify(step.steps[idStep]));
|
|
@@ -103,6 +103,13 @@ export function ElementsComponent(_a) {
|
|
|
103
103
|
baseStep.id = newIdStep;
|
|
104
104
|
newElement.ids[idStep] = newIdStep;
|
|
105
105
|
newSteps[newIdStep] = baseStep;
|
|
106
|
+
if (baseStep.type === StepTypes.MAPPER) {
|
|
107
|
+
addInitialMapper(newValues, baseStep);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (var _b = 0, _c = Object.entries(newValues); _b < _c.length; _b++) {
|
|
111
|
+
var _d = _c[_b], key = _d[0], elems = _d[1];
|
|
112
|
+
others.setValue(key, elems);
|
|
106
113
|
}
|
|
107
114
|
var deps = __assign({}, dependencyStore);
|
|
108
115
|
calcRecursiveData(newElement, newSteps, others.customSteps, deps);
|
|
@@ -121,18 +128,16 @@ export function ElementsComponent(_a) {
|
|
|
121
128
|
}
|
|
122
129
|
};
|
|
123
130
|
var container = calcStyles().container;
|
|
124
|
-
if (!localSteps)
|
|
125
|
-
return _jsx("div", {});
|
|
126
131
|
var mapElements = function () {
|
|
127
|
-
return elements.map(function (element, index) { return (
|
|
132
|
+
return elements.map(function (element, index) { return (_createElement(MapperElementComponent, __assign({}, others, { key: element.id, num: index, loading: loading, element: element, formStyle: formStyle, step: step, errors: errors, form: __assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) }), editable: editable, postview: postview, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore, handleDelete: function () {
|
|
128
133
|
var tempElements = __spreadArray([], elements, true);
|
|
129
134
|
tempElements[index].deleted = true;
|
|
130
135
|
onChange(tempElements);
|
|
131
|
-
} }
|
|
136
|
+
} }))); });
|
|
132
137
|
};
|
|
133
138
|
if (step.style.type === MapperStyleTypes.INLINE)
|
|
134
139
|
return _jsx(React.Fragment, { children: mapElements() });
|
|
135
|
-
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor } }, { children: [_jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
140
|
+
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor } }, { children: [step.label && _jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
136
141
|
margin: step.description
|
|
137
142
|
? '10px 0px'
|
|
138
143
|
: '0px 0px 5px 0px',
|
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
24
|
import { Controller } from 'react-hook-form';
|
|
14
25
|
import { calcStepWidth } from '../../StepFunctions';
|
|
@@ -37,8 +48,8 @@ function TitleStep(props) {
|
|
|
37
48
|
title: props.step.title,
|
|
38
49
|
description: props.step.description,
|
|
39
50
|
}, render: function (_a) {
|
|
40
|
-
var
|
|
41
|
-
return _jsx(Title, __assign({}, props, field));
|
|
51
|
+
var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
|
|
52
|
+
return (_jsx(Title, __assign({}, props, field, { inputRef: ref })));
|
|
42
53
|
} }));
|
|
43
54
|
}
|
|
44
55
|
export default TitleStep;
|
package/package.json
CHANGED