Skip to content

Commit

Permalink
✨ limiting number of selections
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-gn committed Dec 27, 2021
1 parent fbb3220 commit fd62a79
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion design-system/projects/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mprisma/components",
"version": "0.0.72",
"version": "0.0.73",
"repository": {
"type": "git",
"url": "https://github.com/gabriel-gn/prisma-components.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<form>
<input #inputBox
#trigger="matAutocompleteTrigger"
[hidden]="_selectedOptions.length === options.length"
[hidden]="_selectedOptions.length === options.length || (!!limit && _selectedOptions.length >= limit)"
matInput
class="form-control h-100 border-0"
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,27 @@ export class MultiSelectComponent implements OnInit, AfterViewInit {

@ViewChild('inputBox') inputBoxEl: ElementRef;
@ViewChild('trigger') trigger: MatAutocompleteTrigger;
/**
* Ao ser selecionada uma opção nova, emite
*/
@Output() selectedOptions = new EventEmitter<MultiSelectOption[]>();
/**
* Texto a ser exibido no input
*/
@Input() placeholder: string = '';
/**
* opções a serem exibidas no input
*/
@Input() options: MultiSelectOption[] = [];
@Input() borderRadius: Sizes = Sizes.md;
/**
* se as thumbnails serão arredondadas
*/
@Input() roundedThumbnail: boolean = true;
/**
* limite máximo de seleções de itens
*/
@Input() limit: number = 0;
myControl = new FormControl();
_selectedOptions: MultiSelectOption[] = [];
filteredOptions: Observable<MultiSelectOption[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Template: Story<MultiSelectComponent> = (args) => ({
[placeholder]="placeholder"
[borderRadius]="borderRadius"
[roundedThumbnail]="roundedThumbnail"
[limit]="limit"
>
</pm-multi-select>
`
Expand All @@ -25,7 +26,8 @@ export const defaultArgs = {
options: [],
placeholder: '',
borderRadius: Sizes.md,
roundedThumbnail: true
roundedThumbnail: true,
limit: 0
};

export const DefaultMultiSelect = Template.bind({});
Expand Down

1 comment on commit fd62a79

@vercel
Copy link

@vercel vercel bot commented on fd62a79 Dec 27, 2021

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.