@arquimedes.co/eureka-forms 2.0.27 → 2.0.29
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/Form/FormTypes/ColumnForm/ColumnForm.js +2 -9
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.module.css +0 -28
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +11 -18
- package/dist/Form/FormTypes/StepperForm/StepperForm.module.css +0 -27
- package/dist/Shared/CustomBtn/CustomBtn.d.ts +13 -0
- package/dist/Shared/CustomBtn/CustomBtn.js +96 -0
- package/dist/Shared/CustomBtn/CustomBtn.module.css +61 -0
- package/package.json +1 -1
|
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
49
|
import { useCallback, useContext, useState } from 'react';
|
|
50
50
|
import styles from './ColumnForm.module.css';
|
|
51
|
-
import Loader from '../../../Shared/Loader/Loader';
|
|
52
51
|
import React from 'react';
|
|
53
52
|
import Terms from '../../Terms/Terms';
|
|
54
53
|
import { useFormContext } from 'react-hook-form';
|
|
55
54
|
import { useAppSelector } from '../../../hooks';
|
|
56
55
|
import Section from '../../Section/Section';
|
|
57
56
|
import CustomContext from '../../../Contexts/CustomContext';
|
|
57
|
+
import CustomBtn from '../../../Shared/CustomBtn/CustomBtn';
|
|
58
58
|
function ColumnForm(_a) {
|
|
59
59
|
var _this = this;
|
|
60
60
|
var onSubmit = _a.onSubmit, customSubmitBtns = _a.customSubmitBtns;
|
|
@@ -90,13 +90,6 @@ function ColumnForm(_a) {
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
}); }, []);
|
|
93
|
-
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [!customSubmitBtns && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children:
|
|
94
|
-
background: formStyle.primaryColor,
|
|
95
|
-
color: formStyle.primaryContrastColor,
|
|
96
|
-
}, disabled: loading }, { children: [_jsx("div", __assign({ style: {
|
|
97
|
-
visibility: loading
|
|
98
|
-
? 'hidden'
|
|
99
|
-
: 'visible',
|
|
100
|
-
} }, { children: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
|
|
93
|
+
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [!customSubmitBtns && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsx(CustomBtn, { onClick: submit, width: "calc(100% - 70px)", label: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
|
|
101
94
|
}
|
|
102
95
|
export default ColumnForm;
|
|
@@ -17,31 +17,3 @@
|
|
|
17
17
|
width: 200px;
|
|
18
18
|
max-width: calc(100% - 40px);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
.submitBtn {
|
|
22
|
-
border-radius: 20px;
|
|
23
|
-
padding: 15px 10px;
|
|
24
|
-
width: calc(100% - 30px);
|
|
25
|
-
margin: 0 auto 0 auto;
|
|
26
|
-
font-size: 1.4rem;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
-moz-user-select: none;
|
|
29
|
-
-khtml-user-select: none;
|
|
30
|
-
-webkit-user-select: none;
|
|
31
|
-
-ms-user-select: none;
|
|
32
|
-
user-select: none;
|
|
33
|
-
border: none;
|
|
34
|
-
position: relative;
|
|
35
|
-
}
|
|
36
|
-
.submitBtn[disabled] {
|
|
37
|
-
pointer-events: none;
|
|
38
|
-
opacity: 0.5;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.loaderContainer {
|
|
42
|
-
top: 0px;
|
|
43
|
-
bottom: 0px;
|
|
44
|
-
right: 0px;
|
|
45
|
-
left: 0px;
|
|
46
|
-
position: absolute;
|
|
47
|
-
}
|
|
@@ -48,7 +48,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
49
|
import { useCallback, useContext, useState } from 'react';
|
|
50
50
|
import styles from './StepperForm.module.css';
|
|
51
|
-
import Loader from '../../../Shared/Loader/Loader';
|
|
52
51
|
import Terms from '../../Terms/Terms';
|
|
53
52
|
import { useFormContext } from 'react-hook-form';
|
|
54
53
|
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
|
@@ -57,6 +56,7 @@ import CustomContext from '../../../Contexts/CustomContext';
|
|
|
57
56
|
import * as SiteReducer from '../../../States/SiteSlice';
|
|
58
57
|
import { getAppState } from '../../../Utils/store';
|
|
59
58
|
import { IdFormContext } from '../../../App/App';
|
|
59
|
+
import CustomBtn from '../../../Shared/CustomBtn/CustomBtn';
|
|
60
60
|
function StepperForm(_a) {
|
|
61
61
|
var _this = this;
|
|
62
62
|
var onSubmit = _a.onSubmit, scrollToTop = _a.scrollToTop;
|
|
@@ -73,10 +73,13 @@ function StepperForm(_a) {
|
|
|
73
73
|
var handleErrors = handleSubmit(function () { }, function (errors) {
|
|
74
74
|
console.error('Errors:', errors);
|
|
75
75
|
});
|
|
76
|
-
var handlePrevious = useCallback(function () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
var handlePrevious = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
dispatch(SiteReducer.handlePrevious(getValues()));
|
|
79
|
+
scrollToTop === null || scrollToTop === void 0 ? void 0 : scrollToTop();
|
|
80
|
+
return [2 /*return*/];
|
|
81
|
+
});
|
|
82
|
+
}); }, []);
|
|
80
83
|
var handleNext = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
81
84
|
var valid, state, values, response;
|
|
82
85
|
return __generator(this, function (_a) {
|
|
@@ -112,18 +115,8 @@ function StepperForm(_a) {
|
|
|
112
115
|
}); }, [next]);
|
|
113
116
|
if (!idCurrent)
|
|
114
117
|
return _jsx(_Fragment, {});
|
|
115
|
-
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), _jsx(Section, { idSection: idCurrent }, idCurrent), next.length === 0 && _jsx(Terms, {}), _jsxs("div", __assign({ className: styles.btnsContainer }, { children: [previous.length > 0 && (
|
|
116
|
-
|
|
117
|
-
color: formStyle.primaryContrastColor,
|
|
118
|
-
}, disabled: !!loading }, { children: [_jsx("div", __assign({ style: {
|
|
119
|
-
visibility: loading === 'BACK' ? 'hidden' : 'visible',
|
|
120
|
-
} }, { children: "Volver" })), loading === 'BACK' && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] }))), (next.length > 0 || (!postview && editable)) && (_jsxs("button", __assign({ "data-testid": "form__submit", className: styles.formBtn, onClick: handleNext, style: {
|
|
121
|
-
background: formStyle.primaryColor,
|
|
122
|
-
color: formStyle.primaryContrastColor,
|
|
123
|
-
}, disabled: !!loading }, { children: [_jsx("div", __assign({ style: {
|
|
124
|
-
visibility: loading === 'NEXT' ? 'hidden' : 'visible',
|
|
125
|
-
} }, { children: next.length > 0
|
|
126
|
-
? 'Siguiente'
|
|
127
|
-
: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading === 'NEXT' && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })))] }))] })));
|
|
118
|
+
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), _jsx(Section, { idSection: idCurrent }, idCurrent), next.length === 0 && _jsx(Terms, {}), _jsxs("div", __assign({ className: styles.btnsContainer }, { children: [previous.length > 0 && (_jsx(CustomBtn, { label: "Volver", "data-testid": "form__back", onClick: handlePrevious, backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, disabled: !!loading, loading: loading === 'BACK' })), (next.length > 0 || (!postview && editable)) && (_jsx(CustomBtn, { label: next.length > 0
|
|
119
|
+
? 'Siguiente'
|
|
120
|
+
: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar', "data-testid": "form__submit", onClick: handleNext, backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, disabled: !!loading, loading: loading === 'NEXT' }))] }))] })));
|
|
128
121
|
}
|
|
129
122
|
export default StepperForm;
|
|
@@ -24,30 +24,3 @@
|
|
|
24
24
|
justify-content: center;
|
|
25
25
|
gap: 10px 20px;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
.formBtn {
|
|
29
|
-
max-width: 100%;
|
|
30
|
-
border-radius: 20px;
|
|
31
|
-
padding: 15px 20px;
|
|
32
|
-
font-size: 1.4rem;
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
-moz-user-select: none;
|
|
35
|
-
-khtml-user-select: none;
|
|
36
|
-
-webkit-user-select: none;
|
|
37
|
-
-ms-user-select: none;
|
|
38
|
-
user-select: none;
|
|
39
|
-
border: none;
|
|
40
|
-
position: relative;
|
|
41
|
-
}
|
|
42
|
-
.formBtn[disabled] {
|
|
43
|
-
pointer-events: none;
|
|
44
|
-
opacity: 0.5;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.loaderContainer {
|
|
48
|
-
top: 0px;
|
|
49
|
-
bottom: 0px;
|
|
50
|
-
right: 0px;
|
|
51
|
-
left: 0px;
|
|
52
|
-
position: absolute;
|
|
53
|
-
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface CustomBtnProps {
|
|
3
|
+
label: string;
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
width?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function CustomBtn({ label, onClick, backgroundColor, color, loading, disabled, width, ...others }: CustomBtnProps): JSX.Element;
|
|
13
|
+
export default CustomBtn;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
59
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
60
|
+
import { useEffect, useState } from 'react';
|
|
61
|
+
import styles from './CustomBtn.module.css';
|
|
62
|
+
import Loader from '../Loader/Loader';
|
|
63
|
+
function CustomBtn(_a) {
|
|
64
|
+
var _this = this;
|
|
65
|
+
var label = _a.label, onClick = _a.onClick, backgroundColor = _a.backgroundColor, color = _a.color, _b = _a.loading, loading = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.width, width = _d === void 0 ? 'fit-content' : _d, others = __rest(_a, ["label", "onClick", "backgroundColor", "color", "loading", "disabled", "width"]);
|
|
66
|
+
var _e = useState(undefined), coords = _e[0], setCoords = _e[1];
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
if (coords)
|
|
69
|
+
setCoords(undefined);
|
|
70
|
+
}, [label]);
|
|
71
|
+
return (_jsxs("button", __assign({ className: styles.customBtn, style: {
|
|
72
|
+
width: width,
|
|
73
|
+
background: backgroundColor,
|
|
74
|
+
color: color,
|
|
75
|
+
}, "data-testid": others['data-testid'], disabled: disabled || loading, onClick: function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
+
var rect;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
rect = e.target.getBoundingClientRect();
|
|
79
|
+
setCoords({
|
|
80
|
+
x: e.clientX - rect.left,
|
|
81
|
+
y: e.clientY - rect.top,
|
|
82
|
+
});
|
|
83
|
+
setTimeout(function () { return setCoords(undefined); }, 600);
|
|
84
|
+
onClick && onClick(e);
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
});
|
|
87
|
+
}); } }, { children: [coords ? (_jsx("span", { className: styles.ripple, style: {
|
|
88
|
+
backgroundColor: color,
|
|
89
|
+
left: coords.x,
|
|
90
|
+
top: coords.y,
|
|
91
|
+
} })) : (_jsx(_Fragment, {})), _jsx("div", __assign({ style: {
|
|
92
|
+
visibility: loading ? 'hidden' : 'visible',
|
|
93
|
+
margin: '0px 10px',
|
|
94
|
+
} }, { children: label })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: color, position: "unset" }) })))] })));
|
|
95
|
+
}
|
|
96
|
+
export default CustomBtn;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.customBtn {
|
|
2
|
+
max-width: 100%;
|
|
3
|
+
border-radius: 20px;
|
|
4
|
+
padding: 15px 30px;
|
|
5
|
+
font-size: 1.4rem;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
-moz-user-select: none;
|
|
8
|
+
-khtml-user-select: none;
|
|
9
|
+
-webkit-user-select: none;
|
|
10
|
+
-ms-user-select: none;
|
|
11
|
+
user-select: none;
|
|
12
|
+
border: none;
|
|
13
|
+
position: relative;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.customBtn[disabled] {
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ripple {
|
|
26
|
+
width: 50px;
|
|
27
|
+
height: 50px;
|
|
28
|
+
position: absolute;
|
|
29
|
+
display: block;
|
|
30
|
+
content: '';
|
|
31
|
+
border-radius: 9999px;
|
|
32
|
+
opacity: 1;
|
|
33
|
+
animation: 1s ease 1 forwards ripple-effect;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@keyframes ripple-effect {
|
|
37
|
+
0% {
|
|
38
|
+
transform: scale(1);
|
|
39
|
+
opacity: 0.6;
|
|
40
|
+
}
|
|
41
|
+
50% {
|
|
42
|
+
transform: scale(10);
|
|
43
|
+
opacity: 0.1;
|
|
44
|
+
}
|
|
45
|
+
60% {
|
|
46
|
+
transform: scale(35);
|
|
47
|
+
opacity: 0;
|
|
48
|
+
}
|
|
49
|
+
100% {
|
|
50
|
+
transform: scale(35);
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.loaderContainer {
|
|
56
|
+
top: 0px;
|
|
57
|
+
bottom: 0px;
|
|
58
|
+
right: 0px;
|
|
59
|
+
left: 0px;
|
|
60
|
+
position: absolute;
|
|
61
|
+
}
|