svelte-multiselect 7.0.1 → 7.0.2
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 +6 -3
- package/index.d.ts +0 -2
- package/index.js +0 -4
- package/package.json +1 -1
package/MultiSelect.svelte
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, tick } from 'svelte';
|
|
2
|
-
import { get_label, get_value } from './';
|
|
3
2
|
import CircleSpinner from './CircleSpinner.svelte';
|
|
4
3
|
import { CrossIcon, DisabledIcon, ExpandIcon } from './icons';
|
|
5
4
|
import Wiggle from './Wiggle.svelte';
|
|
@@ -52,6 +51,10 @@ export let selectedValues = [];
|
|
|
52
51
|
export let sortSelected = false;
|
|
53
52
|
export let ulOptionsClass = ``;
|
|
54
53
|
export let ulSelectedClass = ``;
|
|
54
|
+
// get the label key from an option object or the option itself if it's a string or number
|
|
55
|
+
const get_label = (op) => (op instanceof Object ? op.label : op);
|
|
56
|
+
// fallback on label if option is object and value is undefined
|
|
57
|
+
const get_value = (op) => (op instanceof Object ? op.value ?? op.label : op);
|
|
55
58
|
// selected and _selected are identical except if maxSelect=1, selected will be the single item (or null)
|
|
56
59
|
// in _selected which will always be an array for easier component internals. selected then solves
|
|
57
60
|
// https://github.com/janosh/svelte-multiselect/issues/86
|
|
@@ -128,8 +131,8 @@ function add(label, event) {
|
|
|
128
131
|
options = [...options, option];
|
|
129
132
|
}
|
|
130
133
|
searchText = ``; // reset search string on selection
|
|
131
|
-
if (
|
|
132
|
-
console.error(`MultiSelect: option with label ${label}
|
|
134
|
+
if ([``, undefined, null].includes(option)) {
|
|
135
|
+
console.error(`MultiSelect: encountered missing option with label ${label} (or option is poorly labeled)`);
|
|
133
136
|
return;
|
|
134
137
|
}
|
|
135
138
|
if (maxSelect === 1) {
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export { default } from './MultiSelect.svelte';
|
|
2
|
-
// get the label key from an option object or the option itself if it's a string or number
|
|
3
|
-
export const get_label = (op) => (op instanceof Object ? op.label : op);
|
|
4
|
-
// fallback on label if option is object and value is undefined
|
|
5
|
-
export const get_value = (op) => op instanceof Object ? op.value ?? op.label : op;
|
|
6
2
|
// Firefox lacks support for scrollIntoViewIfNeeded, see
|
|
7
3
|
// https://github.com/janosh/svelte-multiselect/issues/87
|
|
8
4
|
// this polyfill was copied from
|
package/package.json
CHANGED