turbogui-angular 20.0.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 +53 -1
- package/fesm2022/turbogui-angular.mjs.map +1 -1
- package/main/controller/router-base.service.d.ts +19 -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,40 @@ 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
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Gets the value of a specific route parameter by its key from the current route.
|
|
1688
|
+
*
|
|
1689
|
+
* For example, if the current route is `/user/123`, and you call this method with `key` as `id`, it will return `123`.
|
|
1690
|
+
* The name of the parameter must match the one defined in the route configuration on your application (e.g., `{ path: 'user/:id', component: UserComponent }`).
|
|
1691
|
+
*
|
|
1692
|
+
* @param key The key of the route parameter to retrieve.
|
|
1693
|
+
*
|
|
1694
|
+
* @returns The value of the specified route parameter, or undefined if it does not exist.
|
|
1695
|
+
*/
|
|
1696
|
+
getCurrentRouteParamValue(key) {
|
|
1697
|
+
let currentRoute = this.router.routerState.snapshot.root;
|
|
1698
|
+
while (currentRoute.firstChild) {
|
|
1699
|
+
currentRoute = currentRoute.firstChild;
|
|
1700
|
+
}
|
|
1701
|
+
if (!(key in currentRoute.params)) {
|
|
1702
|
+
throw new Error(`Route parameter '${key}' does not exist.`);
|
|
1703
|
+
}
|
|
1704
|
+
return currentRoute.params[key];
|
|
1705
|
+
}
|
|
1676
1706
|
/**
|
|
1677
1707
|
* Initializes the title management feature to automatically refresh the browser title based on the current
|
|
1678
1708
|
* URL route. It Must be called once, typically at application startup
|
|
@@ -3042,6 +3072,28 @@ class ValidatorsPlus extends Validators {
|
|
|
3042
3072
|
return null;
|
|
3043
3073
|
}
|
|
3044
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
|
+
}
|
|
3045
3097
|
}
|
|
3046
3098
|
|
|
3047
3099
|
/*
|