discourse/app/assets/stylesheets/common/components
Joffrey JAFFEUX 59ec86933a
DEV: DMultiSelect (#32240)
The `DMultiSelect` component provides a customizable multi-select
dropdown with support for both mouse and keyboard interactions.

![Screenshot 2025-04-10 at 15 40
26](https://github.com/user-attachments/assets/277619db-6e56-4beb-8eda-f76360cd2ad8)

### Parameters

#### `@loadFn` (required)
An async function that returns the data to populate the dropdown
options.

```javascript
const loadFn = async () => {
  return [
    { id: 1, name: "Option 1" },
    { id: 2, name: "Option 2" },
  ];
};
```

#### `@compareFn`

A function used to determine equality between items. This is
particularly useful when working with complex objects. By default, `id`
will be used.

```javascript
const compareFn = (a, b) => {
  return a.name === b.name;
};
```

#### `@selection`
An array of pre-selected items that will be displayed as selected when
the component renders.

```javascript
const selection = [
  { id: 1, name: "Option 1" },
  { id: 2, name: "Option 2" },
];
```

#### `@label`
Text label displayed in the trigger element when no items are selected.

```javascript
@label="Select options"
```

### Named Blocks

#### :selection
Block for customizing how selected items appear in the trigger.

```javascript
<:selection as |result|>{{result.name}}</:selection>
```

#### :result
Block for customizing how items appear in the dropdown list.

```javascript
<:result as |result|>{{result.name}}</:result>
```

#### :result
Block for customizing how errors appear in the component.

```javascript
<:error as |error|>{{error}}</:error>
```

### Example Usage

```javascript
<DMultiSelect
  @loadFn={{this.loadOptions}}
  @selection={{this.selectedItems}}
  @compareFn={{this.compareItems}}
  @label="Select options">
  <:selection as |result|>{{result.name}}</:selection>
  <:result as |result|>{{result.name}}</:result>
  <:error as |error|>{{error}}</:error>
</DMultiSelect>
```

Co-Authored-By: Jordan Vidrine
<30537603+jordanvidrine@users.noreply.github.com>

---------

Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com>
2025-04-15 14:56:57 +02:00
..
sidebar/edit-navigation-menu DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
_index.scss DEV: DMultiSelect (#32240) 2025-04-15 14:56:57 +02:00
add-pm-participants.scss DEV: Merge duplicated css (#31167) 2025-02-05 18:42:55 +01:00
badges.scss UX: emoji styling adjustments (#32039) 2025-03-27 18:45:39 +04:00
banner.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
bookmark-list.scss DEV: Make styling bookmarks easier (#31979) 2025-03-25 11:02:11 -05:00
bookmark-menu.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
bookmark-modal.scss DEV: Fix all mixed-decls sass deprecations (#31343) 2025-02-13 23:58:19 +01:00
buttons.scss DEV: Update lint-configs and autofix issues (#31620) 2025-03-05 01:20:16 +01:00
calendar-date-time-input.scss DEV: Fix all mixed-decls sass deprecations (#31343) 2025-02-13 23:58:19 +01:00
char-counter.scss FEATURE: Add word count and indicator when exceeded max (#19367) 2023-02-20 12:06:43 +01:00
color-input.scss FEATURE: add icons and emojis to category (#31795) 2025-03-26 09:46:17 +04:00
composer-toggle-switch.scss DEV: Update lint-configs and autofix issues (#31620) 2025-03-05 01:20:16 +01:00
conditional-loading-section.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
convert-to-public-topic-modal.scss
d-breadcrumbs.scss DEV: Make breadcrumb separators unclickable icons (#29817) 2024-11-19 16:42:43 +08:00
d-multi-select.scss DEV: DMultiSelect (#32240) 2025-04-15 14:56:57 +02:00
d-page-header.scss UX: Add separator for "Learn more..." on admin pages (#31898) 2025-03-19 13:34:17 +10:00
d-select.scss DEV: Enable and fix more stylelint rules (#31200) 2025-02-05 20:03:56 +01:00
d-stat-tiles.scss UX: Introduce <DStatTiles /> component (#30238) 2024-12-13 11:32:46 +10:00
d-toggle-switch.scss DEV: Fix all mixed-decls sass deprecations (#31343) 2025-02-13 23:58:19 +01:00
date-input.scss DEV: Enable and fix more stylelint rules (#31200) 2025-02-05 20:03:56 +01:00
date-picker.scss UX: Normalize sizing for inputs, buttons, dropdowns (#14226) 2021-09-09 11:01:56 -04:00
date-time-input-range.scss UX: Normalize sizing for inputs, buttons, dropdowns (#14226) 2021-09-09 11:01:56 -04:00
date-time-input.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
download-calendar.scss DEV: FloatKit (#23650) 2023-09-26 13:39:52 +02:00
drafts-dropdown-menu.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
dropdown-menu.scss UX: left-align dropdown menu button text (#31198) 2025-02-05 12:43:13 -05:00
emoji-picker.scss FIX: ensures emoji picker loader is centered (#31676) 2025-03-06 21:19:01 +01:00
file-size-input.scss FIX: Make cancel and reset buttons work for file_size_restriction settings (#28347) 2024-08-15 19:38:47 +03:00
filter-input.scss DEV: unifies emoji picker (#28277) 2025-01-08 11:41:36 +01:00
footer-nav.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
form-template-field.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
group-member-dropdown.scss DEV: Set containing block for Popper dropdowns (#20745) 2023-03-20 15:26:20 -04:00
groups-form-membership-fields.scss
hashtag.scss UX: add flex to mentions mixin + update units (#32145) 2025-04-04 12:20:35 +10:00
horizontal-overflow-nav.scss UX: improve nav fade css (#31975) 2025-03-24 15:14:56 -04:00
iframed-html.scss
ignored-user-list.scss UX: fix color preference layout (#21346) 2023-05-03 10:11:52 +08:00
keyboard_shortcuts.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
more-topics.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
navs.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
notifications-tracking.scss FIX: prevents d-menu trigger/untrigger propagation (#32078) 2025-03-31 13:47:24 +02:00
offline-indicator.scss FEATURE: Offline indicator (#21369) 2023-06-05 11:08:04 -05:00
pick-files-button.scss DEV: add pick-files-button component (#13764) 2021-07-16 21:50:50 +04:00
post-list.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
powered-by-discourse.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
relative-time-picker.scss UX: minor fixes in topic action modal (#24772) 2023-12-07 14:54:56 +01:00
signup-progress-bar.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
svg.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
tap-tile.scss UX: highlight vars updates (#20346) 2023-02-21 10:15:49 +01:00
theme-card.scss DEV: Update lint-configs and autofix issues (#31620) 2025-03-05 01:20:16 +01:00
time-input.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
time-shortcut-picker.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
topic-map.scss DEV: Introduce postcss minmax transform (#31885) 2025-03-18 19:28:52 +00:00
topic-query-filter.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
user-card.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
user-info.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
user-status-message.scss UX: improve the alignment of long status messages (#30830) 2025-01-16 17:22:37 -05:00
user-status-picker.scss DEV: unifies emoji picker (#28277) 2025-01-08 11:41:36 +01:00
user-stream-item.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
user-stream.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
welcome-banner.scss FIX: Consistent search shortcuts (#32099) 2025-04-04 11:54:46 +10:00
welcome-header.scss UX: Add progress bar to the registration flow (#27694) 2024-08-28 08:43:39 -03:00
widget-dropdown.scss REFACTOR: improve poll info layout (#22353) 2023-07-05 12:20:18 -04:00