svelte-multiselect 8.2.0 → 8.2.1
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/MultiSelect.svelte +40 -37
- package/changelog.md +22 -11
- package/package.json +1 -1
- package/readme.md +27 -23
package/MultiSelect.svelte
CHANGED
|
@@ -238,7 +238,7 @@ async function handle_keydown(event) {
|
|
|
238
238
|
activeIndex = 0;
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
-
else if (allowUserOptions && searchText.length > 0) {
|
|
241
|
+
else if (allowUserOptions && !matchingOptions.length && searchText.length > 0) {
|
|
242
242
|
// if allowUserOptions is truthy and user entered text but no options match, we make
|
|
243
243
|
// <li>{addUserMsg}</li> active on keydown (or toggle it if already active)
|
|
244
244
|
add_option_msg_is_active = !add_option_msg_is_active;
|
|
@@ -248,7 +248,8 @@ async function handle_keydown(event) {
|
|
|
248
248
|
// if no option is active and no options are matching, do nothing
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
// if none of the above special cases apply, we make next/prev option
|
|
252
253
|
// active with wrap around at both ends
|
|
253
254
|
const increment = event.key === `ArrowUp` ? -1 : 1;
|
|
254
255
|
activeIndex = (activeIndex + increment) % matchingOptions.length;
|
|
@@ -393,37 +394,39 @@ const dragstart = (idx) => (event) => {
|
|
|
393
394
|
{/if}
|
|
394
395
|
</li>
|
|
395
396
|
{/each}
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
397
|
+
<li style="display: contents;">
|
|
398
|
+
<input
|
|
399
|
+
class={inputClass}
|
|
400
|
+
bind:this={input}
|
|
401
|
+
{autocomplete}
|
|
402
|
+
bind:value={searchText}
|
|
403
|
+
on:mouseup|self|stopPropagation={open_dropdown}
|
|
404
|
+
on:keydown|stopPropagation={handle_keydown}
|
|
405
|
+
on:focus
|
|
406
|
+
on:focus={open_dropdown}
|
|
407
|
+
{id}
|
|
408
|
+
{disabled}
|
|
409
|
+
{inputmode}
|
|
410
|
+
{pattern}
|
|
411
|
+
placeholder={selected.length == 0 ? placeholder : null}
|
|
412
|
+
aria-invalid={invalid ? `true` : null}
|
|
413
|
+
ondrop="return false"
|
|
414
|
+
on:blur
|
|
415
|
+
on:change
|
|
416
|
+
on:click
|
|
417
|
+
on:keydown
|
|
418
|
+
on:keyup
|
|
419
|
+
on:mousedown
|
|
420
|
+
on:mouseenter
|
|
421
|
+
on:mouseleave
|
|
422
|
+
on:touchcancel
|
|
423
|
+
on:touchend
|
|
424
|
+
on:touchmove
|
|
425
|
+
on:touchstart
|
|
426
|
+
/>
|
|
427
|
+
<!-- the above on:* lines forward potentially useful DOM events -->
|
|
428
|
+
</li>
|
|
425
429
|
</ul>
|
|
426
|
-
<!-- the above on:* lines forward potentially useful DOM events -->
|
|
427
430
|
{#if loading}
|
|
428
431
|
<slot name="spinner">
|
|
429
432
|
<CircleSpinner />
|
|
@@ -533,7 +536,7 @@ const dragstart = (idx) => (event) => {
|
|
|
533
536
|
border: var(--sms-border, 1pt solid lightgray);
|
|
534
537
|
border-radius: var(--sms-border-radius, 3pt);
|
|
535
538
|
background: var(--sms-bg);
|
|
536
|
-
width: var(--sms-width
|
|
539
|
+
width: var(--sms-width);
|
|
537
540
|
max-width: var(--sms-max-width);
|
|
538
541
|
padding: var(--sms-padding, 0 3pt);
|
|
539
542
|
color: var(--sms-text-color);
|
|
@@ -603,19 +606,19 @@ const dragstart = (idx) => (event) => {
|
|
|
603
606
|
margin: auto 0; /* CSS reset */
|
|
604
607
|
padding: 0; /* CSS reset */
|
|
605
608
|
}
|
|
606
|
-
:where(div.multiselect > ul.selected > input) {
|
|
609
|
+
:where(div.multiselect > ul.selected > li > input) {
|
|
607
610
|
border: none;
|
|
608
611
|
outline: none;
|
|
609
612
|
background: none;
|
|
613
|
+
flex: 1; /* this + next line fix issue #12 https://git.io/JiDe3 */
|
|
614
|
+
min-width: 2em;
|
|
610
615
|
/* ensure input uses text color and not --sms-selected-text-color */
|
|
611
616
|
color: var(--sms-text-color);
|
|
612
617
|
font-size: inherit;
|
|
613
618
|
cursor: inherit; /* needed for disabled state */
|
|
614
619
|
border-radius: 0; /* reset ul.selected > li */
|
|
615
|
-
width: 100%;
|
|
616
|
-
flex: 1;
|
|
617
620
|
}
|
|
618
|
-
:where(div.multiselect > ul.selected > input::placeholder) {
|
|
621
|
+
:where(div.multiselect > ul.selected > li > input::placeholder) {
|
|
619
622
|
padding-left: 5pt;
|
|
620
623
|
color: var(--sms-placeholder-color);
|
|
621
624
|
opacity: var(--sms-placeholder-opacity);
|
package/changelog.md
CHANGED
|
@@ -2,8 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
|
4
4
|
|
|
5
|
+
#### [v8.2.1](https://github.com/janosh/svelte-multiselect/compare/v8.2.0...v8.2.1)
|
|
6
|
+
|
|
7
|
+
- Fix `allowUserOptions` preventing dropdown list navigation with up/down arrow keys [`#184`](https://github.com/janosh/svelte-multiselect/pull/184)
|
|
8
|
+
- Mdsvexamples [`#182`](https://github.com/janosh/svelte-multiselect/pull/182)
|
|
9
|
+
- Add changelog & contributing pages to site [`#181`](https://github.com/janosh/svelte-multiselect/pull/181)
|
|
10
|
+
- tweak contributing.md and css-classes example [`6f78033`](https://github.com/janosh/svelte-multiselect/commit/6f78033826beb34cd00bf3282c93ac5328905735)
|
|
11
|
+
- fix build error [`b896d36`](https://github.com/janosh/svelte-multiselect/commit/b896d3643a0988b0d0bed832ba46bcad0e2c4494)
|
|
12
|
+
- fix readme badge for gh-pages.yml status [`906b560`](https://github.com/janosh/svelte-multiselect/commit/906b56024a826ed45263197b1267015d88f0a660)
|
|
13
|
+
|
|
14
|
+
<!-- auto-changelog-above -->
|
|
15
|
+
|
|
5
16
|
#### [v8.2.0](https://github.com/janosh/svelte-multiselect/compare/v8.1.0...v8.2.0)
|
|
6
17
|
|
|
18
|
+
> 30 November 2022
|
|
19
|
+
|
|
7
20
|
- Draggable selected options [`#178`](https://github.com/janosh/svelte-multiselect/pull/178)
|
|
8
21
|
- Fix page navigation in GH pages, broken because served from non-apex domain [`#172`](https://github.com/janosh/svelte-multiselect/pull/172)
|
|
9
22
|
- Publish docs to GitHub pages [`#170`](https://github.com/janosh/svelte-multiselect/pull/170)
|
|
@@ -11,11 +24,9 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
11
24
|
- add missing about field to bug-report issue template (closes #171) [`#171`](https://github.com/janosh/svelte-multiselect/issues/171)
|
|
12
25
|
- add changelog.md [`236d238`](https://github.com/janosh/svelte-multiselect/commit/236d238c5fa1ce5f07cf08c09861da4d8446acb2)
|
|
13
26
|
- fix prop form_input: set default value null to make it optional [`b150fe0`](https://github.com/janosh/svelte-multiselect/commit/b150fe0032ebde82a319b23bd5e6b573e0c31721)
|
|
14
|
-
- set aliveStatusCodes: [200, 429] in
|
|
27
|
+
- set `aliveStatusCodes: [200, 429]` in `.github/workflows/link-check-config.json` [`b34c7bf`](https://github.com/janosh/svelte-multiselect/commit/b34c7bf99d4afa96dcd3c9c322ab4e94b1ef3a39)
|
|
15
28
|
- add changelog script to `package.json` [`c943617`](https://github.com/janosh/svelte-multiselect/commit/c9436171033e06e8098f4443ed40d48ddee35167)
|
|
16
29
|
|
|
17
|
-
<!-- auto-changelog-above -->
|
|
18
|
-
|
|
19
30
|
#### [v8.1.0](https://github.com/janosh/svelte-multiselect/compare/v8.0.4...v8.1.0)
|
|
20
31
|
|
|
21
32
|
> 18 November 2022
|
|
@@ -41,7 +52,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
41
52
|
- Test uncovered lines [`#157`](https://github.com/janosh/svelte-multiselect/pull/157)
|
|
42
53
|
- Don't `console.error` about missing `options` if `loading=true` [`#156`](https://github.com/janosh/svelte-multiselect/pull/156)
|
|
43
54
|
- Measure `vitest` coverage with `c8` [`#155`](https://github.com/janosh/svelte-multiselect/pull/155)
|
|
44
|
-
- increase --sms-min-height 19
|
|
55
|
+
- increase --sms-min-height 19->`22pt [`5d0e081`](<https://github.com/janosh/svelte-multiselect/commit/5d0e0815d0b488ae23b439a3f085dd083138c326>)
|
|
45
56
|
|
|
46
57
|
#### [v8.0.2](https://github.com/janosh/svelte-multiselect/compare/v8.0.1...v8.0.2)
|
|
47
58
|
|
|
@@ -67,7 +78,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
67
78
|
- Add new prop `value` [`#138`](https://github.com/janosh/svelte-multiselect/pull/138)
|
|
68
79
|
- New prop resetFilterOnAdd [`#137`](https://github.com/janosh/svelte-multiselect/pull/137)
|
|
69
80
|
- `yarn` to `pnpm` [`#134`](https://github.com/janosh/svelte-multiselect/pull/134)
|
|
70
|
-
- Rename prop `noOptionsMsg
|
|
81
|
+
- Rename prop `noOptionsMsg -> noMatchingOptionsMsg` [`#133`](https://github.com/janosh/svelte-multiselect/pull/133)
|
|
71
82
|
- remove props selectedLabels and selectedValues [`ef6598e`](https://github.com/janosh/svelte-multiselect/commit/ef6598e8b0dc1f2f8cb687074463cb73b2f9ebff)
|
|
72
83
|
|
|
73
84
|
#### [v7.1.0](https://github.com/janosh/svelte-multiselect/compare/v7.0.2...v7.1.0)
|
|
@@ -173,7 +184,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
173
184
|
|
|
174
185
|
- Replace `li.scrollIntoViewIfNeeded()` with `li.scrollIntoView()` [`#88`](https://github.com/janosh/svelte-multiselect/pull/88)
|
|
175
186
|
- Add new prop `parseLabelsAsHtml` [`#84`](https://github.com/janosh/svelte-multiselect/pull/84)
|
|
176
|
-
- try fix flaky test 'multiselect
|
|
187
|
+
- try fix flaky test 'multiselect >`can select and remove many options' [`2b0c453`](<https://github.com/janosh/svelte-multiselect/commit/2b0c453c794c0b3b82e81c5b994c10bc305a98d6>)
|
|
177
188
|
- bump netlify node to v18, update readme + deps [`586c724`](https://github.com/janosh/svelte-multiselect/commit/586c724d471aece2b5a3726bb5eb145e36073fe3)
|
|
178
189
|
- remove plausible.js analytics [`cd4c9f6`](https://github.com/janosh/svelte-multiselect/commit/cd4c9f6e18e13959dfb4fcebe9acba7a875b83a2)
|
|
179
190
|
|
|
@@ -222,7 +233,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
222
233
|
- Add `aria-label` to hidden `.form-control` input [`#62`](https://github.com/janosh/svelte-multiselect/pull/62)
|
|
223
234
|
- Add `aria-label` to hidden `.form-control` input (#62) [`#58`](https://github.com/janosh/svelte-multiselect/issues/58) [`#35`](https://github.com/janosh/svelte-multiselect/issues/35)
|
|
224
235
|
- fix dropdown closing when clicking between list items (closes #61) [`#61`](https://github.com/janosh/svelte-multiselect/issues/61)
|
|
225
|
-
- svelte.config.js add kit.prerender.default: true
|
|
236
|
+
- `svelte.config.js` add `kit.prerender.default: true`, `mv src/{global,app}.d.ts` [`4a84913`](https://github.com/janosh/svelte-multiselect/commit/4a8491380e08bad137ca7bdda9ee4ddd38abe3d6)
|
|
226
237
|
|
|
227
238
|
#### [v4.0.2](https://github.com/janosh/svelte-multiselect/compare/v4.0.1...v4.0.2)
|
|
228
239
|
|
|
@@ -261,7 +272,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
261
272
|
|
|
262
273
|
> 20 February 2022
|
|
263
274
|
|
|
264
|
-
- by default, only show maxSelectMsg if maxSelect != null and
|
|
275
|
+
- by default, only show maxSelectMsg if maxSelect != null and >`1 (closes #37) [`#37`](<https://github.com/janosh/svelte-multiselect/issues/37>)
|
|
265
276
|
- add CSS var --sms-options-shadow defaults to subtle black shadow around dropdown list (0 0 14pt -8pt black) (closes #36) [`#36`](https://github.com/janosh/svelte-multiselect/issues/36)
|
|
266
277
|
- add prop liActiveOptionClass = '' (closes #35) [`#35`](https://github.com/janosh/svelte-multiselect/issues/35)
|
|
267
278
|
- turn searchText = and showOptions = false into bindable props (closes #33) [`#33`](https://github.com/janosh/svelte-multiselect/issues/33)
|
|
@@ -293,7 +304,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
293
304
|
|
|
294
305
|
> 3 February 2022
|
|
295
306
|
|
|
296
|
-
- apply id prop to
|
|
307
|
+
- apply id prop to `<input>` instead of outer div (closes #25) [`#25`](https://github.com/janosh/svelte-multiselect/issues/25)
|
|
297
308
|
- add eslint commit hook + update deps [`6ad44b8`](https://github.com/janosh/svelte-multiselect/commit/6ad44b85057aef71eae19293de80f9d42f91f87b)
|
|
298
309
|
- v.3.2.0 [`71ff2d1`](https://github.com/janosh/svelte-multiselect/commit/71ff2d192caccacbe41f83949c14d7d4ca87d590)
|
|
299
310
|
- add readme badge to document minimum svelte version (for #24) [`7d9fe5a`](https://github.com/janosh/svelte-multiselect/commit/7d9fe5a977b56dab95069b64321f0718e0d61f08)
|
|
@@ -303,7 +314,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
303
314
|
> 25 January 2022
|
|
304
315
|
|
|
305
316
|
- wiggle the maxSelect msg on hitting selection limit (closes #19) [`#19`](https://github.com/janosh/svelte-multiselect/issues/19)
|
|
306
|
-
- readme better docs for CSS variables, rename slots {options,selected}Renderer
|
|
317
|
+
- readme better docs for CSS variables, rename slots `{options,selected}Renderer -> render{options,selected}` [`c8ab724`](https://github.com/janosh/svelte-multiselect/commit/c8ab7241506cfe6b5930d098150a251e85c52afd)
|
|
307
318
|
|
|
308
319
|
#### [v3.1.0](https://github.com/janosh/svelte-multiselect/compare/v3.0.1...v3.1.0)
|
|
309
320
|
|
|
@@ -344,7 +355,7 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
344
355
|
|
|
345
356
|
> 27 October 2021
|
|
346
357
|
|
|
347
|
-
- set
|
|
358
|
+
- set `<input>` width back to 1pt as it's only needed to tab into, focus and blur `<MultiSelect>` (closes #12) [`#12`](https://github.com/janosh/svelte-multiselect/issues/12)
|
|
348
359
|
- update readme [`45c7993`](https://github.com/janosh/svelte-multiselect/commit/45c7993398c986499d4c0729177620cbec719cb7)
|
|
349
360
|
|
|
350
361
|
#### [v1.2.1](https://github.com/janosh/svelte-multiselect/compare/v1.2.0...v1.2.1)
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<h4 align="center">
|
|
7
7
|
|
|
8
8
|
[](https://github.com/janosh/svelte-multiselect/actions/workflows/test.yml)
|
|
9
|
-
[](https://github.com/janosh/svelte-multiselect/actions/workflows/gh-pages.yml)
|
|
10
10
|
[](https://npmjs.com/package/svelte-multiselect)
|
|
11
11
|
[](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md)
|
|
12
12
|
[](https://svelte.dev/repl/a5a14b8f15d64cb083b567292480db05)
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
<slot name="examples" />
|
|
23
23
|
|
|
24
|
-
## Features
|
|
24
|
+
## 💡 Features
|
|
25
25
|
|
|
26
26
|
- **Bindable:** `bind:selected` gives you an array of the currently selected options. Thanks to Svelte's 2-way binding, it can also control the component state externally through assignment `selected = ['foo', 42]`.
|
|
27
27
|
- **Keyboard friendly** for mouse-less form completion
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
- **Searchable:** start typing to filter options
|
|
31
31
|
- **Tagging:** selected options are listed as tags within the input
|
|
32
32
|
- **Single / multiple select:** pass `maxSelect={1, 2, 3, ...}` prop to restrict the number of selectable options
|
|
33
|
-
- **Configurable:** see
|
|
33
|
+
- **Configurable:** see props
|
|
34
34
|
|
|
35
35
|
<slot name="nav" />
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## 📜 Breaking changes
|
|
38
38
|
|
|
39
39
|
- **6.1.0** The `dispatch` events `focus` and `blur` were renamed to `open` and `close`, respectively. These actions refer to the dropdown list, i.e. `<MultiSelect on:open={(event) => console.log(event)}>` will trigger when the dropdown list opens. The focus and blur events are now regular DOM (not Svelte `dispatch`) events emitted by the `<input>` node. [PR 120](https://github.com/janosh/svelte-multiselect/pull/120).
|
|
40
40
|
- **v7.0.0** `selected` (as well `selectedLabels` and `selectedValues`) used to be arrays always. Now, if `maxSelect=1`, they will no longer be a length-1 array but simply a single a option (label/value respectively) or `null` if no option is selected. [PR 123](https://github.com/janosh/svelte-multiselect/pull/123).
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
- Props `selectedLabels` and `selectedValues` were removed. If you were using them, they were equivalent to assigning `bind:selected` to a local variable and then running `selectedLabels = selected.map(option => option.label)` and `selectedValues = selected.map(option => option.value)` if your options were objects with `label` and `value` keys. If they were simple strings/numbers, there was no point in using `selected{Labels,Values}` anyway. [PR 138](https://github.com/janosh/svelte-multiselect/pull/138)
|
|
43
43
|
- Prop `noOptionsMsg` was renamed to `noMatchingOptionsMsg`. [PR 133](https://github.com/janosh/svelte-multiselect/pull/133).
|
|
44
44
|
|
|
45
|
-
## Installation
|
|
45
|
+
## 🔨 Installation
|
|
46
46
|
|
|
47
47
|
```sh
|
|
48
48
|
npm install -D svelte-multiselect
|
|
@@ -50,9 +50,9 @@ pnpm add -D svelte-multiselect
|
|
|
50
50
|
yarn add -D svelte-multiselect
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
## Usage
|
|
53
|
+
## 📙 Usage
|
|
54
54
|
|
|
55
|
-
```
|
|
55
|
+
```svelte
|
|
56
56
|
<script>
|
|
57
57
|
import MultiSelect from 'svelte-multiselect'
|
|
58
58
|
|
|
@@ -61,14 +61,14 @@ yarn add -D svelte-multiselect
|
|
|
61
61
|
let selected = []
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
|
-
Favorite Frontend
|
|
64
|
+
Favorite Frontend Tools?
|
|
65
65
|
|
|
66
66
|
<code>selected = {JSON.stringify(selected)}</code>
|
|
67
67
|
|
|
68
68
|
<MultiSelect bind:selected options={ui_libs} />
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
## Props
|
|
71
|
+
## 🔣 Props
|
|
72
72
|
|
|
73
73
|
Full list of props/bindable variables for this component. The `Option` type you see below is defined in [`src/lib/index.ts`](https://github.com/janosh/svelte-multiselect/blob/main/src/lib/index.ts) and can be imported as `import { type Option } from 'svelte-multiselect'`.
|
|
74
74
|
|
|
@@ -344,7 +344,7 @@ Full list of props/bindable variables for this component. The `Option` type you
|
|
|
344
344
|
|
|
345
345
|
If `maxSelect={1}`, `value` will be the single item in `selected` (or `null` if `selected` is empty). If `maxSelect != 1`, `maxSelect` and `selected` are equal. Warning: `value` supports 1-way binding only, meaning `bind:value` will update `value` when internal component state changes but changing `value` externally will not update internal component state. This is because `value` is already reactive to `selected` and making `selected` reactive to `value` would be cyclic. Suggestions for better solutions that solve both [#86](https://github.com/janosh/svelte-multiselect/issues/86) and [#136](https://github.com/janosh/svelte-multiselect/issues/136) welcome!
|
|
346
346
|
|
|
347
|
-
## Slots
|
|
347
|
+
## 🎰 Slots
|
|
348
348
|
|
|
349
349
|
`MultiSelect.svelte` has 3 named slots:
|
|
350
350
|
|
|
@@ -356,7 +356,7 @@ Full list of props/bindable variables for this component. The `Option` type you
|
|
|
356
356
|
|
|
357
357
|
Example:
|
|
358
358
|
|
|
359
|
-
```
|
|
359
|
+
```svelte
|
|
360
360
|
<MultiSelect options={[`Red`, `Green`, `Blue`, `Yellow`, `Purple`]}>
|
|
361
361
|
<span let:idx let:option slot="option">
|
|
362
362
|
{idx + 1}
|
|
@@ -375,7 +375,7 @@ Example:
|
|
|
375
375
|
</MultiSelect>
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
-
## Events
|
|
378
|
+
## 🎬 Events
|
|
379
379
|
|
|
380
380
|
`MultiSelect.svelte` dispatches the following events:
|
|
381
381
|
|
|
@@ -417,7 +417,7 @@ Example:
|
|
|
417
417
|
|
|
418
418
|
For example, here's how you might annoy your users with an alert every time one or more options are added or removed:
|
|
419
419
|
|
|
420
|
-
```
|
|
420
|
+
```svelte
|
|
421
421
|
<MultiSelect
|
|
422
422
|
on:change={(e) => {
|
|
423
423
|
if (e.detail.type === 'add') alert(`You added ${e.detail.option}`)
|
|
@@ -431,18 +431,18 @@ For example, here's how you might annoy your users with an alert every time one
|
|
|
431
431
|
|
|
432
432
|
The above list of events are [Svelte `dispatch` events](https://svelte.dev/tutorial/component-events). This component also forwards many DOM events from the `<input>` node: `blur`, `change`, `click`, `keydown`, `keyup`, `mousedown`, `mouseenter`, `mouseleave`, `touchcancel`, `touchend`, `touchmove`, `touchstart`. Registering listeners for these events works the same:
|
|
433
433
|
|
|
434
|
-
```
|
|
434
|
+
```svelte
|
|
435
435
|
<MultiSelect
|
|
436
436
|
options={[1, 2, 3]}
|
|
437
437
|
on:keyup={(event) => console.log('key', event.target.value)}
|
|
438
438
|
/>
|
|
439
439
|
```
|
|
440
440
|
|
|
441
|
-
## TypeScript
|
|
441
|
+
## 🦺 TypeScript
|
|
442
442
|
|
|
443
443
|
TypeScript users can import the types used for internal type safety:
|
|
444
444
|
|
|
445
|
-
```
|
|
445
|
+
```svelte
|
|
446
446
|
<script lang="ts">
|
|
447
447
|
import MultiSelect from 'svelte-multiselect'
|
|
448
448
|
import type { Option, ObjectOption } from 'svelte-multiselect'
|
|
@@ -456,11 +456,11 @@ TypeScript users can import the types used for internal type safety:
|
|
|
456
456
|
</script>
|
|
457
457
|
```
|
|
458
458
|
|
|
459
|
-
## Styling
|
|
459
|
+
## ✨ Styling
|
|
460
460
|
|
|
461
461
|
There are 3 ways to style this component. To understand which options do what, it helps to keep in mind this simplified DOM structure of the component:
|
|
462
462
|
|
|
463
|
-
```
|
|
463
|
+
```svelte
|
|
464
464
|
<div class="multiselect">
|
|
465
465
|
<ul class="selected">
|
|
466
466
|
<li>Selected 1</li>
|
|
@@ -522,7 +522,7 @@ If you only want to make small adjustments, you can pass the following CSS varia
|
|
|
522
522
|
|
|
523
523
|
For example, to change the background color of the options dropdown:
|
|
524
524
|
|
|
525
|
-
```
|
|
525
|
+
```svelte
|
|
526
526
|
<MultiSelect --sms-options-bg="white" />
|
|
527
527
|
```
|
|
528
528
|
|
|
@@ -540,7 +540,7 @@ The second method allows you to pass in custom classes to the important DOM elem
|
|
|
540
540
|
|
|
541
541
|
This simplified version of the DOM structure of the component shows where these classes are inserted:
|
|
542
542
|
|
|
543
|
-
```
|
|
543
|
+
```svelte
|
|
544
544
|
<div class="multiselect {outerDivClass}">
|
|
545
545
|
<input class={inputClass} />
|
|
546
546
|
<ul class="selected {ulSelectedClass}">
|
|
@@ -559,7 +559,7 @@ This simplified version of the DOM structure of the component shows where these
|
|
|
559
559
|
|
|
560
560
|
### With global CSS
|
|
561
561
|
|
|
562
|
-
Odd as it may seem, you get the most fine-grained control over the styling of every part of this component by using the following `:global()` CSS selectors. `ul.selected` is the list of currently selected options rendered inside the component's input whereas `ul.options` is the list of available options that slides out when the component is in its `open` state. See also [simplified DOM structure](
|
|
562
|
+
Odd as it may seem, you get the most fine-grained control over the styling of every part of this component by using the following `:global()` CSS selectors. `ul.selected` is the list of currently selected options rendered inside the component's input whereas `ul.options` is the list of available options that slides out when the component is in its `open` state. See also [simplified DOM structure](#--styling).
|
|
563
563
|
|
|
564
564
|
```css
|
|
565
565
|
:global(div.multiselect) {
|
|
@@ -607,6 +607,10 @@ Odd as it may seem, you get the most fine-grained control over the styling of ev
|
|
|
607
607
|
}
|
|
608
608
|
```
|
|
609
609
|
|
|
610
|
-
##
|
|
610
|
+
## 🆕 Changelog
|
|
611
611
|
|
|
612
|
-
[
|
|
612
|
+
[View the changelog](changelog.md).
|
|
613
|
+
|
|
614
|
+
## 🙏 Contributing
|
|
615
|
+
|
|
616
|
+
Here are some steps to [get you started](contributing.md) if you'd like to contribute to this project!
|