@arquimedes.co/eureka-forms 2.0.19 → 2.0.21
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/FormStep.d.ts +1 -0
- package/dist/App/App.js +2 -2
- package/dist/App/AppFunctions.js +1 -1
- package/dist/Form/Section/MaterialSection/MaterialSection.js +1 -1
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +1 -1
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +1 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +1 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +23 -23
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +6 -0
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +2 -2
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +20 -63
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -16
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +1 -1
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +21 -76
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -28
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +39 -96
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +2 -2
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +7 -38
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +1 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +20 -74
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +2 -2
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +18 -42
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +2 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +9 -5
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +1 -1
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +15 -43
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +2 -2
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +22 -78
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +0 -16
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -9
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +26 -57
- package/dist/FormSteps/Step.d.ts +0 -2
- package/dist/FormSteps/StepFunctions.d.ts +2 -1
- package/dist/FormSteps/StepFunctions.js +71 -63
- package/dist/FormSteps/StepHooks.d.ts +16 -0
- package/dist/FormSteps/StepHooks.js +58 -2
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +3 -3
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +6 -37
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +13 -39
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +1 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +4 -24
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.d.ts +9 -0
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +48 -0
- package/dist/FormSteps/{EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css → Utils/@StepFiller/StepFiller.module.css} +16 -16
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +11 -0
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +32 -0
- package/dist/FormSteps/{DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css → Utils/MaterialInputContainer/MaterialInputContainer.module.css} +9 -9
- package/dist/Shared/RoundedCheckBox/RoundedCheckBox.d.ts +3 -3
- package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +1 -4
- package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.js +1 -3
- package/dist/States/SiteSlice.d.ts +2 -1
- package/dist/States/SiteSlice.js +25 -6
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +5 -1
- package/package.json +2 -2
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -25
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -9
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
13
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
14
|
if (ar || !(i in from)) {
|
|
@@ -7,11 +18,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
18
|
}
|
|
8
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
20
|
};
|
|
10
|
-
import { useCallback, useEffect } from 'react';
|
|
21
|
+
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
11
22
|
import { useAppSelector, useAppDispatch } from '../hooks';
|
|
12
|
-
import { setStepDependency } from '../States/SiteSlice';
|
|
23
|
+
import { clearDependency, setStepDependency, } from '../States/SiteSlice';
|
|
13
24
|
import { createSelector } from '@reduxjs/toolkit';
|
|
14
25
|
import { calcDefaultValue } from './StepFunctions';
|
|
26
|
+
import { useController, } from 'react-hook-form';
|
|
27
|
+
import { SizeChangeContext } from './Utils/@StepFiller/StepFiller';
|
|
15
28
|
var selectIsDependency = createSelector([
|
|
16
29
|
function (state) { return state.site.dependencies; },
|
|
17
30
|
function (state, step) { return step; },
|
|
@@ -38,6 +51,9 @@ export var useStepDependency = function (step, defaultValue) {
|
|
|
38
51
|
value: defaultValue,
|
|
39
52
|
}));
|
|
40
53
|
}
|
|
54
|
+
return function () {
|
|
55
|
+
dispatch(clearDependency(step));
|
|
56
|
+
};
|
|
41
57
|
}, [isDependency]);
|
|
42
58
|
var handleStepDep = useCallback(function (value) {
|
|
43
59
|
if (!isDependency)
|
|
@@ -85,3 +101,43 @@ var calcDeepDependencies = function (idStep, form, deps) {
|
|
|
85
101
|
}
|
|
86
102
|
return deps;
|
|
87
103
|
};
|
|
104
|
+
export var useFormStep = function (step, _a) {
|
|
105
|
+
var _b = _a === void 0 ? {} : _a, rules = _b.rules, debounce = _b.debounce, sizeChange = _b.sizeChange, defaultValue = _b.defaultValue;
|
|
106
|
+
var _c = useState(), timer = _c[0], setTimer = _c[1];
|
|
107
|
+
var _d = useStepDependency(step, defaultValue), isDependency = _d.isDependency, handleStepDep = _d.handleStepDep, originalValue = _d.originalValue;
|
|
108
|
+
var _e = useController({
|
|
109
|
+
name: step.id,
|
|
110
|
+
rules: rules,
|
|
111
|
+
shouldUnregister: true,
|
|
112
|
+
defaultValue: originalValue,
|
|
113
|
+
}), _f = _e.field, ref = _f.ref, value = _f.value, fieldOnChange = _f.onChange, field = __rest(_f, ["ref", "value", "onChange"]), error = _e.fieldState.error;
|
|
114
|
+
var handleSizeChange = useContext(SizeChangeContext);
|
|
115
|
+
var onChange = useCallback(function (value) {
|
|
116
|
+
if (isDependency) {
|
|
117
|
+
if (debounce) {
|
|
118
|
+
try {
|
|
119
|
+
clearTimeout(timer);
|
|
120
|
+
// eslint-disable-next-line no-empty
|
|
121
|
+
}
|
|
122
|
+
catch (e) { }
|
|
123
|
+
setTimer(setTimeout(function () {
|
|
124
|
+
handleStepDep(value);
|
|
125
|
+
setTimer(undefined);
|
|
126
|
+
}, 1000));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
handleStepDep(value);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
fieldOnChange(value);
|
|
133
|
+
if (sizeChange)
|
|
134
|
+
handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
|
|
135
|
+
}, [handleStepDep, isDependency, fieldOnChange]);
|
|
136
|
+
return {
|
|
137
|
+
ref: ref,
|
|
138
|
+
value: value,
|
|
139
|
+
onChange: onChange,
|
|
140
|
+
error: error,
|
|
141
|
+
field: field,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -114,7 +114,7 @@ function TextAreaStep(_a) {
|
|
|
114
114
|
}
|
|
115
115
|
} }, { children: _jsx("div", __assign({ className: postview
|
|
116
116
|
? styles.postViewContainer + ' EF-DraftContainer'
|
|
117
|
-
: styles.textContainer + ' EF-DraftContainer',
|
|
117
|
+
: styles.textContainer + ' EF-DraftContainer', style: calcStyle(), onMouseEnter: function () {
|
|
118
118
|
if (canEdit) {
|
|
119
119
|
setHovering(true);
|
|
120
120
|
}
|
|
@@ -126,9 +126,9 @@ function TextAreaStep(_a) {
|
|
|
126
126
|
if (canEdit) {
|
|
127
127
|
setFocus(true);
|
|
128
128
|
}
|
|
129
|
-
} }, { children: _jsx(Editor, __assign({}, field, { editorRef: ref, onFocus: function () {
|
|
129
|
+
}, "data-testid": step.id }, { children: _jsx(Editor, __assign({}, field, { editorRef: ref, onFocus: function () {
|
|
130
130
|
setFocus(true);
|
|
131
|
-
}, readOnly: !canEdit, stripPastedStyles: true, onEditorStateChange: handleChange, toolbarClassName: !canEdit ? ' postview-editor-toolbar' : '',
|
|
131
|
+
}, readOnly: !canEdit, stripPastedStyles: true, onEditorStateChange: handleChange, toolbarClassName: !canEdit ? ' postview-editor-toolbar' : '', editorClassName: editorClassName, wrapperClassName: styles.wrapper, placeholder: (_b = step.description) !== null && _b !== void 0 ? _b : '', toolbar: {
|
|
132
132
|
options: ['inline', 'list', 'history'],
|
|
133
133
|
inline: {
|
|
134
134
|
options: [
|
|
@@ -9,60 +9,29 @@ 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
|
-
};
|
|
23
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
13
|
import RoundedTextField from '../../../Shared/RoundedTextField/RoundedTextField';
|
|
25
14
|
import styles from './MaterialTextAreaStep.module.css';
|
|
26
|
-
import { useController } from 'react-hook-form';
|
|
27
|
-
import { useCallback, useState } from 'react';
|
|
28
15
|
import { useAppSelector } from '../../../hooks';
|
|
29
|
-
import {
|
|
16
|
+
import { useFormStep } from '../../StepHooks';
|
|
30
17
|
function TextAreaStep(_a) {
|
|
31
18
|
var _b, _c;
|
|
32
19
|
var step = _a.step, editable = _a.editable, maxLength = _a.maxLength;
|
|
33
20
|
var _d = useAppSelector(function (state) { return state.global; }), formStyle = _d.formStyle, postview = _d.postview, partial = _d.partial;
|
|
34
|
-
var _e =
|
|
35
|
-
|
|
36
|
-
var _g = useController({
|
|
37
|
-
name: step.id,
|
|
38
|
-
shouldUnregister: true,
|
|
21
|
+
var _e = useFormStep(step, {
|
|
22
|
+
debounce: true,
|
|
39
23
|
rules: {
|
|
40
24
|
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
41
25
|
},
|
|
42
|
-
|
|
43
|
-
}), _h = _g.field, ref = _h.ref, field = __rest(_h, ["ref"]), error = _g.fieldState.error;
|
|
44
|
-
var onChange = useCallback(function (e) {
|
|
45
|
-
if (isDependency) {
|
|
46
|
-
try {
|
|
47
|
-
clearTimeout(timer);
|
|
48
|
-
// eslint-disable-next-line no-empty
|
|
49
|
-
}
|
|
50
|
-
catch (e) { }
|
|
51
|
-
setTimer(setTimeout(function () {
|
|
52
|
-
handleStepDep(e.target.value);
|
|
53
|
-
setTimer(undefined);
|
|
54
|
-
}, 1000));
|
|
55
|
-
}
|
|
56
|
-
field.onChange(e);
|
|
57
|
-
}, [handleStepDep, isDependency, field.onChange]);
|
|
26
|
+
}), ref = _e.ref, value = _e.value, onChange = _e.onChange, error = _e.error, field = _e.field;
|
|
58
27
|
var canEdit = editable && !postview;
|
|
59
28
|
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
60
29
|
paddingBottom: step.required || step.description || !!error
|
|
61
30
|
? '0px'
|
|
62
31
|
: '5px',
|
|
63
|
-
} }, { children: [_jsx("div", __assign({ className: styles.erkTextArea }, { children: _jsx(RoundedTextField, __assign({}, field, { onChange: onChange, "data-testid": step.id, maxLength: maxLength, label: step.label,
|
|
32
|
+
} }, { children: [_jsx("div", __assign({ className: styles.erkTextArea }, { children: _jsx(RoundedTextField, __assign({}, field, { inputRef: ref, value: value, onChange: function (e) { return onChange(e.target.value); }, "data-testid": step.id, maxLength: maxLength, label: step.label, required: step.required, cantEdit: !canEdit, fontWeight: 400, multiline: true, minRows: postview && partial ? undefined : 4, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.stepBackgroundColor, helperTextColor: formStyle.descriptionTextColor, helperText: (_c = (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : step.description) !== null && _c !== void 0 ? _c : (step.required ? ' ' : null), error: !!error })) })), postview && (_jsxs("div", __assign({ className: styles.print }, { children: [_jsxs("div", { children: [step.label, ":"] }), _jsx("p", __assign({ className: styles.printContainer, style: {
|
|
64
33
|
backgroundColor: formStyle.stepBackgroundColor,
|
|
65
34
|
borderColor: formStyle.outlineColor,
|
|
66
|
-
} }, { children:
|
|
35
|
+
} }, { children: value }))] })))] })));
|
|
67
36
|
}
|
|
68
37
|
export default TextAreaStep;
|
|
@@ -9,70 +9,44 @@ 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
|
-
};
|
|
23
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
13
|
import RoundedTextField from '../../../Shared/RoundedTextField/RoundedTextField';
|
|
25
14
|
import styles from './MaterialTextInputStep.module.css';
|
|
26
|
-
import { useController } from 'react-hook-form';
|
|
27
15
|
import { calcStepWidth } from '../../StepFunctions';
|
|
28
|
-
import {
|
|
16
|
+
import { useContext } from 'react';
|
|
29
17
|
import FormContext from '../../../Contexts/FormContext';
|
|
30
18
|
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
31
|
-
import {
|
|
19
|
+
import { useFormStep } from '../../StepHooks';
|
|
32
20
|
function TextInputStep(_a) {
|
|
33
21
|
var _b;
|
|
34
22
|
var icon = _a.icon, step = _a.step, editable = _a.editable, maxLength = _a.maxLength, defaultValue = _a.defaultValue, _c = _a.validation, validation = _c === void 0 ? step.validation : _c;
|
|
35
23
|
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
36
24
|
var _d = useAppSelector(function (state) { return state.global; }), formStyle = _d.formStyle, postview = _d.postview;
|
|
37
25
|
var form = useContext(FormContext);
|
|
38
|
-
var _e =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
name: step.id,
|
|
42
|
-
shouldUnregister: true,
|
|
26
|
+
var _e = useFormStep(step, {
|
|
27
|
+
defaultValue: defaultValue,
|
|
28
|
+
debounce: true,
|
|
43
29
|
rules: {
|
|
44
30
|
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
45
31
|
pattern: validation
|
|
46
32
|
? {
|
|
47
|
-
value: new RegExp(validation.
|
|
33
|
+
value: new RegExp(validation.type === 'EMAIL'
|
|
34
|
+
? // eslint-disable-next-line no-control-regex
|
|
35
|
+
/^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/
|
|
36
|
+
: validation.value),
|
|
48
37
|
message: validation.message,
|
|
49
38
|
}
|
|
50
39
|
: undefined,
|
|
51
40
|
},
|
|
52
|
-
|
|
53
|
-
}), _h = _g.field, ref = _h.ref, field = __rest(_h, ["ref"]), error = _g.fieldState.error;
|
|
54
|
-
var onChange = useCallback(function (e) {
|
|
55
|
-
if (isDependency) {
|
|
56
|
-
try {
|
|
57
|
-
clearTimeout(timer);
|
|
58
|
-
// eslint-disable-next-line no-empty
|
|
59
|
-
}
|
|
60
|
-
catch (e) { }
|
|
61
|
-
setTimer(setTimeout(function () {
|
|
62
|
-
handleStepDep(e.target.value);
|
|
63
|
-
setTimer(undefined);
|
|
64
|
-
}, 1000));
|
|
65
|
-
}
|
|
66
|
-
field.onChange(e);
|
|
67
|
-
}, [handleStepDep, isDependency, field.onChange]);
|
|
41
|
+
}), ref = _e.ref, value = _e.value, onChange = _e.onChange, error = _e.error, field = _e.field;
|
|
68
42
|
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
69
43
|
width: currentBreakPoint <= step.size
|
|
70
44
|
? '100%'
|
|
71
45
|
: calcStepWidth(step.size, form.size),
|
|
72
|
-
minHeight:
|
|
73
|
-
step.
|
|
46
|
+
minHeight: step.description ||
|
|
47
|
+
(!postview && editable && (step.required || validation))
|
|
74
48
|
? '55px'
|
|
75
49
|
: '43px',
|
|
76
|
-
} }, { children: _jsx(RoundedTextField, __assign({}, field, { onChange: onChange, maxLength: maxLength, "data-testid": step.id, label: step.label,
|
|
50
|
+
} }, { children: _jsx(RoundedTextField, __assign({}, field, { inputRef: ref, value: value, onChange: function (e) { return onChange(e.target.value); }, maxLength: maxLength, "data-testid": step.id, label: step.label, cantEdit: !editable || postview, required: step.required, fontWeight: 400, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.stepBackgroundColor, helperText: (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : step.description, helperTextColor: formStyle.descriptionTextColor, error: !!error, icon: step.showIcon ? icon : undefined })) })));
|
|
77
51
|
}
|
|
78
52
|
export default TextInputStep;
|
|
@@ -9,32 +9,20 @@ 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
|
-
};
|
|
23
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import { Controller } from 'react-hook-form';
|
|
25
13
|
import { calcStepWidth } from '../../StepFunctions';
|
|
26
14
|
import styles from './MaterialTitleStep.module.css';
|
|
27
15
|
import { useAppSelector } from '../../../hooks';
|
|
28
16
|
import FormContext from '../../../Contexts/FormContext';
|
|
29
17
|
import { useContext } from 'react';
|
|
30
|
-
import {
|
|
31
|
-
function
|
|
18
|
+
import { useFormStep } from '../../StepHooks';
|
|
19
|
+
function TitleStep(_a) {
|
|
32
20
|
var _b;
|
|
33
|
-
var step = _a.step
|
|
21
|
+
var step = _a.step;
|
|
22
|
+
var _c = useFormStep(step).value, title = _c.title, description = _c.description;
|
|
34
23
|
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
35
24
|
var form = useContext(FormContext);
|
|
36
25
|
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
37
|
-
var _c = value !== null && value !== void 0 ? value : {}, title = _c.title, description = _c.description;
|
|
38
26
|
var size = (_b = step.size) !== null && _b !== void 0 ? _b : form.size.blockNum;
|
|
39
27
|
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
40
28
|
color: formStyle.textColor,
|
|
@@ -50,12 +38,4 @@ function Title(_a) {
|
|
|
50
38
|
margin: title ? '10px 0px' : '0px 0px 5px 0px',
|
|
51
39
|
} }, { children: description })))] })));
|
|
52
40
|
}
|
|
53
|
-
function TitleStep(props) {
|
|
54
|
-
var step = props.step;
|
|
55
|
-
var originalValue = useStepDependency(step).originalValue;
|
|
56
|
-
return (_jsx(Controller, { name: step.id, defaultValue: originalValue, render: function (_a) {
|
|
57
|
-
var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
|
|
58
|
-
return (_jsx(Title, __assign({}, props, field, { inputRef: ref })));
|
|
59
|
-
} }));
|
|
60
|
-
}
|
|
61
41
|
export default TitleStep;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FillerSteps } from '../../StepFunctions';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const SizeChangeContext: React.Context<(() => void) | undefined>;
|
|
4
|
+
export interface StepFillerContainerProps {
|
|
5
|
+
step: FillerSteps;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare function StepFillerContainer({ step, children, }: StepFillerContainerProps): JSX.Element;
|
|
9
|
+
export default StepFillerContainer;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { createContext, useCallback, useContext, useState } from 'react';
|
|
14
|
+
import { useFormContext } from 'react-hook-form';
|
|
15
|
+
import { calcFillerSize } from '../../StepFunctions';
|
|
16
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
17
|
+
import styles from './StepFiller.module.css';
|
|
18
|
+
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
19
|
+
export var SizeChangeContext = createContext(undefined);
|
|
20
|
+
function StepFiller(_a) {
|
|
21
|
+
var step = _a.step, children = _a.children;
|
|
22
|
+
var getValues = useFormContext().getValues;
|
|
23
|
+
var form = useContext(FormContext);
|
|
24
|
+
var _b = useState(calcFillerSize(step, form.steps, getValues(), form.size)), fillerSize = _b[0], setFillerSize = _b[1];
|
|
25
|
+
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
26
|
+
var handleSizeChange = useCallback(function () {
|
|
27
|
+
setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
|
|
28
|
+
}, []);
|
|
29
|
+
if (step.maxSize && step.maxSize < form.size.blockNum) {
|
|
30
|
+
return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
|
|
31
|
+
width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
|
|
32
|
+
} }, { children: [_jsx(SizeChangeContext.Provider, __assign({ value: handleSizeChange }, { children: children })), _jsx("div", { className: styles.smallSeparator, style: {
|
|
33
|
+
width: fillerSize,
|
|
34
|
+
} })] })));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return (_jsxs(SizeChangeContext.Provider, __assign({ value: handleSizeChange }, { children: [children, step.maxSize && _jsx("div", { className: styles.separator })] })));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function StepFillerContainer(_a) {
|
|
41
|
+
var step = _a.step, children = _a.children;
|
|
42
|
+
var handleSizeChange = useContext(SizeChangeContext);
|
|
43
|
+
if (handleSizeChange)
|
|
44
|
+
return _jsx(_Fragment, { children: children });
|
|
45
|
+
else
|
|
46
|
+
return _jsx(StepFiller, { step: step, children: children });
|
|
47
|
+
}
|
|
48
|
+
export default StepFillerContainer;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
.firstLvlContainer {
|
|
2
|
+
max-width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-flow: row wrap;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.smallSeparator {
|
|
8
|
+
height: 0;
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
flex-basis: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.separator {
|
|
14
|
+
flex-basis: 100%;
|
|
15
|
+
height: 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { GSmartSelect } from '../../../@Types/GenericFormSteps';
|
|
3
|
+
import { CheckBox, DatePicker, ClassifierSelector, FormSelector } from '../../../@Types/FormStep';
|
|
4
|
+
interface MaterialInputProps {
|
|
5
|
+
step: GSmartSelect | CheckBox | ClassifierSelector | DatePicker | FormSelector;
|
|
6
|
+
editable: boolean;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare function MaterialInputContainer({ step, editable, children, onClick, }: MaterialInputProps): JSX.Element;
|
|
11
|
+
export default MaterialInputContainer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useContext } from 'react';
|
|
14
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
15
|
+
import { useAppSelector, selectBreakPoint } from '../../../hooks';
|
|
16
|
+
import { calcStepWidth } from '../../StepFunctions';
|
|
17
|
+
import styles from './MaterialInputContainer.module.css';
|
|
18
|
+
function MaterialInputContainer(_a) {
|
|
19
|
+
var step = _a.step, editable = _a.editable, children = _a.children, onClick = _a.onClick;
|
|
20
|
+
var form = useContext(FormContext);
|
|
21
|
+
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
22
|
+
var postview = useAppSelector(function (state) { return state.global.postview; });
|
|
23
|
+
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
24
|
+
width: currentBreakPoint <= step.size
|
|
25
|
+
? '100%'
|
|
26
|
+
: calcStepWidth(step.size, form.size),
|
|
27
|
+
minHeight: step.description || (!postview && editable && step.required)
|
|
28
|
+
? '55px'
|
|
29
|
+
: '43px',
|
|
30
|
+
}, onClick: onClick, "data-testid": step.id }, { children: children })));
|
|
31
|
+
}
|
|
32
|
+
export default MaterialInputContainer;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
width: fit-content;
|
|
3
|
-
max-width: calc(100% - 20px);
|
|
4
|
-
display: flex;
|
|
5
|
-
padding: 10px;
|
|
6
|
-
padding-bottom: 0px;
|
|
7
|
-
padding-top: 5px;
|
|
8
|
-
margin-bottom: 0px;
|
|
9
|
-
}
|
|
1
|
+
.container {
|
|
2
|
+
width: fit-content;
|
|
3
|
+
max-width: calc(100% - 20px);
|
|
4
|
+
display: flex;
|
|
5
|
+
padding: 10px;
|
|
6
|
+
padding-bottom: 0px;
|
|
7
|
+
padding-top: 5px;
|
|
8
|
+
margin-bottom: 0px;
|
|
9
|
+
}
|
|
@@ -11,14 +11,14 @@ interface StyleProps {
|
|
|
11
11
|
size?: number | string;
|
|
12
12
|
cantEdit?: boolean;
|
|
13
13
|
}
|
|
14
|
-
interface ComponentProps extends StyleProps {
|
|
15
|
-
onChange?:
|
|
14
|
+
interface ComponentProps extends StyleProps, Omit<CheckboxProps, 'size' | 'onChange'> {
|
|
15
|
+
onChange?: (checked: boolean) => void;
|
|
16
16
|
checked: boolean;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Generic datepicker with apps designs. Is class do to the use in the react-hook-forms library
|
|
20
20
|
*/
|
|
21
|
-
declare class RoundedCheckBox extends React.Component<ComponentProps
|
|
21
|
+
declare class RoundedCheckBox extends React.Component<ComponentProps> {
|
|
22
22
|
render(): JSX.Element;
|
|
23
23
|
}
|
|
24
24
|
export default RoundedCheckBox;
|
|
@@ -38,10 +38,7 @@ export interface RoundedSmartSelectProps extends Omit<TextFieldProps, 'color' |
|
|
|
38
38
|
/** If the input is loading */
|
|
39
39
|
loading?: boolean;
|
|
40
40
|
/** function called when value changes */
|
|
41
|
-
handleUpdate?: (
|
|
42
|
-
name?: string | undefined;
|
|
43
|
-
value: any;
|
|
44
|
-
}> | string, child?: React.ReactNode) => void;
|
|
41
|
+
handleUpdate?: (value: any) => void;
|
|
45
42
|
/** Strig to place in the label */
|
|
46
43
|
label: string;
|
|
47
44
|
/** Minimum width in px of the component */
|
|
@@ -218,10 +218,8 @@ export default function RoundedSmartSelect(_a) {
|
|
|
218
218
|
else {
|
|
219
219
|
return (_jsxs(RoundedSelect, __assign({ onBlur: onBlur, onFocus: onFocus, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: function (event) {
|
|
220
220
|
handleUpdate === null || handleUpdate === void 0 ? void 0 : handleUpdate(options === null || options === void 0 ? void 0 : options.find(function (option) {
|
|
221
|
-
return getValueString(option)
|
|
221
|
+
return getValueString(option) === event.target.value;
|
|
222
222
|
}));
|
|
223
|
-
}, onOpen: function () {
|
|
224
|
-
//Show loading icon if loading
|
|
225
223
|
}, value: loading ? '' : getValueString(value), color: color, errorColor: errorColor, focusColor: focusColor, helperTextColor: helperTextColor, backgroundColor: backgroundColor, outlineColor: outlineColor, cantEdit: cantEdit, disabled: cantEdit || disabled, label: label, required: required, readOnly: readOnly, helperText: hidden ? undefined : helperText, containerMargin: containerMargin, height: height, fontSize: fontSize, error: !hidden && error, iconComponent: loading
|
|
226
224
|
? function () { return (_jsx("div", __assign({ style: {
|
|
227
225
|
marginTop: 3,
|
|
@@ -25,6 +25,7 @@ export declare const SiteSlice: import("@reduxjs/toolkit").Slice<SiteState, {
|
|
|
25
25
|
};
|
|
26
26
|
type: string;
|
|
27
27
|
}) => void;
|
|
28
|
+
clearDependency: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload: { id, idSection } }: PayloadAction<GBaseStep>) => void;
|
|
28
29
|
setEmptyDependency: (state: import("immer/dist/internal").WritableDraft<SiteState>, { payload: { step: { id }, empty, }, }: {
|
|
29
30
|
payload: {
|
|
30
31
|
step: GBaseStep;
|
|
@@ -50,7 +51,7 @@ export declare const SiteSlice: import("@reduxjs/toolkit").Slice<SiteState, {
|
|
|
50
51
|
export declare const focusStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{
|
|
51
52
|
step: FormStep;
|
|
52
53
|
values: FieldValues;
|
|
53
|
-
} | undefined, "site/focusStep">, setStepDependency: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
54
|
+
} | undefined, "site/focusStep">, clearDependency: import("@reduxjs/toolkit").ActionCreatorWithPayload<GBaseStep, "site/clearDependency">, setStepDependency: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
54
55
|
step: GBaseStep;
|
|
55
56
|
value: StepDependency['value'];
|
|
56
57
|
}, "site/setStepDependency">, addStepsDependencies: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
package/dist/States/SiteSlice.js
CHANGED
|
@@ -33,11 +33,30 @@ export var SiteSlice = createSlice({
|
|
|
33
33
|
var old = state.dependencies[id];
|
|
34
34
|
if (old && (old.type !== type || old.value !== value)) {
|
|
35
35
|
state.dependencies[id] = __assign(__assign({}, state.dependencies[id]), { type: type, value: value });
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
dependent.idSection !== idSection) {
|
|
40
|
-
|
|
36
|
+
if (state.idCurrentSection !== null) {
|
|
37
|
+
for (var _i = 0, _d = old.dependents; _i < _d.length; _i++) {
|
|
38
|
+
var dependent = _d[_i];
|
|
39
|
+
if (dependent.idSection !== idSection) {
|
|
40
|
+
state.values.sections[dependent.idSection][dependent.id] = calcDefaultValue(dependent);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
clearDependency: function (state, _a) {
|
|
47
|
+
var _b = _a.payload, id = _b.id, idSection = _b.idSection;
|
|
48
|
+
if (state.idCurrentSection === null ||
|
|
49
|
+
state.idCurrentSection === idSection) {
|
|
50
|
+
var old = state.dependencies[id];
|
|
51
|
+
if (old && old.value !== null) {
|
|
52
|
+
state.dependencies[id] = __assign(__assign({}, state.dependencies[id]), { value: null, empty: false });
|
|
53
|
+
if (state.idCurrentSection !== null) {
|
|
54
|
+
for (var _i = 0, _c = old.dependents; _i < _c.length; _i++) {
|
|
55
|
+
var dependent = _c[_i];
|
|
56
|
+
if (dependent.idSection !== idSection) {
|
|
57
|
+
state.values.sections[dependent.idSection][dependent.id] = calcDefaultValue(dependent);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
41
60
|
}
|
|
42
61
|
}
|
|
43
62
|
}
|
|
@@ -106,5 +125,5 @@ export var SiteSlice = createSlice({
|
|
|
106
125
|
});
|
|
107
126
|
},
|
|
108
127
|
});
|
|
109
|
-
export var focusStep = (_a = SiteSlice.actions, _a.focusStep), setStepDependency = _a.setStepDependency, addStepsDependencies = _a.addStepsDependencies, setEmptyDependency = _a.setEmptyDependency, handlePrevious = _a.handlePrevious, handleNext = _a.handleNext;
|
|
128
|
+
export var focusStep = (_a = SiteSlice.actions, _a.focusStep), clearDependency = _a.clearDependency, setStepDependency = _a.setStepDependency, addStepsDependencies = _a.addStepsDependencies, setEmptyDependency = _a.setEmptyDependency, handlePrevious = _a.handlePrevious, handleNext = _a.handleNext;
|
|
110
129
|
export default SiteSlice;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TypedUseSelectorHook } from 'react-redux';
|
|
2
2
|
import { type RootState, type AppDispatch } from './Utils/store';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export declare const StoreContext: React.Context<any>;
|
|
3
5
|
export declare const useAppDispatch: () => AppDispatch;
|
|
4
6
|
export declare const useAppSelector: TypedUseSelectorHook<RootState>;
|
|
5
7
|
export declare const selectBreakPoint: (state: RootState) => number;
|
package/dist/hooks.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDispatchHook, createSelectorHook } from 'react-redux';
|
|
2
2
|
import { defaultRootState, } from './Utils/store';
|
|
3
3
|
import { useContext } from 'react';
|
|
4
4
|
import { IdFormContext } from './App/App';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export var StoreContext = React.createContext({});
|
|
7
|
+
var useSelector = createSelectorHook(StoreContext);
|
|
8
|
+
var useDispatch = createDispatchHook(StoreContext);
|
|
5
9
|
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
|
6
10
|
export var useAppDispatch = function () {
|
|
7
11
|
var idForm = useContext(IdFormContext);
|
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.
|
|
4
|
+
"version": "2.0.21",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "react-scripts test",
|
|
10
10
|
"test-ci": "react-scripts test --reporters=default --reporters=jest-junit --coverage --coverageReporters cobertura html",
|
|
11
11
|
"tsc-build": "tsc --noEmit false --outDir ./dist --incremental false",
|
|
12
|
-
"watch": "tsc -w --preserveWatchOutput",
|
|
12
|
+
"watch": "tsc -w --noEmit false --outDir ./dist --preserveWatchOutput",
|
|
13
13
|
"storybook": "storybook dev -p 6006",
|
|
14
14
|
"build-storybook": "storybook build",
|
|
15
15
|
"cypress": "DISPLAY=:0 cypress open"
|