turbogui-angular 20.1.0 → 20.2.0
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/fesm2022/turbogui-angular.mjs +33 -1
- package/fesm2022/turbogui-angular.mjs.map +1 -1
- package/main/controller/router-base.service.d.ts +8 -0
- package/main/controller/router-base.service.d.ts.map +1 -1
- package/main/view/forms/ValidatorsPlus.d.ts +14 -2
- package/main/view/forms/ValidatorsPlus.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
|
|
22
22
|
import * as i4 from '@angular/material/input';
|
|
23
23
|
import { MatInputModule } from '@angular/material/input';
|
|
24
24
|
import * as i5 from '@angular/forms';
|
|
25
|
-
import { FormsModule, Validators } from '@angular/forms';
|
|
25
|
+
import { FormsModule, Validators, FormControl } from '@angular/forms';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* TurboGUI is A library that helps with the most common and generic UI elements and functionalities
|
|
@@ -1669,10 +1669,20 @@ class RouterBaseService {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
/**
|
|
1671
1671
|
* Gets the current value of the route URL synchronously.
|
|
1672
|
+
* For example, if the current route is `/user/123`, it will return `/user/123`.
|
|
1673
|
+
* Notice that the base URL is not included in the returned value.
|
|
1672
1674
|
*/
|
|
1673
1675
|
getCurrentRoute() {
|
|
1674
1676
|
return this._currentRoute.getValue();
|
|
1675
1677
|
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Gets the current value of the route absolute URL synchronously.
|
|
1680
|
+
*
|
|
1681
|
+
* For example, if the current route is `/user/123` and the base href is `http://example.com/app/`, it will return `http://example.com/app/user/123`.
|
|
1682
|
+
*/
|
|
1683
|
+
getCurrentRouteAbsolute() {
|
|
1684
|
+
return window.location.origin + this.getCurrentRoute();
|
|
1685
|
+
}
|
|
1676
1686
|
/**
|
|
1677
1687
|
* Gets the value of a specific route parameter by its key from the current route.
|
|
1678
1688
|
*
|
|
@@ -3062,6 +3072,28 @@ class ValidatorsPlus extends Validators {
|
|
|
3062
3072
|
return null;
|
|
3063
3073
|
}
|
|
3064
3074
|
}
|
|
3075
|
+
/**
|
|
3076
|
+
* Validator to check that at least one of the specified form controls has a non empty value.
|
|
3077
|
+
* Non empty criteria is the same as the nonEmpty validator on this same class, which verifies that the value is not semantically empty.
|
|
3078
|
+
*
|
|
3079
|
+
* To use this validator, you need to pass an array of control names that you want to check. And set it to the validators property
|
|
3080
|
+
* of the form builder group.
|
|
3081
|
+
*
|
|
3082
|
+
* @param controlNames An array of control names to check. For example, ['name', 'surname'].
|
|
3083
|
+
*
|
|
3084
|
+
* @returns A validator function.
|
|
3085
|
+
*/
|
|
3086
|
+
static atLeastOneIsNotEmpty(controlNames) {
|
|
3087
|
+
return (control) => {
|
|
3088
|
+
const formGroup = control;
|
|
3089
|
+
const hasValue = controlNames.some(name => {
|
|
3090
|
+
const formControl = formGroup.get(name);
|
|
3091
|
+
// Check if it's a FormControl and if it's not empty
|
|
3092
|
+
return formControl instanceof FormControl && ValidatorsPlus.nonEmpty(formControl) === null;
|
|
3093
|
+
});
|
|
3094
|
+
return hasValue ? null : { atLeastOneRequired: true };
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3065
3097
|
}
|
|
3066
3098
|
|
|
3067
3099
|
/*
|