Skip to content

Commit

Permalink
🔧 multi-select treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-gn committed Oct 23, 2023
1 parent 6377195 commit 0333d0c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Angular Version | NPM Package Version |
|-----------------|---------------------|
| ^16.1.4 | 16.1.12 |
| ^16.1.4 | 16.1.13 |
| 15.0.4 | 15.0.6 |
| 13.2.3 | 13.0.22 |
| < 13.0.0 | 0.0.77 |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mprisma/components",
"version": "16.1.12",
"version": "16.1.13",
"repository": {
"type": "git",
"url": "https://github.com/gabriel-gn/prisma-components.git"
Expand Down
17 changes: 10 additions & 7 deletions src/components/inputs/multi-select/multi-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ export class MultiSelectComponent implements OnInit, AfterViewInit, ControlValue
*/
private _selectedOptions: MultiSelectOption[] = [];
@Input() set selectedOptions(options: (MultiSelectOption | any)[]) {
options = options.reduce((acc: any[], val: any) => {
if (isMultiSelectOption(val)) {
return [...acc, val];
} else {
return [...acc, this.options.find((option: MultiSelectOption) => _.isEqual(option.value, val))];
}
}, []) as unknown as MultiSelectOption[];
options = options
.reduce((acc: any[], val: any) => {
if (isMultiSelectOption(val)) {
return [...acc, val];
} else {
return [...acc, this.options.find((option: MultiSelectOption) => _.isEqual(option.value, val))];
}
}, [])
// filtra as opções do "find" que podem ser undefined
.filter(i => !!i) as unknown as MultiSelectOption[];
this._selectedOptions = options;
this.selectedOptionsChanged.emit(this.selectedOptions);
this.propagateChange(this.selectedOptions);
Expand Down

1 comment on commit 0333d0c

@vercel
Copy link

@vercel vercel bot commented on 0333d0c Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.