react-mui-form-validator 1.7.2 → 1.7.3
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/lib/index.cjs +18 -15
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +21 -8
- package/lib/index.d.ts +21 -8
- package/lib/index.js +18 -15
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -20272,8 +20272,12 @@ var ValidatorForm = class extends React72.Component {
|
|
|
20272
20272
|
};
|
|
20273
20273
|
childs = [];
|
|
20274
20274
|
errors = [];
|
|
20275
|
-
|
|
20276
|
-
|
|
20275
|
+
get instantValidate() {
|
|
20276
|
+
return this.props.instantValidate !== void 0 ? this.props.instantValidate : true;
|
|
20277
|
+
}
|
|
20278
|
+
get debounceTime() {
|
|
20279
|
+
return this.props.debounceTime !== void 0 ? this.props.debounceTime : 0;
|
|
20280
|
+
}
|
|
20277
20281
|
getFormHelpers = () => ({
|
|
20278
20282
|
form: {
|
|
20279
20283
|
attachToForm: this.attachToForm,
|
|
@@ -20297,9 +20301,7 @@ var ValidatorForm = class extends React72.Component {
|
|
|
20297
20301
|
}
|
|
20298
20302
|
};
|
|
20299
20303
|
submit = (event) => {
|
|
20300
|
-
|
|
20301
|
-
event.preventDefault();
|
|
20302
|
-
}
|
|
20304
|
+
event.preventDefault();
|
|
20303
20305
|
this.errors = [];
|
|
20304
20306
|
this.walk(this.childs).then((result) => {
|
|
20305
20307
|
if (this.errors.length && this.props.onError) {
|
|
@@ -20327,7 +20329,7 @@ var ValidatorForm = class extends React72.Component {
|
|
|
20327
20329
|
checkInput = (input, dryRun) => {
|
|
20328
20330
|
return new Promise((resolve) => {
|
|
20329
20331
|
const validators = input?.props?.validators;
|
|
20330
|
-
if (!validators || !Array.isArray(validators)) {
|
|
20332
|
+
if (!validators || !Array.isArray(validators) || validators.length === 0) {
|
|
20331
20333
|
resolve(true);
|
|
20332
20334
|
return;
|
|
20333
20335
|
}
|
|
@@ -20434,9 +20436,7 @@ var ValidatorComponent = class extends React73.Component {
|
|
|
20434
20436
|
}
|
|
20435
20437
|
}
|
|
20436
20438
|
componentWillUnmount() {
|
|
20437
|
-
|
|
20438
|
-
this.form.detachFromForm(this);
|
|
20439
|
-
}
|
|
20439
|
+
this.form?.detachFromForm?.(this);
|
|
20440
20440
|
if (this.validateDebounced?.cancel) {
|
|
20441
20441
|
this.validateDebounced.cancel();
|
|
20442
20442
|
}
|
|
@@ -20446,9 +20446,9 @@ var ValidatorComponent = class extends React73.Component {
|
|
|
20446
20446
|
}
|
|
20447
20447
|
configure = () => {
|
|
20448
20448
|
const form = this.context?.form;
|
|
20449
|
-
if (!form) {
|
|
20449
|
+
if (!form?.attachToForm || !form?.detachFromForm) {
|
|
20450
20450
|
console.error(
|
|
20451
|
-
"MuiTextField debe estar dentro de <
|
|
20451
|
+
"MuiTextField debe estar dentro de tu <MuiForm> local. No mezcles este MuiTextField con MuiForm de react-mui-form-validator."
|
|
20452
20452
|
);
|
|
20453
20453
|
return;
|
|
20454
20454
|
}
|
|
@@ -20456,7 +20456,12 @@ var ValidatorComponent = class extends React73.Component {
|
|
|
20456
20456
|
this.form.attachToForm(this);
|
|
20457
20457
|
this.instantValidate = this.form.instantValidate;
|
|
20458
20458
|
this.debounceTime = this.form.debounceTime;
|
|
20459
|
-
this.validateDebounced = debounce2(
|
|
20459
|
+
this.validateDebounced = debounce2(
|
|
20460
|
+
(value, includeRequired, dryRun) => {
|
|
20461
|
+
void this.validate(value, includeRequired, dryRun);
|
|
20462
|
+
},
|
|
20463
|
+
this.debounceTime
|
|
20464
|
+
);
|
|
20460
20465
|
};
|
|
20461
20466
|
getErrorMessage = () => {
|
|
20462
20467
|
const { errorMessages } = this.state;
|
|
@@ -20491,9 +20496,7 @@ var ValidatorComponent = class extends React73.Component {
|
|
|
20491
20496
|
});
|
|
20492
20497
|
if (!dryRun) {
|
|
20493
20498
|
this.setState({ isValid: valid }, () => {
|
|
20494
|
-
|
|
20495
|
-
this.props.validatorListener(this.isValid());
|
|
20496
|
-
}
|
|
20499
|
+
this.props.validatorListener?.(this.isValid());
|
|
20497
20500
|
});
|
|
20498
20501
|
}
|
|
20499
20502
|
return valid;
|