discourse/app/assets/stylesheets
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
..
admin FIX: Rename branding to logo and fonts (#32264) 2025-04-14 10:49:47 +08:00
common DEV: DMultiSelect (#32240) 2025-04-15 14:56:57 +02:00
desktop UX: Use mixin for quote border radius (#32294) 2025-04-14 16:33:21 -05:00
lib DEV: Introduce new breakpoints (#31886) 2025-03-28 14:50:06 +00:00
mobile FIX: Consistent search shortcuts (#32099) 2025-04-04 11:54:46 +10:00
vendor DEV: Remove rotate-center css animation (#32151) 2025-04-03 19:12:55 +02:00
admin.scss DEV: Move admin SCSS files to their own directory (#31417) 2025-02-21 15:14:17 +00:00
admin_rtl.scss FEATURE: Serve RTL versions of admin and plugins CSS bundles for RTL locales (#21876) 2023-06-01 05:27:11 +03:00
color_definitions.scss DEV: Introduce postcss for autoprefix and light-dark() polyfill (#31393) 2025-02-20 14:40:27 +00:00
common.scss DEV: Remove rotate-center css animation (#32151) 2025-04-03 19:12:55 +02:00
desktop.scss DEV: Move desktop-specific admin styles to admin css bundle (#31524) 2025-02-26 13:39:52 +00:00
desktop_rtl.scss
embed.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
ember_cli.scss DEV: Enable and fix more stylelint rules (#31200) 2025-02-05 20:03:56 +01:00
mobile.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
mobile_rtl.scss
publish.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
qunit-custom.scss DEV: Fix dark-mode qunit "skipped" test color (#31327) 2025-02-13 04:27:12 +01:00
wcag.scss A11Y: fix post control button contrast issue for WCAG colors (#31177) 2025-02-04 15:17:29 -05:00
wizard.scss DEV: Wizard step tweaks (#32304) 2025-04-15 13:53:01 +08:00
wizard_rtl.scss FEATURE: Serve RTL versions of admin and plugins CSS bundles for RTL locales (#21876) 2023-06-01 05:27:11 +03:00