discourse/app/assets/stylesheets/common
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
..
base UX: Quick mobile fix for quote styles (#32297) 2025-04-14 17:28:03 -05:00
components DEV: DMultiSelect (#32240) 2025-04-15 14:56:57 +02:00
float-kit UX: Refactor, removal, cleanup (#31839) 2025-03-14 16:40:45 -05:00
form-kit FIX: allows to resize textarea (#32076) 2025-03-31 16:52:29 +02:00
foundation UX: Use mixin for quote border radius (#32294) 2025-04-14 16:33:21 -05:00
login DEV: Introduce postcss minmax transform (#31885) 2025-03-18 19:28:52 +00:00
modal FIX: safari bug on rich editor's list item (#32243) 2025-04-09 15:03:52 -03:00
rich-editor UX: Border radius prose-mirror select node (#32292) 2025-04-14 15:10:23 -05:00
select-kit DEV: normalize tag text color assignment (#31860) 2025-03-17 12:54:15 -04:00
table-builder DEV: Remove unneeded -webkit prefixes from css (#31448) 2025-02-21 14:48:20 +00:00
d-editor.scss UX: keep the whisper editor font/color style consistent between editors (#32287) 2025-04-14 14:27:05 -03:00
font-variables.scss UX: Replace font-size-ios-input workaround (#30877) 2025-01-20 19:17:30 +00:00
input_tip.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
loading-slider.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
post-action-feedback.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
printer-friendly.scss DEV: Merge duplicated css (#31167) 2025-02-05 18:42:55 +01:00
software-update-prompt.scss DEV: Fix all mixed-decls sass deprecations (#31343) 2025-02-13 23:58:19 +01:00
topic-entrance.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
topic-timeline.scss DEV: Introduce postcss minmax transform (#31885) 2025-03-18 19:28:52 +00:00
whcm.scss A11Y: Improve accessibility in WHCM themes (#18606) 2022-10-17 07:07:46 -07:00