@arquimedes.co/eureka-forms 1.9.23-test → 1.9.25-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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Form } from '../../../@Types/Form';
|
|
2
3
|
import { FormComponentProps } from '../Form';
|
|
3
|
-
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, sendLabel, widthStats, customSteps, customSend,
|
|
4
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, sendLabel, widthStats, customSteps, customSend, customForm, handleLoaded, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
4
5
|
export default ColumnForm;
|
|
6
|
+
export declare const mapOriginalValues: (originalValues: Record<string, any>, form: Form) => any;
|
|
@@ -72,18 +72,19 @@ import widgetInstance from '../../../AxiosWidget';
|
|
|
72
72
|
import React from 'react';
|
|
73
73
|
function ColumnForm(_a) {
|
|
74
74
|
var _this = this;
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var _c = useState(
|
|
78
|
-
var _d =
|
|
75
|
+
var _b;
|
|
76
|
+
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, sendLabel = _a.sendLabel, widthStats = _a.widthStats, customSteps = _a.customSteps, customSend = _a.customSend, customForm = _a.customForm, handleLoaded = _a.handleLoaded, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "sendLabel", "widthStats", "customSteps", "customSend", "customForm", "handleLoaded", "originalValues"]);
|
|
77
|
+
var _c = useState(false), tempError = _c[0], setTempError = _c[1];
|
|
78
|
+
var _d = useState(calcDependencies(form.steps, originalValues)), dependencyStore = _d[0], setDependencyStore = _d[1];
|
|
79
|
+
var _e = (_b = customForm === null || customForm === void 0 ? void 0 : customForm.form) !== null && _b !== void 0 ? _b : useForm({
|
|
79
80
|
defaultValues: mapOriginalValues(originalValues, form),
|
|
80
81
|
mode: 'onTouched',
|
|
81
82
|
shouldFocusError: true,
|
|
82
|
-
}), getValues =
|
|
83
|
+
}), getValues = _e.getValues, setValue = _e.setValue, clearErrors = _e.clearErrors, control = _e.control, errors = _e.formState.errors, trigger = _e.trigger;
|
|
83
84
|
var recaptchaRef = useRef();
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
85
|
+
var _f = useState(undefined), sections = _f[0], setSections = _f[1];
|
|
86
|
+
var _g = useState(false), loading = _g[0], setLoading = _g[1];
|
|
87
|
+
var _h = useState(), showConfirmation = _h[0], setShowConfirmation = _h[1];
|
|
87
88
|
useEffect(function () {
|
|
88
89
|
var tempSections = [];
|
|
89
90
|
calcNextSection(form, form.firstSection, tempSections);
|
|
@@ -163,7 +164,7 @@ function ColumnForm(_a) {
|
|
|
163
164
|
(originalValues === null || originalValues === void 0 ? void 0 : originalValues['INTERNAL_CREATING_AGENT']) === undefined && (_jsx("div", __assign({ className: styles.termsContainer, style: {
|
|
164
165
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
165
166
|
form.size.blockNum,
|
|
166
|
-
} }, { children: form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }) }))), !postview && others.editable && (_jsxs(React.Fragment, { children: [form.hasCaptcha && !internal && (_jsx(ReCAPTCHA, { ref: recaptchaRef, sitekey: "6LcL22kkAAAAAEotDeAFbRATob-u5vbibbCyWL2p", size: 'invisible', badge: 'bottomright' })), !
|
|
167
|
+
} }, { children: form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }) }))), !postview && others.editable && (_jsxs(React.Fragment, { children: [form.hasCaptcha && !internal && (_jsx(ReCAPTCHA, { ref: recaptchaRef, sitekey: "6LcL22kkAAAAAEotDeAFbRATob-u5vbibbCyWL2p", size: 'invisible', badge: 'bottomright' })), !(customForm === null || customForm === void 0 ? void 0 : customForm.submit) && (_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 () {
|
|
167
168
|
var valid, captcha;
|
|
168
169
|
return __generator(this, function (_a) {
|
|
169
170
|
switch (_a.label) {
|
|
@@ -199,8 +200,8 @@ function ColumnForm(_a) {
|
|
|
199
200
|
visibility: loading
|
|
200
201
|
? 'hidden'
|
|
201
202
|
: 'visible',
|
|
202
|
-
} }, { children: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))),
|
|
203
|
-
cloneElement(
|
|
203
|
+
} }, { children: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))), (customForm === null || customForm === void 0 ? void 0 : customForm.submit) &&
|
|
204
|
+
cloneElement(customForm === null || customForm === void 0 ? void 0 : customForm.submit, {
|
|
204
205
|
onSubmit: onSubmit,
|
|
205
206
|
loading: loading,
|
|
206
207
|
})] }))] })));
|
|
@@ -218,7 +219,7 @@ function calcNextSection(form, idSection, sections) {
|
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
var mapOriginalValues = function (originalValues, form) {
|
|
222
|
+
export var mapOriginalValues = function (originalValues, form) {
|
|
222
223
|
var _a;
|
|
223
224
|
var newValues = __assign({}, originalValues);
|
|
224
225
|
var _loop_1 = function (val) {
|
|
@@ -14,7 +14,10 @@ export interface FormComponentProps {
|
|
|
14
14
|
originalValues: Record<string, unknown>;
|
|
15
15
|
customSteps: Record<string, CustomStep>;
|
|
16
16
|
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
17
|
-
|
|
17
|
+
customForm?: {
|
|
18
|
+
form?: any;
|
|
19
|
+
submit?: JSX.Element;
|
|
20
|
+
};
|
|
18
21
|
widthStats: WidthStats;
|
|
19
22
|
internal: boolean;
|
|
20
23
|
reload: Function;
|
package/dist/index.lib.d.ts
CHANGED
package/dist/index.lib.js
CHANGED
package/package.json
CHANGED