Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@ngx-smart-forms/smart-selector
Advanced tools
A dynamic and flexible Angular component for selecting options from lists or grids. Features include single and multi-select modes, keyboard navigation, customizable templates, accessibility support (ARIA), and integration with Angular forms. Ideal for bu
@ngx-smart-forms/smart-selector
is a comprehensive Angular library for building rich selection interfaces. It supports single and multi-selection, grid and list layouts, custom templates, and integrates seamlessly with Angular forms. The library is highly customizable with theming support, built-in validation, and event-driven workflows. Full accessibility (A11y) ensures your components are usable across all devices and assistive technologies.
npm install @ngx-smart-forms/smart-selector
Or:
yarn add @ngx-smart-forms/smart-selector
Check out a live interactive demo of the @ngx-smart-forms/smart-selector
library on StackBlitz:
You can also click here to open the project in a new tab.
SmartSelector
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SmartSelector, SmartSelectorOption } from '@ngx-smart-forms/smart-selector';
@Component({
selector: 'app-selector-demo',
standalone: true,
imports: [ReactiveFormsModule, SmartSelector],
templateUrl: './selector-demo.component.html',
})
export class SelectorDemoComponent {
form: FormGroup;
options: SmartSelectorOption[] = [
{ id: '1', label: 'Strength' },
{ id: '2', label: 'Endurance' },
{ id: '3', label: 'Flexibility' },
{ id: '4', label: 'Cardio' },
{ id: '5', label: 'Power' },
];
constructor(private fb: FormBuilder) {
this.form = this.fb.group({
selection: [null], // Single selection
multiSelection: [[]], // Multi-selection
});
}
onOptionChange(event: SmartSelectorOption | SmartSelectorOption[]) {
console.log('Option changed:', event);
}
}
<form [formGroup]="form">
<smart-selector
formControlName="selection"
[options]="options"
(optionChanged)="onOptionChange($event)"
></smart-selector>
</form>
<smart-selector
formControlName="multiSelection"
[options]="options"
[multiSelect]="true"
(optionChanged)="onOptionChange($event)"
></smart-selector>
<smart-selector
[layout]="'grid'"
[options]="options"
(optionChanged)="onOptionChange($event)"
></smart-selector>
<smart-selector
[options]="imageOptions"
[optionImage]="getImage"
(optionChanged)="onOptionChange($event)"
></smart-selector>
getImage(option: SmartSelectorOption): string | null {
return option.image || null;
}
<smart-selector
[multiSelect]="true"
[maxSelection]="3"
[options]="options"
formControlName="multiSelection"
></smart-selector>
<div *ngIf="form.get('multiSelection')?.errors as errors">
<div *ngIf="errors['maxSelection']">
You can only select {{ errors['maxSelection'].maxAllowed }} options.
</div>
</div>
<ng-template #customOption let-option let-selected="selected">
<img [src]="option.image" alt="Option Image" />
<p [class.selected]="selected">{{ option.label }}</p>
</ng-template>
<smart-selector
[template]="customOption"
[options]="options"
[layout]="'grid'"
></smart-selector>
<smart-selector
[placeholder]="'Select an item'"
[noOptionsText]="'No options available'"
[ariaLabel]="'Custom Selector'"
[options]="options"
></smart-selector>
<!-- Select All / Deselect All Checkbox -->
<label>
<input type="checkbox" [smartToggleSelection]="selector" />
Select/Deselect All
</label>
<!-- Smart Selector Component -->
<smart-selector
#selector
formControlName="multiSelection"
[options]="options"
[multiSelect]="true"
(optionChanged)="onOptionChange($event)"
></smart-selector>
import { SmartSelector, SmartToggleSelection } from '@ngx-smart-forms/smart-selector';
@Component({
selector: 'app-smart-selector-demo',
standalone: true,
imports: [
SmartSelector,
SmartToggleSelection,
],
templateUrl: './smart-selector-demo.component.html',
styleUrls: ['./smart-selector-demo.component.scss'],
})
Property | Type | Default | Description |
---|---|---|---|
options | SmartSelectorOption[] | [] | Array of selectable options. |
multiSelect | boolean | false | Enable multi-selection mode. |
layout | 'list' | 'grid' | list | Layout type (list or grid). |
maxSelection | number | Infinity | Maximum number of selections allowed. |
placeholder | string | null | Placeholder text for empty selections. |
noOptionsText | string | string | Message when no options are available. |
ariaLabel | string | 'Option' | Accessible label for screen readers. |
optionLabel | (option) => string | string | Function to display custom labels. |
optionImage | (option) => string | null | string | Function to display images for options. |
Event | Description |
---|---|
optionChanged | Triggered when an option is selected or deselected. |
onSelect | Fired when an option is selected. |
onDeselect | Fired when an option is deselected. |
validationErrors | Emitted when validation errors occur. |
Customize the look and feel using the following CSS variables:
smart-selector {
--selector-background-color: #f5f9fd;
--selector-text-color: #333;
--selector-active-background-color: #007bff;
--selector-active-text-color: #fff;
--selector-hover-background-color: #e9ecef;
--selector-hover-text-color: #000;
--selector-item-spacing: 10px;
--selector-item-padding: 15px;
--selector-item-border-radius: 4px;
--grid-columns: repeat(auto-fit, minmax(150px, 1fr));
--selector-disabled-background-color: #e0e0e0;
--selector-disabled-text-color: #9e9e9e;
--selector-disabled-cursor: not-allowed;
}
role="listbox"
and aria-multiselectable
attributes.noOptionsText
for better UX.maxSelection
to avoid excessive selections.If you encounter an issue, you can create a ticket
We welcome contributions! Please see the CONTRIBUTING.md file for more information on how to get involved.
This library is licensed under the MIT License - see the LICENSE file for details.
FAQs
A dynamic and flexible Angular component for selecting options from lists or grids. Features include single and multi-select modes, keyboard navigation, customizable templates, accessibility support (ARIA), and integration with Angular forms. Ideal for bu
The npm package @ngx-smart-forms/smart-selector receives a total of 2 weekly downloads. As such, @ngx-smart-forms/smart-selector popularity was classified as not popular.
We found that @ngx-smart-forms/smart-selector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.