@fleetbase/ember-ui
Version:
Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.
63 lines (39 loc) • 3.23 kB
Markdown
# MultiSelect Component
This is a reusable MultiSelect component built with Ember.js.
It provides a customizable UI element that allows users to select multiple options from a list.
## Usage
To use the MultiSelect component, you can simply import it into your Ember component and include it in your template as follows:
```hbs
<MultiSelect ={{this.options}} ={{fn this.search}} ={{ .multiOptionSearchField}} ={{ .multiOptionSearchEnabled}} ={{ .multiOptionSearchPlaceholder}} ={{this.value}} ={{ }} ={{ }} ={{this.isLoading}} ={{fn this.onChange}} />
```
You can customize the MultiSelect component by passing in different props:
| Option | Description |
| ------------------- | -------------------------------------------------------------------------- |
| `options` | The list of options to select from. |
| `search` | The search function to filter the options list. |
| `searchField` | The field to search for the options. |
| `searchEnabled` | Whether or not to enable search functionality. |
| `searchPlaceholder` | The placeholder text for the search field. |
| `selected` | The selected value(s). |
| `placeholder` | The placeholder text to display when no value is selected. |
| `allowClear` | Whether or not to allow clearing the selected value(s). |
| `isLoading` | Whether or not to display a loading spinner. |
| `onChange` | The function to call when a value is selected. |
Additionally, you can also provide a block to customize the option label displayed in the dropdown.
```hbs
<MultiSelect ={{this.options}} ={{this.value}} as |option|>
{{or (get option ) option}}
</MultiSelect>
```
## Example
```hbs
<MultiSelect ="form-input-sm flex-1" ={{this.options}} ={{fn this.search}} ={{ .multiOptionSearchField}} ={{ .multiOptionSearchEnabled}} ={{ .multiOptionSearchPlaceholder}} ={{this.value}} ={{ }} ={{fn this.onChange}} ={{ }} as |option|>
{{or (get option ) option}}
</MultiSelect>
{{#if this.isLoading}}
<ModelSelect::Spinner />
{{/if}}
```
This is a multi-select dropdown UI component implemented using Ember.js.
It has various configurable properties such as ` ` for the list of selectable options, ` ` for the currently selected options, and ` ` for the callback function when an option is selected.
The component also includes a conditional block to display a loading spinner when options are asynchronously loaded, specified by the `isLoading` property.