gd-bs 6.1.4 → 6.1.5
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/build/components/form/control.js +88 -84
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/form/control.ts +92 -88
|
@@ -647,94 +647,98 @@ var FormControl = /** @class */ (function () {
|
|
|
647
647
|
};
|
|
648
648
|
// Updates the control validation
|
|
649
649
|
FormControl.prototype.updateValidation = function (elControl, validation) {
|
|
650
|
-
// Get the form
|
|
651
|
-
var
|
|
652
|
-
|
|
653
|
-
//
|
|
654
|
-
elFormControl
|
|
655
|
-
elFormControl
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
// Parse the controls
|
|
662
|
-
for (var i = 0; i < controls.length; i++) {
|
|
663
|
-
var control = controls[i];
|
|
664
|
-
// Clear the invalid/valid classes
|
|
665
|
-
control.classList.remove("is-invalid");
|
|
666
|
-
control.classList.remove("is-valid");
|
|
667
|
-
// Set the class
|
|
668
|
-
control.classList.add(validation.isValid ? "is-valid" : "is-invalid");
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
// Get the checkboxes
|
|
672
|
-
var elCheckboxes = elControl.querySelectorAll(".form-check-input");
|
|
673
|
-
if (elCheckboxes.length > 0) {
|
|
674
|
-
// Validate the controls
|
|
675
|
-
validateControls(elCheckboxes);
|
|
676
|
-
// Set the form control
|
|
677
|
-
elFormControl = elCheckboxes.length > 0 ? elCheckboxes[elCheckboxes.length - 1] : elFormControl;
|
|
678
|
-
}
|
|
679
|
-
// Get the custom controls
|
|
680
|
-
var elCustomControls = elControl.querySelectorAll(".custom-control-input");
|
|
681
|
-
if (elCustomControls.length > 0) {
|
|
682
|
-
// Validate the controls
|
|
683
|
-
validateControls(elCustomControls);
|
|
684
|
-
// Set the form control
|
|
685
|
-
elFormControl = elCustomControls.length > 0 ? elCustomControls[elCustomControls.length - 1] : elFormControl;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
// Ensure the form control exists
|
|
689
|
-
if (elFormControl) {
|
|
690
|
-
var useTooltip = this._formProps.validationType == _1.FormValidationTypes.Tooltip;
|
|
691
|
-
// Clear the old valid message if it exists
|
|
692
|
-
var validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
|
|
693
|
-
var elMessage = elFormControl.parentNode.querySelector("." + validClassName);
|
|
694
|
-
if (elMessage) {
|
|
695
|
-
// Clear the message
|
|
696
|
-
elMessage.innerHTML = "";
|
|
697
|
-
elMessage.style.display = "";
|
|
650
|
+
// Get the form controls
|
|
651
|
+
var elFormControls = elControl.querySelectorAll(".form-control") || elControl.querySelectorAll(".form-select");
|
|
652
|
+
for (var i = 0; i < elFormControls.length; i++) {
|
|
653
|
+
// Ensure the control exists
|
|
654
|
+
var elFormControl = elFormControls[i];
|
|
655
|
+
if (elFormControl) {
|
|
656
|
+
// Clear the invalid/valid classes
|
|
657
|
+
elFormControl.classList.remove("is-invalid");
|
|
658
|
+
elFormControl.classList.remove("is-valid");
|
|
659
|
+
// Set the class
|
|
660
|
+
elFormControl.classList.add(validation.isValid ? "is-valid" : "is-invalid");
|
|
698
661
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
662
|
+
else {
|
|
663
|
+
var validateControls = function (controls) {
|
|
664
|
+
// Parse the controls
|
|
665
|
+
for (var i_1 = 0; i_1 < controls.length; i_1++) {
|
|
666
|
+
var control = controls[i_1];
|
|
667
|
+
// Clear the invalid/valid classes
|
|
668
|
+
control.classList.remove("is-invalid");
|
|
669
|
+
control.classList.remove("is-valid");
|
|
670
|
+
// Set the class
|
|
671
|
+
control.classList.add(validation.isValid ? "is-valid" : "is-invalid");
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
// Get the checkboxes
|
|
675
|
+
var elCheckboxes = elControl.querySelectorAll(".form-check-input");
|
|
676
|
+
if (elCheckboxes.length > 0) {
|
|
677
|
+
// Validate the controls
|
|
678
|
+
validateControls(elCheckboxes);
|
|
679
|
+
// Set the form control
|
|
680
|
+
elFormControl = elCheckboxes.length > 0 ? elCheckboxes[elCheckboxes.length - 1] : elFormControl;
|
|
681
|
+
}
|
|
682
|
+
// Get the custom controls
|
|
683
|
+
var elCustomControls = elControl.querySelectorAll(".custom-control-input");
|
|
684
|
+
if (elCustomControls.length > 0) {
|
|
685
|
+
// Validate the controls
|
|
686
|
+
validateControls(elCustomControls);
|
|
687
|
+
// Set the form control
|
|
688
|
+
elFormControl = elCustomControls.length > 0 ? elCustomControls[elCustomControls.length - 1] : elFormControl;
|
|
717
689
|
}
|
|
718
|
-
// Set the message
|
|
719
|
-
elMessage.innerHTML = validation.invalidMessage || this._props.errorMessage;
|
|
720
|
-
// Update the display
|
|
721
|
-
elMessage.style.display = validation.isValid ? "" : "block";
|
|
722
690
|
}
|
|
723
|
-
//
|
|
724
|
-
if (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
elMessage.
|
|
732
|
-
|
|
691
|
+
// Ensure the form control exists
|
|
692
|
+
if (elFormControl) {
|
|
693
|
+
var useTooltip = this._formProps.validationType == _1.FormValidationTypes.Tooltip;
|
|
694
|
+
// Clear the old valid message if it exists
|
|
695
|
+
var validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
|
|
696
|
+
var elMessage = elFormControl.parentNode.querySelector("." + validClassName);
|
|
697
|
+
if (elMessage) {
|
|
698
|
+
// Clear the message
|
|
699
|
+
elMessage.innerHTML = "";
|
|
700
|
+
elMessage.style.display = "";
|
|
701
|
+
}
|
|
702
|
+
// Clear the old valid message if it exists
|
|
703
|
+
var invalidClassName = useTooltip ? "invalid-tooltip" : "invalid-feedback";
|
|
704
|
+
elMessage = elFormControl.parentNode.querySelector("." + invalidClassName);
|
|
705
|
+
if (elMessage) {
|
|
706
|
+
// Clear the message
|
|
707
|
+
elMessage.innerHTML = "";
|
|
708
|
+
elMessage.style.display = "";
|
|
709
|
+
}
|
|
710
|
+
// See if there is invalid feedback
|
|
711
|
+
if (validation.invalidMessage || this._props.errorMessage) {
|
|
712
|
+
// Get the element
|
|
713
|
+
var invalidClassName_1 = useTooltip ? "invalid-tooltip" : "invalid-feedback";
|
|
714
|
+
elMessage = elFormControl.parentNode.querySelector("." + invalidClassName_1);
|
|
715
|
+
if (elMessage == null) {
|
|
716
|
+
// Create the element
|
|
717
|
+
elMessage = document.createElement("div");
|
|
718
|
+
elMessage.className = invalidClassName_1;
|
|
719
|
+
elFormControl.parentNode.appendChild(elMessage);
|
|
720
|
+
}
|
|
721
|
+
// Set the message
|
|
722
|
+
elMessage.innerHTML = validation.invalidMessage || this._props.errorMessage;
|
|
723
|
+
// Update the display
|
|
724
|
+
elMessage.style.display = validation.isValid ? "" : "block";
|
|
725
|
+
}
|
|
726
|
+
// See if there is valid feedback
|
|
727
|
+
if (validation.validMessage) {
|
|
728
|
+
// Get the element
|
|
729
|
+
var validClassName_1 = useTooltip ? "valid-tooltip" : "valid-feedback";
|
|
730
|
+
elMessage = elFormControl.parentNode.querySelector("." + validClassName_1);
|
|
731
|
+
if (elMessage == null) {
|
|
732
|
+
// Create the element
|
|
733
|
+
elMessage = document.createElement("div");
|
|
734
|
+
elMessage.className = validClassName_1;
|
|
735
|
+
elFormControl.parentNode.appendChild(elMessage);
|
|
736
|
+
}
|
|
737
|
+
// Set the message
|
|
738
|
+
elMessage.innerHTML = validation.validMessage;
|
|
739
|
+
// Update the display
|
|
740
|
+
elMessage.style.display = validation.isValid ? "block" : "";
|
|
733
741
|
}
|
|
734
|
-
// Set the message
|
|
735
|
-
elMessage.innerHTML = validation.validMessage;
|
|
736
|
-
// Update the display
|
|
737
|
-
elMessage.style.display = validation.isValid ? "block" : "";
|
|
738
742
|
}
|
|
739
743
|
}
|
|
740
744
|
};
|