svelte-multiselect 11.4.0 โ 11.5.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/package.json +11 -11
- package/readme.md +138 -39
- package/dist/CircleSpinner.svelte +0 -29
- package/dist/CircleSpinner.svelte.d.ts +0 -8
- package/dist/CmdPalette.svelte +0 -74
- package/dist/CmdPalette.svelte.d.ts +0 -66
- package/dist/CodeExample.svelte +0 -85
- package/dist/CodeExample.svelte.d.ts +0 -25
- package/dist/CopyButton.svelte +0 -74
- package/dist/CopyButton.svelte.d.ts +0 -25
- package/dist/FileDetails.svelte +0 -52
- package/dist/FileDetails.svelte.d.ts +0 -23
- package/dist/GitHubCorner.svelte +0 -82
- package/dist/GitHubCorner.svelte.d.ts +0 -13
- package/dist/Icon.svelte +0 -23
- package/dist/Icon.svelte.d.ts +0 -8
- package/dist/MultiSelect.svelte +0 -1190
- package/dist/MultiSelect.svelte.d.ts +0 -25
- package/dist/Nav.svelte +0 -444
- package/dist/Nav.svelte.d.ts +0 -42
- package/dist/PrevNext.svelte +0 -101
- package/dist/PrevNext.svelte.d.ts +0 -56
- package/dist/Toggle.svelte +0 -74
- package/dist/Toggle.svelte.d.ts +0 -11
- package/dist/Wiggle.svelte +0 -15
- package/dist/Wiggle.svelte.d.ts +0 -15
- package/dist/attachments.d.ts +0 -57
- package/dist/attachments.js +0 -547
- package/dist/icons.d.ts +0 -47
- package/dist/icons.js +0 -46
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -42
- package/dist/types.d.ts +0 -171
- package/dist/types.js +0 -1
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +0 -61
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"homepage": "https://janosh.github.io/svelte-multiselect",
|
|
6
6
|
"repository": "https://github.com/janosh/svelte-multiselect",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "11.
|
|
8
|
+
"version": "11.5.0",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "vite dev",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"@playwright/test": "^1.57.0",
|
|
24
24
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
25
25
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
26
|
-
"@sveltejs/kit": "^2.49.
|
|
26
|
+
"@sveltejs/kit": "^2.49.2",
|
|
27
27
|
"@sveltejs/package": "2.5.7",
|
|
28
28
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
29
|
-
"@types/node": "^
|
|
30
|
-
"@vitest/coverage-v8": "^4.0.
|
|
31
|
-
"eslint": "^9.39.
|
|
29
|
+
"@types/node": "^25.0.3",
|
|
30
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
31
|
+
"eslint": "^9.39.2",
|
|
32
32
|
"eslint-plugin-svelte": "^3.13.1",
|
|
33
33
|
"happy-dom": "^20.0.11",
|
|
34
34
|
"hastscript": "^9.0.1",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"mdsvexamples": "^0.5.0",
|
|
37
37
|
"rehype-autolink-headings": "^7.1.0",
|
|
38
38
|
"rehype-slug": "^6.0.0",
|
|
39
|
-
"svelte": "^5.
|
|
40
|
-
"svelte-check": "^4.3.
|
|
39
|
+
"svelte": "^5.46.1",
|
|
40
|
+
"svelte-check": "^4.3.5",
|
|
41
41
|
"svelte-preprocess": "^6.0.3",
|
|
42
42
|
"svelte-toc": "^0.6.2",
|
|
43
|
-
"svelte2tsx": "^0.7.
|
|
43
|
+
"svelte2tsx": "^0.7.46",
|
|
44
44
|
"typescript": "5.9.3",
|
|
45
|
-
"typescript-eslint": "^8.
|
|
46
|
-
"vite": "^7.
|
|
47
|
-
"vitest": "^4.0.
|
|
45
|
+
"typescript-eslint": "^8.51.0",
|
|
46
|
+
"vite": "^7.3.0",
|
|
47
|
+
"vitest": "^4.0.16"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"svelte",
|
package/readme.md
CHANGED
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
|
|
35
35
|
## ๐งช   Coverage
|
|
36
36
|
|
|
37
|
-
| Statements
|
|
38
|
-
|
|
|
39
|
-
|  |  |  |
|
|
40
40
|
|
|
41
41
|
## ๐จ   Installation
|
|
42
42
|
|
|
@@ -334,6 +334,85 @@ These are the core props you'll use in most cases:
|
|
|
334
334
|
|
|
335
335
|
Configuration for portal rendering. When `active: true`, the dropdown is rendered at document.body level with fixed positioning. Useful for avoiding z-index and overflow issues.
|
|
336
336
|
|
|
337
|
+
### Grouping Props
|
|
338
|
+
|
|
339
|
+
Group related options together with visual headers. Add a `group` key to your option objects:
|
|
340
|
+
|
|
341
|
+
```svelte
|
|
342
|
+
<script>
|
|
343
|
+
const options = [
|
|
344
|
+
{ label: `JavaScript`, group: `Frontend` },
|
|
345
|
+
{ label: `TypeScript`, group: `Frontend` },
|
|
346
|
+
{ label: `Python`, group: `Backend` },
|
|
347
|
+
{ label: `Go`, group: `Backend` },
|
|
348
|
+
]
|
|
349
|
+
</script>
|
|
350
|
+
|
|
351
|
+
<MultiSelect {options} collapsibleGroups groupSelectAll />
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
See the [grouping demo](https://janosh.github.io/svelte-multiselect/grouping) for live examples.
|
|
355
|
+
|
|
356
|
+
1. ```ts
|
|
357
|
+
collapsibleGroups: boolean = false
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Enable click-to-collapse groups. When `true`, users can click group headers to hide/show options in that group.
|
|
361
|
+
|
|
362
|
+
1. ```ts
|
|
363
|
+
collapsedGroups: Set<string> = new Set()
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Bindable set of collapsed group names. Use `bind:collapsedGroups` to control which groups are collapsed externally or to persist collapse state.
|
|
367
|
+
|
|
368
|
+
1. ```ts
|
|
369
|
+
groupSelectAll: boolean = false
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Add a "Select all" button to each group header, allowing users to select all options in a specific group at once.
|
|
373
|
+
|
|
374
|
+
1. ```ts
|
|
375
|
+
ungroupedPosition: 'first' | 'last' = 'first'
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Where to render options that don't have a `group` key. `'first'` places them at the top, `'last'` at the bottom.
|
|
379
|
+
|
|
380
|
+
1. ```ts
|
|
381
|
+
groupSortOrder: 'none' | 'asc' | 'desc' | ((a: string, b: string) => number) = 'none'
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Sort groups alphabetically (`'asc'` or `'desc'`) or with a custom comparator function. Default `'none'` preserves order of first occurrence.
|
|
385
|
+
|
|
386
|
+
1. ```ts
|
|
387
|
+
searchExpandsCollapsedGroups: boolean = false
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
When `true`, collapsed groups automatically expand when the search query matches options within them.
|
|
391
|
+
|
|
392
|
+
1. ```ts
|
|
393
|
+
liGroupHeaderClass: string = ''
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
CSS class applied to group header `<li>` elements.
|
|
397
|
+
|
|
398
|
+
1. ```ts
|
|
399
|
+
liGroupHeaderStyle: string | null = null
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Inline style for group header elements.
|
|
403
|
+
|
|
404
|
+
1. ```ts
|
|
405
|
+
groupHeader: Snippet<[{ group: string; options: T[]; collapsed: boolean }]>
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Custom snippet for rendering group headers. Receives the group name, array of options in that group, and whether the group is collapsed.
|
|
409
|
+
|
|
410
|
+
1. ```ts
|
|
411
|
+
ongroupToggle: (data: { group: string; collapsed: boolean }) => void
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Callback fired when a group is collapsed or expanded. Receives the group name and its new collapsed state.
|
|
415
|
+
|
|
337
416
|
### Form & Accessibility Props
|
|
338
417
|
|
|
339
418
|
1. ```ts
|
|
@@ -631,15 +710,16 @@ These reflect internal component state:
|
|
|
631
710
|
|
|
632
711
|
1. `#snippet option({ option, idx })`: Customize rendering of dropdown options. Receives as props an `option` and the zero-indexed position (`idx`) it has in the dropdown.
|
|
633
712
|
1. `#snippet selectedItem({ option, idx })`: Customize rendering of selected items. Receives as props an `option` and the zero-indexed position (`idx`) it has in the list of selected items.
|
|
713
|
+
1. `#snippet children({ option, idx })`: Convenience snippet that applies to both dropdown options AND selected items. Use this when you want the same custom rendering for both. Takes precedence if `option` or `selectedItem` are not provided.
|
|
634
714
|
1. `#snippet spinner()`: Custom spinner component to display when in `loading` state. Receives no props.
|
|
635
715
|
1. `#snippet disabledIcon()`: Custom icon to display inside the input when in `disabled` state. Receives no props. Use an empty `{#snippet disabledIcon()}{/snippet}` to remove the default disabled icon.
|
|
636
|
-
1. `#snippet expandIcon()`: Allows setting a custom icon to indicate to users that the Multiselect text input field is expandable into a dropdown list.
|
|
716
|
+
1. `#snippet expandIcon({ open })`: Allows setting a custom icon to indicate to users that the Multiselect text input field is expandable into a dropdown list. `open` is `true` if the dropdown is visible and `false` if hidden.
|
|
637
717
|
1. `#snippet removeIcon()`: Custom icon to display as remove button. Will be used both by buttons to remove individual selected options and the 'remove all' button that clears all options at once. Receives no props.
|
|
638
718
|
1. `#snippet userMsg({ searchText, msgType, msg })`: Displayed like a dropdown item when the list is empty and user is allowed to create custom options based on text input (or if the user's text input clashes with an existing option). Receives props:
|
|
639
719
|
- `searchText`: The text user typed into search input.
|
|
640
720
|
- `msgType: false | 'create' | 'dupe' | 'no-match'`: `'dupe'` means user input is a duplicate of an existing option. `'create'` means user is allowed to convert their input into a new option not previously in the dropdown. `'no-match'` means user input doesn't match any dropdown items and users are not allowed to create new options. `false` means none of the above.
|
|
641
721
|
- `msg`: Will be `duplicateOptionMsg` or `createOptionMsg` (see [props](#๐ฃ-props)) based on whether user input is a duplicate or can be created as new option. Note this snippet replaces the default UI for displaying these messages so the snippet needs to render them instead (unless purposely not showing a message).
|
|
642
|
-
1.
|
|
722
|
+
1. `#snippet afterInput({ selected, disabled, invalid, id, placeholder, open, required })`: Placed after the search input. For arbitrary content like icons or temporary messages. Can serve as a more dynamic, more customizable alternative to the `placeholder` prop.
|
|
643
723
|
|
|
644
724
|
Example using several snippets:
|
|
645
725
|
|
|
@@ -666,65 +746,79 @@ Example using several snippets:
|
|
|
666
746
|
|
|
667
747
|
## ๐ฌ   Events
|
|
668
748
|
|
|
669
|
-
`MultiSelect.svelte`
|
|
749
|
+
`MultiSelect.svelte` provides the following event callback props:
|
|
750
|
+
|
|
751
|
+
1. ```ts
|
|
752
|
+
onadd={({ option }) => console.log(option)}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Triggers when a new option is selected. The newly selected option is provided as `option`.
|
|
670
756
|
|
|
671
757
|
1. ```ts
|
|
672
|
-
|
|
758
|
+
oncreate={({ option }) => console.log(option)}
|
|
673
759
|
```
|
|
674
760
|
|
|
675
|
-
Triggers when a new option is
|
|
761
|
+
Triggers when a user creates a new option (when `allowUserOptions` is enabled). The created option is provided as `option`.
|
|
676
762
|
|
|
677
763
|
1. ```ts
|
|
678
|
-
|
|
764
|
+
onremove={({ option }) => console.log(option)}
|
|
679
765
|
```
|
|
680
766
|
|
|
681
|
-
Triggers when a
|
|
767
|
+
Triggers when a single selected option is removed. The removed option is provided as `option`.
|
|
682
768
|
|
|
683
769
|
1. ```ts
|
|
684
|
-
|
|
770
|
+
onremoveAll={({ options }) => console.log(options)}
|
|
685
771
|
```
|
|
686
772
|
|
|
687
|
-
Triggers when
|
|
773
|
+
Triggers when all selected options are removed. The `options` payload gives the options that were removed (might not be all if `minSelect` is set).
|
|
688
774
|
|
|
689
775
|
1. ```ts
|
|
690
|
-
|
|
776
|
+
onselectAll={({ options }) => console.log(options)}
|
|
691
777
|
```
|
|
692
778
|
|
|
693
|
-
Triggers when
|
|
779
|
+
Triggers when the "Select All" option is clicked (requires `selectAllOption` to be enabled). The `options` payload contains the options that were added.
|
|
694
780
|
|
|
695
781
|
1. ```ts
|
|
696
|
-
|
|
782
|
+
onreorder={({ options }) => console.log(options)}
|
|
697
783
|
```
|
|
698
784
|
|
|
699
|
-
Triggers when
|
|
785
|
+
Triggers when selected options are reordered via drag-and-drop (enabled by default when `sortSelected` is false). The `options` payload is the newly ordered array of selected options.
|
|
700
786
|
|
|
701
787
|
1. ```ts
|
|
702
|
-
|
|
788
|
+
onchange={({ type, option, options }) => console.log(type, option ?? options)}
|
|
703
789
|
```
|
|
704
790
|
|
|
705
|
-
Triggers when
|
|
791
|
+
Triggers when an option is either added (selected) or removed from selected, all selected options are removed at once, or selected options are reordered via drag-and-drop. `type` is one of `'add' | 'remove' | 'removeAll' | 'selectAll' | 'reorder'` and payload will be `option: Option` or `options: Option[]`, respectively.
|
|
706
792
|
|
|
707
793
|
1. ```ts
|
|
708
|
-
|
|
794
|
+
onopen={({ event }) => console.log(`Dropdown opened by`, event)}
|
|
709
795
|
```
|
|
710
796
|
|
|
711
|
-
Triggers when the dropdown list of options
|
|
797
|
+
Triggers when the dropdown list of options appears. `event` is the DOM's `FocusEvent`, `KeyboardEvent` or `ClickEvent` that triggered the open.
|
|
798
|
+
|
|
799
|
+
1. ```ts
|
|
800
|
+
onclose={({ event }) => console.log(`Dropdown closed by`, event)}
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
Triggers when the dropdown list of options disappears. `event` is the DOM's `FocusEvent`, `KeyboardEvent` or `ClickEvent` that triggered the close.
|
|
712
804
|
|
|
713
805
|
For example, here's how you might annoy your users with an alert every time one or more options are added or removed:
|
|
714
806
|
|
|
715
807
|
```svelte
|
|
716
808
|
<MultiSelect
|
|
717
|
-
onchange={(
|
|
718
|
-
if (
|
|
719
|
-
if (
|
|
720
|
-
if (
|
|
809
|
+
onchange={({ type, option, options }) => {
|
|
810
|
+
if (type === 'add') alert(`You added ${option}`)
|
|
811
|
+
if (type === 'remove') alert(`You removed ${option}`)
|
|
812
|
+
if (type === 'removeAll') alert(`You removed ${options}`)
|
|
813
|
+
if (type === 'selectAll') alert(`You selected all: ${options}`)
|
|
814
|
+
if (type === 'reorder') alert(`New order: ${options}`)
|
|
721
815
|
}}
|
|
722
816
|
/>
|
|
723
817
|
```
|
|
724
818
|
|
|
725
|
-
> Note: Depending on the data passed to the component the `
|
|
819
|
+
> Note: Depending on the data passed to the component the `option(s)` payload will either be objects or simple strings/numbers.
|
|
726
820
|
|
|
727
|
-
|
|
821
|
+
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:
|
|
728
822
|
|
|
729
823
|
```svelte
|
|
730
824
|
<MultiSelect
|
|
@@ -795,10 +889,10 @@ Minimal example that changes the background color of the options dropdown:
|
|
|
795
889
|
```
|
|
796
890
|
|
|
797
891
|
- `div.multiselect`
|
|
798
|
-
- `border: var(--sms-border, 1pt solid lightgray)`: Change this to e.g. to `1px solid red` to indicate this form field is in an invalid state.
|
|
892
|
+
- `border: var(--sms-border, 1pt solid light-dark(lightgray, #555))`: Change this to e.g. to `1px solid red` to indicate this form field is in an invalid state.
|
|
799
893
|
- `border-radius: var(--sms-border-radius, 3pt)`
|
|
800
894
|
- `padding: var(--sms-padding, 0 3pt)`
|
|
801
|
-
- `background: var(--sms-bg)`
|
|
895
|
+
- `background: var(--sms-bg, light-dark(white, #1a1a1a))`
|
|
802
896
|
- `color: var(--sms-text-color)`
|
|
803
897
|
- `min-height: var(--sms-min-height, 22pt)`
|
|
804
898
|
- `width: var(--sms-width)`
|
|
@@ -810,23 +904,23 @@ Minimal example that changes the background color of the options dropdown:
|
|
|
810
904
|
- `div.multiselect:focus-within`
|
|
811
905
|
- `border: var(--sms-focus-border, 1pt solid var(--sms-active-color, cornflowerblue))`: Border when component has focus. Defaults to `--sms-active-color` which in turn defaults to `cornflowerblue`.
|
|
812
906
|
- `div.multiselect.disabled`
|
|
813
|
-
- `background: var(--sms-disabled-bg, lightgray)`: Background when in disabled state.
|
|
907
|
+
- `background: var(--sms-disabled-bg, light-dark(lightgray, #444))`: Background when in disabled state.
|
|
814
908
|
- `div.multiselect input::placeholder`
|
|
815
909
|
- `color: var(--sms-placeholder-color)`
|
|
816
910
|
- `opacity: var(--sms-placeholder-opacity)`
|
|
817
911
|
- `div.multiselect > ul.selected > li`
|
|
818
|
-
- `background: var(--sms-selected-bg, rgba(0, 0, 0, 0.15))`: Background of selected options.
|
|
912
|
+
- `background: var(--sms-selected-bg, light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.15)))`: Background of selected options.
|
|
819
913
|
- `padding: var(--sms-selected-li-padding, 1pt 5pt)`: Height of selected options.
|
|
820
914
|
- `color: var(--sms-selected-text-color, var(--sms-text-color))`: Text color for selected options.
|
|
821
915
|
- `ul.selected > li button:hover, button.remove-all:hover, button:focus`
|
|
822
|
-
- `color: var(--sms-remove-btn-hover-color, lightskyblue)`: Color of the remove-icon buttons for removing all or individual selected options when in `:focus` or `:hover` state.
|
|
823
|
-
- `background: var(--sms-remove-btn-hover-bg, rgba(0, 0, 0, 0.2))`: Background for hovered remove buttons.
|
|
916
|
+
- `color: var(--sms-remove-btn-hover-color, light-dark(#0088cc, lightskyblue))`: Color of the remove-icon buttons for removing all or individual selected options when in `:focus` or `:hover` state.
|
|
917
|
+
- `background: var(--sms-remove-btn-hover-bg, light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.2)))`: Background for hovered remove buttons.
|
|
824
918
|
- `div.multiselect > ul.options`
|
|
825
|
-
- `background: var(--sms-options-bg,
|
|
919
|
+
- `background: var(--sms-options-bg, light-dark(#fafafa, #1a1a1a))`: Background of dropdown list.
|
|
826
920
|
- `max-height: var(--sms-options-max-height, 50vh)`: Maximum height of options dropdown.
|
|
827
921
|
- `overscroll-behavior: var(--sms-options-overscroll, none)`: Whether scroll events bubble to parent elements when reaching the top/bottom of the options dropdown. See [MDN](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior).
|
|
828
922
|
- `z-index: var(--sms-options-z-index, 3)`: Z-index for the dropdown options list.
|
|
829
|
-
- `box-shadow: var(--sms-options-shadow, 0 0 14pt -8pt black)`: Box shadow of dropdown list.
|
|
923
|
+
- `box-shadow: var(--sms-options-shadow, light-dark(0 0 14pt -8pt black, 0 0 14pt -4pt rgba(0, 0, 0, 0.8)))`: Box shadow of dropdown list.
|
|
830
924
|
- `border: var(--sms-options-border)`
|
|
831
925
|
- `border-width: var(--sms-options-border-width)`
|
|
832
926
|
- `border-radius: var(--sms-options-border-radius, 1ex)`
|
|
@@ -835,13 +929,13 @@ Minimal example that changes the background color of the options dropdown:
|
|
|
835
929
|
- `div.multiselect > ul.options > li`
|
|
836
930
|
- `scroll-margin: var(--sms-options-scroll-margin, 100px)`: Top/bottom margin to keep between dropdown list items and top/bottom screen edge when auto-scrolling list to keep items in view.
|
|
837
931
|
- `div.multiselect > ul.options > li.selected`
|
|
838
|
-
- `background: var(--sms-li-selected-bg)`: Background of selected list items in options pane.
|
|
839
|
-
- `
|
|
932
|
+
- `background: var(--sms-li-selected-plain-bg, light-dark(rgba(0, 123, 255, 0.1), rgba(100, 180, 255, 0.2)))`: Background of selected list items in options pane.
|
|
933
|
+
- `border-left: var(--sms-li-selected-plain-border, 3px solid var(--sms-active-color, cornflowerblue))`: Left border of selected list items in options pane.
|
|
840
934
|
- `div.multiselect > ul.options > li.active`
|
|
841
|
-
- `background: var(--sms-li-active-bg, var(--sms-active-color, rgba(0, 0, 0, 0.15)))`: Background of active options. Options in the dropdown list become active either by mouseover or by navigating to them with arrow keys. Selected options become active when `selectedOptionsDraggable=true` and an option is being dragged to a new position. Note the active option in that case is not the dragged option but the option under it whose place it will take on drag end.
|
|
935
|
+
- `background: var(--sms-li-active-bg, var(--sms-active-color, light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.15))))`: Background of active options. Options in the dropdown list become active either by mouseover or by navigating to them with arrow keys. Selected options become active when `selectedOptionsDraggable=true` and an option is being dragged to a new position. Note the active option in that case is not the dragged option but the option under it whose place it will take on drag end.
|
|
842
936
|
- `div.multiselect > ul.options > li.disabled`
|
|
843
|
-
- `background: var(--sms-li-disabled-bg, #f5f5f6)`: Background of disabled options in the dropdown list.
|
|
844
|
-
- `color: var(--sms-li-disabled-text, #b8b8b8)`: Text color of disabled option in the dropdown list.
|
|
937
|
+
- `background: var(--sms-li-disabled-bg, light-dark(#f5f5f6, #2a2a2a))`: Background of disabled options in the dropdown list.
|
|
938
|
+
- `color: var(--sms-li-disabled-text, light-dark(#b8b8b8, #666))`: Text color of disabled option in the dropdown list.
|
|
845
939
|
- `::highlight(sms-search-matches)`: applies to search results in dropdown list that match the current search query if `highlightMatches=true`. These styles [cannot be set via CSS variables](https://stackoverflow.com/a/56799215). Instead, use a new rule set. For example:
|
|
846
940
|
|
|
847
941
|
```css
|
|
@@ -862,6 +956,7 @@ The second method allows you to pass in custom classes to the important DOM elem
|
|
|
862
956
|
- `ulOptionsClass`: available options listed in the dropdown when component is in `open` state
|
|
863
957
|
- `liOptionClass`: list items selectable from dropdown list
|
|
864
958
|
- `liActiveOptionClass`: the currently active dropdown list item (i.e. hovered or navigated to with arrow keys)
|
|
959
|
+
- `liSelectAllClass`: the "Select All" option at the top of the dropdown (when `selectAllOption` is enabled)
|
|
865
960
|
- `liUserMsgClass`: user message (last child of dropdown list when no options match user input)
|
|
866
961
|
- `liActiveUserMsgClass`: user message when active (i.e. hovered or navigated to with arrow keys)
|
|
867
962
|
- `maxSelectMsgClass`: small span towards the right end of the input field displaying to the user how many of the allowed number of options they've already selected
|
|
@@ -877,6 +972,7 @@ This simplified version of the DOM structure of the component shows where these
|
|
|
877
972
|
</ul>
|
|
878
973
|
<span class="maxSelectMsgClass">2/5 selected</span>
|
|
879
974
|
<ul class="options {ulOptionsClass}">
|
|
975
|
+
<li class="select-all {liSelectAllClass}">Select all</li>
|
|
880
976
|
<li class={liOptionClass}>Option 1</li>
|
|
881
977
|
<li class="{liOptionClass} {liActiveOptionClass}">
|
|
882
978
|
Option 2 (currently active)
|
|
@@ -937,6 +1033,9 @@ Odd as it may seem, you get the most fine-grained control over the styling of ev
|
|
|
937
1033
|
:global(div.multiselect > ul.options > li.disabled) {
|
|
938
1034
|
/* options with disabled key set to true (see props above) */
|
|
939
1035
|
}
|
|
1036
|
+
:global(div.multiselect > ul.options > li.select-all) {
|
|
1037
|
+
/* the "Select All" option at the top of the dropdown */
|
|
1038
|
+
}
|
|
940
1039
|
```
|
|
941
1040
|
|
|
942
1041
|
## ๐   Changelog
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="ts">"use strict";
|
|
2
|
-
let { color = `cornflowerblue`, duration = `1.5s`, size = `1em` } = $props();
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div
|
|
6
|
-
style="--duration: {duration}"
|
|
7
|
-
style:border-color="{color} transparent {color}
|
|
8
|
-
{color}"
|
|
9
|
-
style:width={size}
|
|
10
|
-
style:height={size}
|
|
11
|
-
>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<style>
|
|
15
|
-
div {
|
|
16
|
-
display: inline-block;
|
|
17
|
-
vertical-align: middle;
|
|
18
|
-
margin: 0 3pt;
|
|
19
|
-
border-width: calc(1em / 5);
|
|
20
|
-
border-style: solid;
|
|
21
|
-
border-radius: 50%;
|
|
22
|
-
animation: var(--duration) infinite rotate;
|
|
23
|
-
}
|
|
24
|
-
@keyframes rotate {
|
|
25
|
-
100% {
|
|
26
|
-
transform: rotate(360deg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
</style>
|
package/dist/CmdPalette.svelte
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
<script
|
|
2
|
-
lang="ts"
|
|
3
|
-
generics="Action extends { label: string; action: (label: string) => void } & Record<string, unknown> = { label: string; action: (label: string) => void }"
|
|
4
|
-
>import { fade } from 'svelte/transition';
|
|
5
|
-
import MultiSelect from './MultiSelect.svelte';
|
|
6
|
-
let { actions, triggers = [`k`], close_keys = [`Escape`], fade_duration = 200, dialog_style = ``, open = $bindable(false), dialog = $bindable(null), input = $bindable(null), placeholder = `Filter actions...`, dialog_props, ...rest } = $props();
|
|
7
|
-
$effect(() => {
|
|
8
|
-
if (open && input && document.activeElement !== input)
|
|
9
|
-
input.focus();
|
|
10
|
-
});
|
|
11
|
-
async function toggle(event) {
|
|
12
|
-
const is_trigger = triggers.includes(event.key) &&
|
|
13
|
-
(event.metaKey || event.ctrlKey);
|
|
14
|
-
if (is_trigger && !open)
|
|
15
|
-
open = true;
|
|
16
|
-
else if (close_keys.includes(event.key) && open)
|
|
17
|
-
open = false;
|
|
18
|
-
}
|
|
19
|
-
function close_if_outside(event) {
|
|
20
|
-
const target = event.target;
|
|
21
|
-
if (!target || !(target instanceof HTMLElement))
|
|
22
|
-
return;
|
|
23
|
-
if (open && !dialog?.contains(target) && !target.closest(`ul.options`)) {
|
|
24
|
-
open = false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function trigger_action_and_close({ option }) {
|
|
28
|
-
if (!option?.action)
|
|
29
|
-
return;
|
|
30
|
-
option.action(option.label);
|
|
31
|
-
open = false;
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<svelte:window onkeydown={toggle} onclick={close_if_outside} />
|
|
36
|
-
|
|
37
|
-
{#if open}
|
|
38
|
-
<dialog
|
|
39
|
-
open
|
|
40
|
-
bind:this={dialog}
|
|
41
|
-
transition:fade={{ duration: fade_duration }}
|
|
42
|
-
style={dialog_style}
|
|
43
|
-
{...dialog_props}
|
|
44
|
-
>
|
|
45
|
-
<MultiSelect
|
|
46
|
-
options={actions}
|
|
47
|
-
bind:input
|
|
48
|
-
{placeholder}
|
|
49
|
-
onadd={trigger_action_and_close}
|
|
50
|
-
onkeydown={toggle}
|
|
51
|
-
{...rest}
|
|
52
|
-
--sms-bg="var(--sms-options-bg)"
|
|
53
|
-
--sms-width="min(20em, 90vw)"
|
|
54
|
-
--sms-max-width="none"
|
|
55
|
-
--sms-placeholder-color="lightgray"
|
|
56
|
-
--sms-options-margin="1px 0"
|
|
57
|
-
--sms-options-border-radius="0 0 1ex 1ex"
|
|
58
|
-
/>
|
|
59
|
-
</dialog>
|
|
60
|
-
{/if}
|
|
61
|
-
|
|
62
|
-
<style>
|
|
63
|
-
:where(dialog) {
|
|
64
|
-
position: fixed;
|
|
65
|
-
top: 30%;
|
|
66
|
-
border: none;
|
|
67
|
-
padding: 0;
|
|
68
|
-
background-color: transparent;
|
|
69
|
-
display: flex;
|
|
70
|
-
color: white;
|
|
71
|
-
z-index: 10;
|
|
72
|
-
font-size: 2.4ex;
|
|
73
|
-
}
|
|
74
|
-
</style>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
-
declare function $$render<Action extends {
|
|
3
|
-
label: string;
|
|
4
|
-
action: (label: string) => void;
|
|
5
|
-
} & Record<string, unknown> = {
|
|
6
|
-
label: string;
|
|
7
|
-
action: (label: string) => void;
|
|
8
|
-
}>(): {
|
|
9
|
-
props: Omit<import("./types").MultiSelectProps<Action>, "options"> & {
|
|
10
|
-
actions: Action[];
|
|
11
|
-
triggers?: string[];
|
|
12
|
-
close_keys?: string[];
|
|
13
|
-
fade_duration?: number;
|
|
14
|
-
dialog_style?: string;
|
|
15
|
-
open?: boolean;
|
|
16
|
-
dialog?: HTMLDialogElement | null;
|
|
17
|
-
input?: HTMLInputElement | null;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
dialog_props?: HTMLAttributes<HTMLDialogElement>;
|
|
20
|
-
};
|
|
21
|
-
exports: {};
|
|
22
|
-
bindings: "dialog" | "input" | "open";
|
|
23
|
-
slots: {};
|
|
24
|
-
events: {};
|
|
25
|
-
};
|
|
26
|
-
declare class __sveltets_Render<Action extends {
|
|
27
|
-
label: string;
|
|
28
|
-
action: (label: string) => void;
|
|
29
|
-
} & Record<string, unknown> = {
|
|
30
|
-
label: string;
|
|
31
|
-
action: (label: string) => void;
|
|
32
|
-
}> {
|
|
33
|
-
props(): ReturnType<typeof $$render<Action>>['props'];
|
|
34
|
-
events(): ReturnType<typeof $$render<Action>>['events'];
|
|
35
|
-
slots(): ReturnType<typeof $$render<Action>>['slots'];
|
|
36
|
-
bindings(): "dialog" | "input" | "open";
|
|
37
|
-
exports(): {};
|
|
38
|
-
}
|
|
39
|
-
interface $$IsomorphicComponent {
|
|
40
|
-
new <Action extends {
|
|
41
|
-
label: string;
|
|
42
|
-
action: (label: string) => void;
|
|
43
|
-
} & Record<string, unknown> = {
|
|
44
|
-
label: string;
|
|
45
|
-
action: (label: string) => void;
|
|
46
|
-
}>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Action>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Action>['props']>, ReturnType<__sveltets_Render<Action>['events']>, ReturnType<__sveltets_Render<Action>['slots']>> & {
|
|
47
|
-
$$bindings?: ReturnType<__sveltets_Render<Action>['bindings']>;
|
|
48
|
-
} & ReturnType<__sveltets_Render<Action>['exports']>;
|
|
49
|
-
<Action extends {
|
|
50
|
-
label: string;
|
|
51
|
-
action: (label: string) => void;
|
|
52
|
-
} & Record<string, unknown> = {
|
|
53
|
-
label: string;
|
|
54
|
-
action: (label: string) => void;
|
|
55
|
-
}>(internal: unknown, props: ReturnType<__sveltets_Render<Action>['props']> & {}): ReturnType<__sveltets_Render<Action>['exports']>;
|
|
56
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
57
|
-
}
|
|
58
|
-
declare const CmdPalette: $$IsomorphicComponent;
|
|
59
|
-
type CmdPalette<Action extends {
|
|
60
|
-
label: string;
|
|
61
|
-
action: (label: string) => void;
|
|
62
|
-
} & Record<string, unknown> = {
|
|
63
|
-
label: string;
|
|
64
|
-
action: (label: string) => void;
|
|
65
|
-
}> = InstanceType<typeof CmdPalette<Action>>;
|
|
66
|
-
export default CmdPalette;
|
package/dist/CodeExample.svelte
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<script lang="ts">import Icon from './Icon.svelte';
|
|
2
|
-
let { src = ``, meta = {}, open = $bindable(!meta.collapsible), title, example, code, link_props, // Applied after computed attributes (href, title, etc.), allowing override
|
|
3
|
-
button_props, } = $props();
|
|
4
|
-
let { id, collapsible, code_above, repl, github, repo, file } = $derived(meta);
|
|
5
|
-
const links = { target: `_blank`, rel: `noreferrer` };
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<nav>
|
|
9
|
-
{#each [
|
|
10
|
-
{ cond: repl, href: repl, icon: `Svelte` },
|
|
11
|
-
{
|
|
12
|
-
cond: github && repo,
|
|
13
|
-
href: file ? `${repo}/blob/-/${github == true ? file : github}` : repo,
|
|
14
|
-
icon: `GitHub`,
|
|
15
|
-
},
|
|
16
|
-
] as const as
|
|
17
|
-
{ cond, href, icon }
|
|
18
|
-
(icon)
|
|
19
|
-
}
|
|
20
|
-
<a
|
|
21
|
-
{href}
|
|
22
|
-
{...links}
|
|
23
|
-
title={icon}
|
|
24
|
-
style:display={cond ? `inline-block` : `none`}
|
|
25
|
-
{...link_props}
|
|
26
|
-
>
|
|
27
|
-
<Icon {icon} />
|
|
28
|
-
</a>
|
|
29
|
-
{/each}
|
|
30
|
-
{#if collapsible}
|
|
31
|
-
{@render title?.()}
|
|
32
|
-
<button onclick={() => (open = !open)} {...button_props}>
|
|
33
|
-
<Icon icon={open ? `Collapse` : `Expand`} />
|
|
34
|
-
{open ? `Close` : `View code`}
|
|
35
|
-
</button>
|
|
36
|
-
{/if}
|
|
37
|
-
</nav>
|
|
38
|
-
<!-- wrap in div with id for precise CSS selectors in playwright E2E tests -->
|
|
39
|
-
<div {id} class="code-example">
|
|
40
|
-
{#if !code_above}
|
|
41
|
-
{@render example?.()}
|
|
42
|
-
{/if}
|
|
43
|
-
|
|
44
|
-
<pre class:open><code>{#if code}{@render code()}{:else}{src}{/if}</code></pre>
|
|
45
|
-
|
|
46
|
-
{#if code_above}
|
|
47
|
-
{@render example?.()}
|
|
48
|
-
{/if}
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<style>
|
|
52
|
-
div.code-example {
|
|
53
|
-
margin: var(--code-example-margin, 1em auto);
|
|
54
|
-
position: relative;
|
|
55
|
-
}
|
|
56
|
-
nav {
|
|
57
|
-
display: flex;
|
|
58
|
-
justify-content: end;
|
|
59
|
-
align-items: center;
|
|
60
|
-
margin: var(--code-example-nav-margin, initial);
|
|
61
|
-
gap: var(--code-example-nav-gap, 1ex);
|
|
62
|
-
}
|
|
63
|
-
pre code {
|
|
64
|
-
background-color: transparent;
|
|
65
|
-
display: inline-block;
|
|
66
|
-
}
|
|
67
|
-
pre {
|
|
68
|
-
position: relative;
|
|
69
|
-
overflow-x: auto;
|
|
70
|
-
visibility: hidden;
|
|
71
|
-
opacity: 0;
|
|
72
|
-
max-height: 0;
|
|
73
|
-
transition: max-height, opacity, visibility;
|
|
74
|
-
transition-duration: var(--code-example-pre-transition-duration, 0.3s);
|
|
75
|
-
border-radius: var(--code-example-pre-border-radius, 4pt);
|
|
76
|
-
background-color: var(--code-example-pre-bg, var(--pre-bg));
|
|
77
|
-
padding: var(--code-example-pre-padding, 1em);
|
|
78
|
-
}
|
|
79
|
-
pre.open {
|
|
80
|
-
visibility: visible;
|
|
81
|
-
opacity: 1;
|
|
82
|
-
max-height: 9999vh;
|
|
83
|
-
margin: var(--code-example-pre-margin, 1em 0 0 0);
|
|
84
|
-
}
|
|
85
|
-
</style>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
type $$ComponentProps = {
|
|
4
|
-
src?: string;
|
|
5
|
-
meta?: {
|
|
6
|
-
collapsible?: boolean;
|
|
7
|
-
code_above?: boolean;
|
|
8
|
-
id?: string;
|
|
9
|
-
repl?: string;
|
|
10
|
-
github?: string | boolean;
|
|
11
|
-
repo?: string;
|
|
12
|
-
Wrapper?: string;
|
|
13
|
-
example?: boolean;
|
|
14
|
-
file?: string;
|
|
15
|
-
};
|
|
16
|
-
open?: boolean;
|
|
17
|
-
title?: Snippet<[]>;
|
|
18
|
-
example?: Snippet<[]>;
|
|
19
|
-
code?: Snippet<[]>;
|
|
20
|
-
link_props?: HTMLAttributes<HTMLAnchorElement>;
|
|
21
|
-
button_props?: HTMLAttributes<HTMLButtonElement>;
|
|
22
|
-
};
|
|
23
|
-
declare const CodeExample: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
24
|
-
type CodeExample = ReturnType<typeof CodeExample>;
|
|
25
|
-
export default CodeExample;
|