datastake-daf 0.6.565 → 0.6.566
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/components/index.js
CHANGED
|
@@ -40514,6 +40514,9 @@ function AuthForm(_ref) {
|
|
|
40514
40514
|
const [currentStep, setCurrentStep] = React.useState(0);
|
|
40515
40515
|
const [allFormValues, setAllFormValues] = React.useState(initialValues);
|
|
40516
40516
|
const [formErrors, setFormErrors] = React.useState(null);
|
|
40517
|
+
console.log({
|
|
40518
|
+
errors
|
|
40519
|
+
});
|
|
40517
40520
|
const isMultiStep = !!steps;
|
|
40518
40521
|
const currentFields = isMultiStep ? steps === null || steps === void 0 || (_steps$currentStep = steps[currentStep]) === null || _steps$currentStep === void 0 ? void 0 : _steps$currentStep.fields : fields || [];
|
|
40519
40522
|
React.useEffect(() => {
|
|
@@ -40542,16 +40545,21 @@ function AuthForm(_ref) {
|
|
|
40542
40545
|
};
|
|
40543
40546
|
const prev = () => setCurrentStep(prev => prev - 1);
|
|
40544
40547
|
const handleSubmit = async values => {
|
|
40545
|
-
|
|
40546
|
-
|
|
40547
|
-
|
|
40548
|
-
|
|
40548
|
+
try {
|
|
40549
|
+
await formInstance.validateFields();
|
|
40550
|
+
const token = await handleReCaptchaVerify();
|
|
40551
|
+
if (!token) {
|
|
40552
|
+
console.error('reCAPTCHA verification failed');
|
|
40553
|
+
return;
|
|
40554
|
+
}
|
|
40555
|
+
setFormErrors(null);
|
|
40556
|
+
if (!isMultiStep) return onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(values);
|
|
40557
|
+
if (currentStep < (steps === null || steps === void 0 ? void 0 : steps.length) - 1) return next();
|
|
40558
|
+
const finalValues = _objectSpread2(_objectSpread2({}, allFormValues), values);
|
|
40559
|
+
onSubmit === null || onSubmit === void 0 || onSubmit(finalValues);
|
|
40560
|
+
} catch (err) {
|
|
40561
|
+
console.error("Validation failed:", err);
|
|
40549
40562
|
}
|
|
40550
|
-
setFormErrors(null);
|
|
40551
|
-
if (!isMultiStep) return onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(values);
|
|
40552
|
-
if (currentStep < (steps === null || steps === void 0 ? void 0 : steps.length) - 1) return next();
|
|
40553
|
-
const finalValues = _objectSpread2(_objectSpread2({}, allFormValues), values);
|
|
40554
|
-
onSubmit === null || onSubmit === void 0 || onSubmit(finalValues);
|
|
40555
40563
|
};
|
|
40556
40564
|
const checkRequiredFieldsFilled = (changedValues, allValues) => {
|
|
40557
40565
|
const requiredFields = currentFields.filter(f => f.required).map(f => f.name);
|
|
@@ -40563,27 +40571,6 @@ function AuthForm(_ref) {
|
|
|
40563
40571
|
React.useEffect(() => {
|
|
40564
40572
|
setFormErrors(errors);
|
|
40565
40573
|
}, [errors]);
|
|
40566
|
-
const renderErrors = (err, t) => {
|
|
40567
|
-
const generalErrors = [];
|
|
40568
|
-
Object.keys(err).forEach(key => {
|
|
40569
|
-
const isFieldError = currentFields.some(field => field.name === key);
|
|
40570
|
-
if (isFieldError) {
|
|
40571
|
-
formInstance.setFields([{
|
|
40572
|
-
name: key,
|
|
40573
|
-
errors: err[key]
|
|
40574
|
-
}]);
|
|
40575
|
-
} else {
|
|
40576
|
-
generalErrors.push(...err[key].map(error => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40577
|
-
className: "ant-form-item-explain errors-cont",
|
|
40578
|
-
style: {
|
|
40579
|
-
color: '#ff4d4f'
|
|
40580
|
-
},
|
|
40581
|
-
children: t(error)
|
|
40582
|
-
}, "".concat(key, "-").concat(error))));
|
|
40583
|
-
}
|
|
40584
|
-
});
|
|
40585
|
-
return generalErrors;
|
|
40586
|
-
};
|
|
40587
40574
|
const renderField = field => {
|
|
40588
40575
|
var _field$options;
|
|
40589
40576
|
const rules = [...(field.required ? [{
|
|
@@ -40644,7 +40631,7 @@ function AuthForm(_ref) {
|
|
|
40644
40631
|
layout: "vertical",
|
|
40645
40632
|
initialValues: initialValues,
|
|
40646
40633
|
onFinish: handleSubmit,
|
|
40647
|
-
children: [currentFields.map(renderField),
|
|
40634
|
+
children: [currentFields.map(renderField), isMultiStep && currentStep > 0 ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40648
40635
|
className: "flex flex-column gap-2",
|
|
40649
40636
|
style: {
|
|
40650
40637
|
width: '100%'
|
package/package.json
CHANGED
|
@@ -18,6 +18,8 @@ function AuthForm ({
|
|
|
18
18
|
const [allFormValues, setAllFormValues] = useState(initialValues);
|
|
19
19
|
const [formErrors, setFormErrors] = useState(null);
|
|
20
20
|
|
|
21
|
+
console.log({errors})
|
|
22
|
+
|
|
21
23
|
const isMultiStep = !!steps;
|
|
22
24
|
const currentFields = isMultiStep ? steps?.[currentStep]?.fields : fields || [];
|
|
23
25
|
|
|
@@ -54,18 +56,26 @@ function AuthForm ({
|
|
|
54
56
|
const prev = () => setCurrentStep((prev) => prev - 1);
|
|
55
57
|
|
|
56
58
|
const handleSubmit = async (values) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.error('reCAPTCHA verification failed');
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
setFormErrors(null);
|
|
63
|
-
if (!isMultiStep) return onSubmit?.(values);
|
|
59
|
+
try {
|
|
60
|
+
await formInstance.validateFields();
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const token = await handleReCaptchaVerify();
|
|
63
|
+
if (!token) {
|
|
64
|
+
console.error('reCAPTCHA verification failed');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setFormErrors(null);
|
|
69
|
+
|
|
70
|
+
if (!isMultiStep) return onSubmit?.(values);
|
|
71
|
+
|
|
72
|
+
if (currentStep < steps?.length - 1) return next();
|
|
73
|
+
|
|
74
|
+
const finalValues = { ...allFormValues, ...values };
|
|
75
|
+
onSubmit?.(finalValues);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error("Validation failed:", err);
|
|
78
|
+
}
|
|
69
79
|
};
|
|
70
80
|
|
|
71
81
|
const checkRequiredFieldsFilled = (changedValues, allValues) => {
|
|
@@ -81,29 +91,18 @@ function AuthForm ({
|
|
|
81
91
|
}, [errors]);
|
|
82
92
|
|
|
83
93
|
const renderErrors = (err, t) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Object.keys(err).
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
generalErrors.push(...err[key].map(error =>
|
|
96
|
-
<div
|
|
97
|
-
key={`${key}-${error}`}
|
|
98
|
-
className="ant-form-item-explain errors-cont"
|
|
99
|
-
style={{ color: '#ff4d4f' }}>
|
|
100
|
-
{t(error)}
|
|
101
|
-
</div>
|
|
102
|
-
));
|
|
103
|
-
}
|
|
94
|
+
document.querySelectorAll('.ant-form-item')
|
|
95
|
+
.forEach(input => input.classList.add('ant-form-item-has-error'))
|
|
96
|
+
return Object.keys(err).map(key => {
|
|
97
|
+
return err[key].map(error =>
|
|
98
|
+
<div
|
|
99
|
+
key={error}
|
|
100
|
+
className="ant-form-item-explain errors-cont"
|
|
101
|
+
style={{ color: '#ff4d4f' }}>
|
|
102
|
+
{t(error)}
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
104
105
|
});
|
|
105
|
-
|
|
106
|
-
return generalErrors;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
const renderField = (field) => {
|
|
@@ -163,9 +162,9 @@ function AuthForm ({
|
|
|
163
162
|
{currentFields.map(renderField)}
|
|
164
163
|
|
|
165
164
|
|
|
166
|
-
{formErrors ? (
|
|
165
|
+
{/* {formErrors ? (
|
|
167
166
|
renderErrors(formErrors, t)
|
|
168
|
-
) : null}
|
|
167
|
+
) : null} */}
|
|
169
168
|
|
|
170
169
|
{isMultiStep && currentStep > 0 ? (
|
|
171
170
|
<div className="flex flex-column gap-2" style={{ width: '100%' }}>
|