@stackline/vue-multiselect-dropdown 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,89 @@
1
1
  # @stackline/vue-multiselect-dropdown
2
2
 
3
- > A maintained Vue multiselect dropdown with separate Vue 2 and Vue 3 release lines, controlled state, searchable/grouped options, lazy loading hooks, render functions, skins, body-overlay positioning, and ADA-compliant keyboard/ARIA behavior.
3
+ > A maintained Vue multiselect dropdown with Vue 2 and Vue 3 release lines, controlled `v-model` state, scoped slots, renderless/state composables, searchable/grouped options, lazy loading hooks, custom render functions, skins, body-overlay positioning, and accessibility-focused and keyboard/ARIA tested behavior.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@stackline/vue-multiselect-dropdown.svg?style=flat-square)](https://www.npmjs.com/package/@stackline/vue-multiselect-dropdown)
6
+ [![npm monthly](https://img.shields.io/npm/dm/@stackline/vue-multiselect-dropdown.svg?style=flat-square)](https://www.npmjs.com/package/@stackline/vue-multiselect-dropdown)
6
7
  [![license](https://img.shields.io/npm/l/@stackline/vue-multiselect-dropdown.svg?style=flat-square)](https://github.com/alexandroit/vue-multiselect-dropdown/blob/main/LICENSE)
7
- [![Vue 2](https://img.shields.io/badge/Vue-2.x-42b883?style=flat-square&logo=vue.js)](https://alexandro.net/docs/vue/multiselect/vue-2/)
8
8
  [![Vue 3](https://img.shields.io/badge/Vue-3.x-42b883?style=flat-square&logo=vue.js)](https://alexandro.net/docs/vue/multiselect/vue-3/)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
10
+ [![Reddit community](https://img.shields.io/badge/community-r%2FStackline-ff4500?style=flat-square&logo=reddit&logoColor=white)](https://www.reddit.com/r/Stackline/)
9
11
 
10
- **[Documentation & Live Demos](https://alexandro.net/docs/vue/multiselect/)** | **[Vue 2 Demo](https://alexandro.net/docs/vue/multiselect/vue-2/)** | **[Vue 3 Demo](https://alexandro.net/docs/vue/multiselect/vue-3/)** | **[npm](https://www.npmjs.com/package/@stackline/vue-multiselect-dropdown)** | **[Repository](https://github.com/alexandroit/vue-multiselect-dropdown)**
12
+ **[Documentation & Live Demos](https://alexandro.net/docs/vue/multiselect/)** | **[Vue 2 Demo](https://alexandro.net/docs/vue/multiselect/vue-2/)** | **[Vue 3 Demo](https://alexandro.net/docs/vue/multiselect/vue-3/)** | **[Community Discussions](https://www.reddit.com/r/Stackline/)** | **[npm](https://www.npmjs.com/package/@stackline/vue-multiselect-dropdown)** | **[Issues](https://github.com/alexandroit/vue-multiselect-dropdown/issues)** | **[Repository](https://github.com/alexandroit/vue-multiselect-dropdown)**
11
13
 
12
- **Latest Vue 3 package release:** `3.0.2` for Vue `3.x`
13
- **Maintained Vue 2 package release:** `2.0.0` for Vue `2.x`
14
+ **Latest Vue 3 release:** `3.1.0` for Vue `3.x`
15
+
16
+ **Maintained Vue 2 release:** `2.0.0` for Vue `2.x`
14
17
 
15
18
  ---
16
19
 
17
- ## Why this library?
20
+ > **Credits:** Current maintenance, Vue release-line stewardship, publishing, and documentation by [Alexandro Paixao Marques](https://github.com/alexandroit/vue-multiselect-dropdown).
18
21
 
19
- `@stackline/vue-multiselect-dropdown` provides maintained Vue 2 and Vue 3 multiselect release lines for applications that need predictable selection state, search, grouping, skins, keyboard support, and live tested examples.
22
+ ---
23
+
24
+ ## Why this library?
20
25
 
21
- The package follows a familiar Stackline settings contract while staying idiomatic for each Vue family: bind with `v-model`, pass `:data`, customize behavior through `:settings`, and listen for `@select`, `@de-select`, `@select-all`, `@de-select-all`, `@open`, and `@close`.
26
+ `@stackline/vue-multiselect-dropdown` provides maintained Vue 2 and Vue 3 multiselect release lines for applications that need predictable selection state, search, grouping, skins, keyboard support, custom Vue markup, and live tested examples.
27
+
28
+ The package follows the familiar Stackline settings contract while staying idiomatic for Vue: pass `:data`, bind selected values with `v-model`, customize behavior through `:settings`, and listen for Vue events such as `@select`, `@de-select`, `@select-all`, `@de-select-all`, `@open`, and `@close`.
29
+
30
+ The current stable Vue 3 release is `3.1.0`. It adds renderless composables, a state composable, scoped-slot customization, helper APIs, and a strengthened combobox contract while keeping the styled `<VueMultiselectDropdown />` component compatible with the existing visual contract.
31
+
32
+ ## Features
33
+
34
+ | Feature | Supported |
35
+ | :--- | :---: |
36
+ | Vue 2 and Vue 3 maintained release lines | Yes |
37
+ | Multi-select and single-select modes | Yes |
38
+ | Controlled `v-model` selection | Yes |
39
+ | Scoped slots for custom Vue HTML | Yes |
40
+ | Renderless `useMultiSelectDropdown` composable | Yes |
41
+ | State-only `useMultiSelectState` composable | Yes |
42
+ | Search and filter | Yes |
43
+ | Group by field or callback | Yes |
44
+ | Custom item render functions | Yes |
45
+ | Custom badge render functions | Yes |
46
+ | Lazy loading hooks | Yes |
47
+ | Add-new-item from search text | Yes |
48
+ | Instance methods for open, close, focus, select all, and clear | Yes |
49
+ | Built-in `classic`, `material`, `dark`, `custom`, and `brand` skins | Yes |
50
+ | Accessibility-focused and keyboard/ARIA tested navigation, focus states, and ARIA labels | Yes |
51
+ | Multiselect options expose both `aria-selected` and `aria-checked` | Yes |
52
+ | Backspace/Escape combobox contract | Yes |
53
+ | Selected object preservation across async data refreshes | Yes |
54
+ | Dialog and overflow-container support through `appendToBody` / `tagToBody` | Yes |
55
+ | Left-aligned, vertically centered placeholder and single-value text | Yes |
56
+ | Versioned docs builds per Vue line | Yes |
57
+
58
+ ## Table of Contents
59
+
60
+ 1. [Vue Version Compatibility](#vue-version-compatibility)
61
+ 2. [Installation](#installation)
62
+ 3. [Setup](#setup)
63
+ 4. [Styling and Skins](#styling-and-skins)
64
+ 5. [Basic Usage](#basic-usage)
65
+ 6. [Customization Paths](#customization-paths)
66
+ 7. [Typed Helper API](#typed-helper-api)
67
+ 8. [Scoped Slots](#scoped-slots)
68
+ 9. [Headless Usage](#headless-usage)
69
+ 10. [Combobox Contract](#combobox-contract)
70
+ 11. [Official Vue 3 Test Matrix](#official-vue-3-test-matrix)
71
+ 12. [Custom Render Functions](#custom-render-functions)
72
+ 13. [Forms and Controlled State](#forms-and-controlled-state)
73
+ 14. [Lazy Loading and Dynamic Data](#lazy-loading-and-dynamic-data)
74
+ 15. [Dialogs and Overflow Containers](#dialogs-and-overflow-containers)
75
+ 16. [Events](#events)
76
+ 17. [Instance Methods](#instance-methods)
77
+ 18. [Run Locally](#run-locally)
78
+ 19. [License](#license)
22
79
 
23
80
  ## Vue Version Compatibility
24
81
 
25
- | Package family | Vue family | Peer range | First tested runtime | Demo link |
82
+ Each package family installs on its matching Vue family. Keep the package family aligned with the Vue major used by your application.
83
+
84
+ | Package family | Vue family | Peer range | Tested release window | Demo link |
26
85
  | :---: | :---: | :---: | :---: | :--- |
27
- | **3.x** | **Vue 3 only** | **`>=3.0.0 <4.0.0`** | **3.0.0** | [Vue 3 family docs](https://alexandro.net/docs/vue/multiselect/vue-3/) |
86
+ | **3.x** | **Vue 3 only** | **`>=3.0.0 <4.0.0`** | **3.0.0 through 3.5.35** | [Vue 3 family docs](https://alexandro.net/docs/vue/multiselect/vue-3/) |
28
87
  | **2.x** | **Vue 2 only** | **`>=2.0.0 <3.0.0`** | **2.0.0** | [Vue 2 family docs](https://alexandro.net/docs/vue/multiselect/vue-2/) |
29
88
 
30
89
  ## Installation
@@ -32,7 +91,7 @@ The package follows a familiar Stackline settings contract while staying idiomat
32
91
  For Vue 3 applications:
33
92
 
34
93
  ```bash
35
- npm install @stackline/vue-multiselect-dropdown@3.0.2 --save-exact
94
+ npm install @stackline/vue-multiselect-dropdown@3.1.0 --save-exact
36
95
  ```
37
96
 
38
97
  For Vue 2 applications:
@@ -41,74 +100,574 @@ For Vue 2 applications:
41
100
  npm install @stackline/vue-multiselect-dropdown@2.0.0 --save-exact
42
101
  ```
43
102
 
103
+ The styled component injects its component styles at runtime. The renderless composables do not require the built-in DOM and let your application own the markup and styling.
104
+
44
105
  ## Setup
45
106
 
107
+ ### 1. Import the component
108
+
46
109
  ```js
47
110
  import { createApp } from 'vue';
48
111
  import {
49
112
  VueMultiselect,
50
113
  VueMultiselectDropdown
51
114
  } from '@stackline/vue-multiselect-dropdown';
115
+ ```
52
116
 
53
- const app = createApp({
54
- components: { VueMultiselectDropdown },
55
- data() {
56
- return {
57
- countries: [
58
- { id: 1, itemName: 'Brazil' },
59
- { id: 2, itemName: 'Canada' },
60
- { id: 3, itemName: 'Portugal' }
61
- ],
62
- selectedCountries: [],
63
- settings: {
64
- text: 'Select countries',
65
- enableSearchFilter: true,
66
- primaryKey: 'id',
67
- labelKey: 'itemName',
68
- badgeShowLimit: 3,
69
- skin: 'classic'
70
- }
71
- };
72
- }
73
- });
117
+ ### 2. Keep selection in Vue state
118
+
119
+ ```js
120
+ const selectedCountries = ref([]);
121
+ ```
122
+
123
+ ### 3. Pass a stable settings object
124
+
125
+ ```js
126
+ const settings = {
127
+ text: 'Select countries',
128
+ enableSearchFilter: true,
129
+ primaryKey: 'id',
130
+ labelKey: 'itemName',
131
+ badgeShowLimit: 3,
132
+ skin: 'classic'
133
+ };
134
+ ```
135
+
136
+ Register globally:
137
+
138
+ ```js
139
+ const app = createApp(App);
74
140
 
75
141
  app.use(VueMultiselect);
76
142
  app.mount('#app');
77
143
  ```
78
144
 
79
- ```html
80
- <vue-multiselect-dropdown
81
- :data="countries"
82
- v-model="selectedCountries"
83
- :settings="settings"
84
- />
145
+ Or register locally:
146
+
147
+ ```js
148
+ export default {
149
+ components: { VueMultiselectDropdown }
150
+ };
151
+ ```
152
+
153
+ ## Styling and Skins
154
+
155
+ Use `settings.skin` to switch the visual mode:
156
+
157
+ ```js
158
+ settings.skin = 'material';
159
+ ```
160
+
161
+ Built-in skins:
162
+
163
+ | Skin | Usage |
164
+ | :--- | :--- |
165
+ | `classic` | Compact classic dropdown styling. |
166
+ | `material` | Material-style rounded controls and chips. |
167
+ | `dark` | Dark UI surfaces. |
168
+ | `custom` | CSS-variable starter skin for custom projects. |
169
+ | `brand` | Stackline brand skin. |
170
+
171
+ `settings.theme` is accepted as a legacy alias, but new Vue usage should configure only `settings.skin`.
172
+
173
+ ## Basic Usage
174
+
175
+ ```vue
176
+ <script setup>
177
+ import { ref } from 'vue';
178
+ import {
179
+ VueMultiselectDropdown,
180
+ defineSettings
181
+ } from '@stackline/vue-multiselect-dropdown';
182
+
183
+ const countries = [
184
+ { id: 1, itemName: 'Brazil', capital: 'Brasilia', region: 'South America' },
185
+ { id: 2, itemName: 'Canada', capital: 'Ottawa', region: 'North America' },
186
+ { id: 3, itemName: 'Portugal', capital: 'Lisbon', region: 'Europe' },
187
+ { id: 4, itemName: 'United States', capital: 'Washington, DC', region: 'North America' },
188
+ { id: 5, itemName: 'Argentina', capital: 'Buenos Aires', region: 'South America' },
189
+ { id: 6, itemName: 'Mexico', capital: 'Mexico City', region: 'North America' }
190
+ ];
191
+
192
+ const selectedCountries = ref([countries[1]]);
193
+
194
+ const settings = defineSettings({
195
+ singleSelection: false,
196
+ text: 'Select countries',
197
+ selectAllText: 'Select all',
198
+ unSelectAllText: 'Clear all',
199
+ enableSearchFilter: true,
200
+ searchPlaceholderText: 'Search',
201
+ primaryKey: 'id',
202
+ labelKey: 'itemName',
203
+ badgeShowLimit: 4,
204
+ maxHeight: 260,
205
+ showCheckbox: true,
206
+ noDataLabel: 'No data',
207
+ skin: 'classic',
208
+ appendToBody: false
209
+ });
210
+
211
+ function handleSelect(item) {
212
+ console.log('selected', item);
213
+ }
214
+
215
+ function handleRemove(item) {
216
+ console.log('removed', item);
217
+ }
218
+ </script>
219
+
220
+ <template>
221
+ <VueMultiselectDropdown
222
+ :data="countries"
223
+ v-model="selectedCountries"
224
+ :settings="settings"
225
+ @select="handleSelect"
226
+ @de-select="handleRemove"
227
+ @select-all="(items) => console.log('selected all', items)"
228
+ @de-select-all="(items) => console.log('cleared all', items)"
229
+ />
230
+ </template>
231
+ ```
232
+
233
+ ## Customization Paths
234
+
235
+ Use the API layer that matches the amount of control your team needs:
236
+
237
+ | Layer | Best for | What you own |
238
+ | :--- | :--- | :--- |
239
+ | `<VueMultiselectDropdown />` | Fast forms, filters, dashboards, and admin screens. | Data, selected state, settings, events, and optional render functions. |
240
+ | `createVueMultiselectDropdown<T>()` | Teams that want a typed helper around settings and composables. | Typed state/composable usage for a feature or design-system wrapper. |
241
+ | Scoped slots | Custom Vue HTML around the proven component behavior. | Specific DOM pieces such as trigger, badges, menu footer, group headers, and options. |
242
+ | `useMultiSelectDropdown` | Fully custom interfaces and design systems. | All markup and CSS, while Stackline provides state, ARIA prop bags, keyboard flow, grouping, and callbacks. |
243
+ | `useMultiSelectState` | Advanced state engines or existing combobox shells. | Every element, every event binding, and all visual behavior. |
244
+
245
+ For most teams, start with the component. Use scoped slots when the component works but your layout needs a different shell. Use the renderless composables when the application must own the whole combobox contract.
246
+
247
+ ## Typed Helper API
248
+
249
+ Use `createVueMultiselectDropdown<T>()` when a feature, package, or design-system wrapper should bind the item type once and reuse it across settings and composables.
250
+
251
+ This is optional. The normal `<VueMultiselectDropdown />` API remains the fastest path for most screens.
252
+
253
+ ```ts
254
+ import {
255
+ createVueMultiselectDropdown
256
+ } from '@stackline/vue-multiselect-dropdown';
257
+
258
+ type Country = {
259
+ id: number;
260
+ itemName: string;
261
+ capital: string;
262
+ region: string;
263
+ };
264
+
265
+ const CountryMultiselect = createVueMultiselectDropdown<Country>();
266
+
267
+ const countrySettings = CountryMultiselect.defineSettings({
268
+ text: 'Choose countries',
269
+ primaryKey: 'id',
270
+ labelKey: 'itemName',
271
+ searchBy: ['itemName', 'capital'],
272
+ groupBy: 'region',
273
+ enableSearchFilter: true,
274
+ badgeShowLimit: 2
275
+ });
276
+
277
+ export function useCountryMultiselect(countries, selectedCountries) {
278
+ return CountryMultiselect.useMultiSelectDropdown({
279
+ data: countries,
280
+ selectedItems: selectedCountries,
281
+ settings: countrySettings,
282
+ onChange(items) {
283
+ selectedCountries.value = items;
284
+ }
285
+ });
286
+ }
85
287
  ```
86
288
 
87
- ## Skins
289
+ The helper is useful when a design-system wrapper wants one typed place for settings, state, and renderless dropdown behavior. The styled Vue component remains available for normal template usage.
290
+
291
+ ## Scoped Slots
292
+
293
+ Scoped slots let you replace the visible Vue HTML pieces while the package still owns the tested selection, filtering, keyboard, focus, ARIA, body overlay, and async behavior.
88
294
 
89
- Use `settings.skin` for `classic`, `material`, `dark`, `custom`, and `brand`.
295
+ The important rule is simple: keep the provided slot callbacks and ARIA values connected to your custom elements. They carry the behavior that makes the component accessible.
90
296
 
91
- `settings.theme` is accepted only as a compatibility alias. Prefer `settings.skin` in new code.
297
+ ```vue
298
+ <script setup>
299
+ import { ref } from 'vue';
300
+ import { VueMultiselectDropdown } from '@stackline/vue-multiselect-dropdown';
301
+
302
+ const selectedCountries = ref([]);
303
+
304
+ const countries = [
305
+ { id: 1, itemName: 'Brazil', capital: 'Brasilia', region: 'South America' },
306
+ { id: 2, itemName: 'Canada', capital: 'Ottawa', region: 'North America' },
307
+ { id: 3, itemName: 'Portugal', capital: 'Lisbon', region: 'Europe' }
308
+ ];
309
+
310
+ const settings = {
311
+ text: 'Choose countries',
312
+ enableSearchFilter: true,
313
+ groupBy: 'region',
314
+ primaryKey: 'id',
315
+ labelKey: 'itemName',
316
+ badgeShowLimit: 2,
317
+ skin: 'classic'
318
+ };
319
+ </script>
320
+
321
+ <template>
322
+ <VueMultiselectDropdown
323
+ :data="countries"
324
+ v-model="selectedCountries"
325
+ :settings="settings"
326
+ >
327
+ <template #option="{ item, label, selected, ariaSelected, ariaChecked, toggle }">
328
+ <button
329
+ type="button"
330
+ class="country-option"
331
+ :aria-pressed="selected"
332
+ @click.stop="toggle"
333
+ >
334
+ <span>
335
+ <strong>{{ label }}</strong>
336
+ <small>{{ item.capital }} - {{ item.region }}</small>
337
+ </span>
338
+ <code>{{ ariaSelected }}/{{ ariaChecked }}</code>
339
+ </button>
340
+ </template>
341
+
342
+ <template #badge="{ label, remove }">
343
+ <span class="country-badge">
344
+ {{ label }}
345
+ <button type="button" @click.stop="remove">Remove</button>
346
+ </span>
347
+ </template>
348
+
349
+ <template #menu-footer="{ selected, filteredItems }">
350
+ <div class="country-footer">
351
+ {{ selected.length }} selected - {{ filteredItems.length }} visible
352
+ </div>
353
+ </template>
354
+ </VueMultiselectDropdown>
355
+ </template>
356
+ ```
357
+
358
+ Available scoped slots:
359
+
360
+ `trigger`, `placeholder`, `badge`, `option`, `loading`, `empty`, `group-header`, and `menu-footer`.
361
+
362
+ ## Headless Usage
363
+
364
+ Use `useMultiSelectDropdown` when you want Stackline selection, filtering, keyboard handling, ARIA prop bags, grouping, limits, and callbacks without the built-in DOM/CSS.
365
+
366
+ The flag sample below uses SVG country icons from `flag-icons`. You can replace that import with your own icon system if your app already has one.
367
+
368
+ ```bash
369
+ npm install flag-icons
370
+ ```
371
+
372
+ ```vue
373
+ <script setup>
374
+ import { computed, ref } from 'vue';
375
+ import 'flag-icons/css/flag-icons.min.css';
376
+ import { useMultiSelectDropdown } from '@stackline/vue-multiselect-dropdown';
377
+
378
+ const countries = [
379
+ { id: 1, itemName: 'Brazil', flag: 'BR', capital: 'Brasilia', region: 'Americas' },
380
+ { id: 2, itemName: 'Canada', flag: 'CA', capital: 'Ottawa', region: 'Americas' },
381
+ { id: 3, itemName: 'Portugal', flag: 'PT', capital: 'Lisbon', region: 'Europe' }
382
+ ];
383
+
384
+ const selectedItems = ref([countries[0]]);
385
+
386
+ const dropdown = useMultiSelectDropdown({
387
+ data: countries,
388
+ selectedItems,
389
+ onChange(items) {
390
+ selectedItems.value = items;
391
+ },
392
+ settings: {
393
+ text: 'Choose countries',
394
+ enableSearchFilter: true,
395
+ searchPlaceholderText: 'Search country',
396
+ groupBy: 'region',
397
+ primaryKey: 'id',
398
+ labelKey: 'itemName',
399
+ badgeShowLimit: 2,
400
+ clearAll: true
401
+ }
402
+ });
403
+
404
+ const selectedSummary = computed(() => (
405
+ dropdown.selectedItems.value.length
406
+ ? `${dropdown.selectedItems.value.length} selected`
407
+ : 'No selected countries'
408
+ ));
409
+
410
+ function flagClass(code) {
411
+ return `fi fi-${code.toLowerCase()}`;
412
+ }
413
+ </script>
414
+
415
+ <template>
416
+ <div class="country-picker" v-bind="dropdown.getRootProps()">
417
+ <button class="country-trigger" v-bind="dropdown.getTriggerProps()">
418
+ <span>{{ dropdown.label.value }}</span>
419
+ <strong>{{ dropdown.isOpen.value ? 'Close' : 'Open' }}</strong>
420
+ </button>
421
+
422
+ <div class="country-chips" :aria-label="selectedSummary">
423
+ <span
424
+ v-for="item in dropdown.selectedItems.value"
425
+ :key="dropdown.getItemKey(item)"
426
+ class="country-chip"
427
+ >
428
+ <span :class="['country-flag', flagClass(item.flag)]" aria-hidden="true" />
429
+ {{ dropdown.getItemLabel(item) }}
430
+ <button v-bind="dropdown.getRemoveButtonProps(item)">x</button>
431
+ </span>
432
+ </div>
433
+
434
+ <div
435
+ v-if="dropdown.isOpen.value"
436
+ class="country-panel"
437
+ v-bind="dropdown.getListboxProps()"
438
+ >
439
+ <input class="country-search" v-bind="dropdown.getSearchInputProps()" />
440
+
441
+ <div
442
+ v-for="option in dropdown.visibleOptions.value"
443
+ :key="option.key"
444
+ v-bind="dropdown.getOptionProps(option, {
445
+ class: option.selected ? 'country-option selected' : 'country-option'
446
+ })"
447
+ >
448
+ <span :class="['country-flag', flagClass(option.item.flag)]" aria-hidden="true" />
449
+ <span>
450
+ <strong>{{ option.label }}</strong>
451
+ <small>{{ option.item.capital }} - {{ option.item.region }}</small>
452
+ </span>
453
+ <input type="checkbox" :checked="option.selected" readonly />
454
+ </div>
455
+ </div>
456
+ </div>
457
+ </template>
458
+ ```
459
+
460
+ Use `useMultiSelectState` when you want the selection/filter/grouping engine without prop bags:
461
+
462
+ ```js
463
+ import { useMultiSelectState } from '@stackline/vue-multiselect-dropdown';
464
+
465
+ const state = useMultiSelectState({
466
+ data: countries,
467
+ selectedItems,
468
+ onChange(items) {
469
+ selectedItems.value = items;
470
+ },
471
+ settings: {
472
+ primaryKey: 'id',
473
+ labelKey: 'itemName',
474
+ enableSearchFilter: true
475
+ }
476
+ });
477
+ ```
478
+
479
+ The styled component remains available for drop-in usage. The renderless composables are for teams that want a headless-style ownership model where the application controls layout, elements, and CSS.
480
+
481
+ ## Combobox Contract
482
+
483
+ Version `3.1.0` tightens the interaction details that usually matter most in production forms:
484
+
485
+ | Behavior | Contract |
486
+ | :--- | :--- |
487
+ | Focus after selection/removal | Focus returns to search while the list stays open, or to the trigger when the list closes. |
488
+ | Option selection state | Multiselect options expose matching `aria-selected` and `aria-checked` values. |
489
+ | Backspace in search | Edits the query. With an empty query it does not remove selected values by default. |
490
+ | Backspace/Delete on focused badge remove button | Removes that selected badge. |
491
+ | Escape | Closes the list without clearing selected values. |
492
+ | Async option refresh | Selected object values stay stable by `primaryKey` when data refreshes. |
493
+ | Keyboard navigation | Trigger ArrowDown/ArrowUp, option Home/End, and option ids keep focus and ARIA predictable. |
494
+
495
+ Keyboard behavior is enabled by default. You can turn each part off from `settings.keyboard` when an application needs a stricter interaction model:
496
+
497
+ ```js
498
+ const settings = {
499
+ text: 'Countries',
500
+ enableSearchFilter: true,
501
+ keyboard: {
502
+ space: true,
503
+ spaceOptionAction: 'toggle',
504
+ tab: true,
505
+ arrows: true,
506
+ escape: true,
507
+ backspaceRemovesLastWhenSearchEmpty: false,
508
+ deleteRemovesFocusedBadge: true
509
+ }
510
+ };
511
+ ```
512
+
513
+ Set any key to `false` to disable that behavior. `backspaceRemovesLastWhenSearchEmpty` can be turned on for applications that want the legacy "empty search removes last badge" pattern. `keyboard.backspace` is still accepted as a deprecated alias for that legacy behavior. `spaceOptionAction` controls only focused options:
514
+ `'toggle'` keeps focus on the current option, while `'toggle-and-next'` toggles and moves to the next enabled option.
515
+ `escapeToClose: false` is still supported and also disables `keyboard.escape`.
516
+
517
+ ## Official Vue 3 Test Matrix
518
+
519
+ The Vue 3 release was tested in a clean Vue `3.5.35` application with `@stackline/vue-multiselect-dropdown@3.1.0`. The docs use the same examples from that test app, including keyboard navigation, focus, ARIA behavior, badge counters, responsive action buttons, scrollable lists, dialog-safe body overlays, the corrected left-aligned placeholder with vertical centering, scoped-slot customization, headless/custom HTML, and the combobox contract checks for Backspace, Escape, focused badge removal, focus, and option ARIA.
520
+
521
+ The same core scenarios are validated for the visual skins:
522
+
523
+ | # | Scenario | Main settings tested |
524
+ | :---: | :--- | :--- |
525
+ | 01 | Basic multi | `{ enableSearchFilter: true }` |
526
+ | 02 | All selected badges visible | `{ badgeShowLimit: 10 }` |
527
+ | 03 | Single selection | `{ singleSelection: true }` |
528
+ | 04 | Search by fields | `{ searchBy: ['itemName', 'capital'] }` |
529
+ | 05 | Grouped options | `{ groupBy: 'category', selectGroup: true }` |
530
+ | 06 | Selection limit | `{ limitSelection: 2, badgeShowLimit: 2 }` |
531
+ | 07 | Custom rendering | `renderItem` and `renderBadge` |
532
+ | 08 | Search and add item | `{ addNewItemOnFilter: true }` |
533
+ | 09 | Disabled state | `{ disabled: true }` |
534
+ | 10 | Controlled form validation | Vue state and derived validation |
535
+ | 11 | Long list with keyboard scroll | `{ maxHeight: 140 }` |
536
+ | 12 | Local lazy loading | `{ lazyLoading: true }` |
537
+ | 13 | Dialog and overflow container | `{ appendToBody: true, tagToBody: true }` |
538
+ | 14 | Body overlay auto direction | `{ autoPosition: true, position: 'top' }` |
539
+ | 15 | Instance methods | `openDropdown`, `closeDropdown`, `selectAll`, `clearSelection` |
540
+ | 16 | Scoped slots custom HTML | `#trigger`, `#option`, `#badge`, `#group-header`, `#menu-footer` |
541
+
542
+ ## Custom Render Functions
543
+
544
+ Use `renderItem` for option rows and `renderBadge` for selected chips when you only need to replace inner content. Use scoped slots when you need to replace component structure.
545
+
546
+ ```vue
547
+ <script setup>
548
+ import { h, ref } from 'vue';
549
+ import { VueMultiselectDropdown } from '@stackline/vue-multiselect-dropdown';
550
+
551
+ const selectedCountries = ref([]);
552
+
553
+ function renderItem(item, context) {
554
+ return h('span', [
555
+ h('strong', context.label),
556
+ h('small', item.capital)
557
+ ]);
558
+ }
559
+
560
+ function renderBadge(item) {
561
+ return h('span', item.itemName);
562
+ }
563
+ </script>
564
+
565
+ <template>
566
+ <VueMultiselectDropdown
567
+ :data="countries"
568
+ v-model="selectedCountries"
569
+ :settings="settings"
570
+ :render-item="renderItem"
571
+ :render-badge="renderBadge"
572
+ />
573
+ </template>
574
+ ```
575
+
576
+ ## Forms and Controlled State
577
+
578
+ Keep the selected array in Vue state and derive validity from that state:
579
+
580
+ ```vue
581
+ <script setup>
582
+ import { computed, ref } from 'vue';
583
+ import { VueMultiselectDropdown } from '@stackline/vue-multiselect-dropdown';
584
+
585
+ const name = ref('');
586
+ const email = ref('');
587
+ const selectedSkills = ref([]);
588
+
589
+ const formIsValid = computed(() => (
590
+ email.value.trim().length > 0 && selectedSkills.value.length > 0
591
+ ));
592
+ </script>
593
+
594
+ <template>
595
+ <form @submit.prevent>
596
+ <input v-model="name" />
597
+ <input v-model="email" />
598
+
599
+ <VueMultiselectDropdown
600
+ :data="skills"
601
+ v-model="selectedSkills"
602
+ :settings="skillSettings"
603
+ />
604
+
605
+ <button type="submit" :disabled="!formIsValid">
606
+ Submit
607
+ </button>
608
+ </form>
609
+ </template>
610
+ ```
611
+
612
+ ## Lazy Loading and Dynamic Data
613
+
614
+ Enable lazy loading through the settings object and append more rows when the list reaches the end:
615
+
616
+ ```vue
617
+ <script setup>
618
+ import { ref } from 'vue';
619
+ import { VueMultiselectDropdown } from '@stackline/vue-multiselect-dropdown';
620
+
621
+ const people = ref(loadFirstPage());
622
+ const selectedPeople = ref([]);
623
+
624
+ const settings = {
625
+ text: 'Select people',
626
+ enableSearchFilter: true,
627
+ lazyLoading: true,
628
+ labelKey: 'name',
629
+ primaryKey: 'id',
630
+ maxHeight: 140
631
+ };
632
+
633
+ function appendPeople() {
634
+ people.value = people.value.concat(loadMorePeople());
635
+ }
636
+ </script>
637
+
638
+ <template>
639
+ <VueMultiselectDropdown
640
+ :data="people"
641
+ v-model="selectedPeople"
642
+ :settings="settings"
643
+ @scroll-to-end="appendPeople"
644
+ />
645
+ </template>
646
+ ```
92
647
 
93
648
  ## Dialogs and Overflow Containers
94
649
 
95
650
  Use `appendToBody: true` or `tagToBody: true` when the dropdown is inside dialogs, modals, drawers, or containers that set `overflow: hidden` or `overflow: auto`.
96
651
 
97
652
  ```js
98
- settings: {
653
+ const settings = {
99
654
  text: 'Dialog dropdown',
100
655
  enableSearchFilter: true,
101
656
  skin: 'material',
102
657
  appendToBody: true,
103
658
  tagToBody: true,
104
659
  autoPosition: true
105
- }
660
+ };
106
661
  ```
107
662
 
108
- With body overlay enabled, the open panel is moved to `document.body`, aligned to the original trigger, sized to the trigger, recalculated on open, scroll, resize, and selection changes, then restored and cleaned up when the dropdown closes or unmounts.
663
+ With body overlay enabled, the open panel is rendered against `document.body`, aligned to the original trigger, sized to the trigger, recalculated on open, scroll, resize, and content changes, and cleaned up when the dropdown closes or the component unmounts.
664
+
665
+ `autoPosition: true` treats `position` as a preferred direction. The menu opens upward only when there is meaningfully less room below and enough room above; otherwise it opens below and shrinks the scrollable list height to stay visible without covering the trigger.
109
666
 
110
667
  ## Events
111
668
 
669
+ Available Vue events:
670
+
112
671
  - `input`
113
672
  - `change`
114
673
  - `select`
@@ -124,14 +683,42 @@ With body overlay enabled, the open panel is moved to `document.body`, aligned t
124
683
 
125
684
  ## Instance Methods
126
685
 
127
- ```js
128
- this.$refs.dropdown.openDropdown();
129
- this.$refs.dropdown.closeDropdown();
130
- this.$refs.dropdown.focusSearch();
131
- this.$refs.dropdown.selectAll();
132
- this.$refs.dropdown.clearSelection();
686
+ ```vue
687
+ <script setup>
688
+ import { ref } from 'vue';
689
+ import { VueMultiselectDropdown } from '@stackline/vue-multiselect-dropdown';
690
+
691
+ const dropdownRef = ref(null);
692
+
693
+ function openDropdown() {
694
+ dropdownRef.value?.openDropdown();
695
+ }
696
+
697
+ function clearSelection() {
698
+ dropdownRef.value?.clearSelection();
699
+ }
700
+ </script>
701
+
702
+ <template>
703
+ <VueMultiselectDropdown
704
+ ref="dropdownRef"
705
+ :data="countries"
706
+ v-model="selectedCountries"
707
+ :settings="settings"
708
+ />
709
+ </template>
133
710
  ```
134
711
 
712
+ Available methods:
713
+
714
+ - `openDropdown()`
715
+ - `closeDropdown()`
716
+ - `focusSearch()`
717
+ - `selectAll()`
718
+ - `deSelectAll()`
719
+ - `clearSelection()`
720
+ - `getSelectedItems()`
721
+
135
722
  ## Run Locally
136
723
 
137
724
  ```bash