-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kit):
Segmented
fix native reset form action (#8605)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
6cba52c
commit ec87062
Showing
11 changed files
with
69 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type {AbstractControl} from '@angular/forms'; | ||
import {FormArray, FormGroup} from '@angular/forms'; | ||
import {tuiToInt} from '@taiga-ui/cdk/utils/math'; | ||
|
||
import {tuiIsControlEmpty} from './is-control-empty'; | ||
|
||
export function tuiCountFilledControls(control: AbstractControl): number { | ||
if (control instanceof FormArray) { | ||
return control.controls.reduce( | ||
(acc, nestedControl) => acc + tuiCountFilledControls(nestedControl), | ||
0, | ||
); | ||
} | ||
|
||
if (control instanceof FormGroup) { | ||
return Object.values(control.controls).reduce( | ||
(acc, nestedControl) => acc + tuiCountFilledControls(nestedControl), | ||
0, | ||
); | ||
} | ||
|
||
return tuiToInt(!tuiIsControlEmpty(control)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type {AbstractControl} from '@angular/forms'; | ||
|
||
export function tuiIsControlEmpty({value = null}: AbstractControl): boolean { | ||
return value === null || value === '' || (Array.isArray(value) && !value.length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters