svelte-multiselect 10.3.0 → 11.0.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/dist/CircleSpinner.svelte +3 -4
- package/dist/CircleSpinner.svelte.d.ts +7 -17
- package/dist/CmdPalette.svelte +19 -24
- package/dist/CmdPalette.svelte.d.ts +22 -30
- package/dist/MultiSelect.svelte +239 -265
- package/dist/MultiSelect.svelte.d.ts +16 -105
- package/dist/Wiggle.svelte +10 -19
- package/dist/Wiggle.svelte.d.ts +14 -24
- package/dist/icons/ChevronExpand.svelte +5 -1
- package/dist/icons/ChevronExpand.svelte.d.ts +4 -23
- package/dist/icons/Cross.svelte +6 -2
- package/dist/icons/Cross.svelte.d.ts +4 -23
- package/dist/icons/Disabled.svelte +5 -1
- package/dist/icons/Disabled.svelte.d.ts +4 -23
- package/dist/icons/Octocat.svelte +5 -1
- package/dist/icons/Octocat.svelte.d.ts +4 -23
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -7
- package/dist/props.d.ts +138 -0
- package/dist/props.js +1 -0
- package/dist/types.d.ts +0 -40
- package/dist/utils.d.ts +22 -3
- package/dist/utils.js +60 -3
- package/package.json +35 -32
- package/readme.md +44 -65
|
@@ -1,108 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { MultiSelectProps } from './props';
|
|
2
|
+
import type { Option as T } from './types';
|
|
3
3
|
declare class __sveltets_Render<Option extends T> {
|
|
4
|
-
props():
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
allowEmpty?: boolean | undefined;
|
|
10
|
-
autocomplete?: string | undefined;
|
|
11
|
-
autoScroll?: boolean | undefined;
|
|
12
|
-
breakpoint?: number | undefined;
|
|
13
|
-
defaultDisabledTitle?: string | undefined;
|
|
14
|
-
disabled?: boolean | undefined;
|
|
15
|
-
disabledInputTitle?: string | undefined;
|
|
16
|
-
duplicateOptionMsg?: string | undefined;
|
|
17
|
-
duplicates?: boolean | undefined;
|
|
18
|
-
key?: ((opt: T) => unknown) | undefined;
|
|
19
|
-
filterFunc?: ((opt: Option, searchText: string) => boolean) | undefined;
|
|
20
|
-
closeDropdownOnSelect?: boolean | "desktop" | undefined;
|
|
21
|
-
form_input?: HTMLInputElement | null | undefined;
|
|
22
|
-
highlightMatches?: boolean | undefined;
|
|
23
|
-
id?: string | null | undefined;
|
|
24
|
-
input?: HTMLInputElement | null | undefined;
|
|
25
|
-
inputClass?: string | undefined;
|
|
26
|
-
inputStyle?: string | null | undefined;
|
|
27
|
-
inputmode?: string | null | undefined;
|
|
28
|
-
invalid?: boolean | undefined;
|
|
29
|
-
liActiveOptionClass?: string | undefined;
|
|
30
|
-
liActiveUserMsgClass?: string | undefined;
|
|
31
|
-
liOptionClass?: string | undefined;
|
|
32
|
-
liOptionStyle?: string | null | undefined;
|
|
33
|
-
liSelectedClass?: string | undefined;
|
|
34
|
-
liSelectedStyle?: string | null | undefined;
|
|
35
|
-
liUserMsgClass?: string | undefined;
|
|
36
|
-
loading?: boolean | undefined;
|
|
37
|
-
matchingOptions?: Option[] | undefined;
|
|
38
|
-
maxOptions?: number | undefined;
|
|
39
|
-
maxSelect?: number | null | undefined;
|
|
40
|
-
maxSelectMsg?: ((current: number, max: number) => string) | null | undefined;
|
|
41
|
-
maxSelectMsgClass?: string | undefined;
|
|
42
|
-
name?: string | null | undefined;
|
|
43
|
-
noMatchingOptionsMsg?: string | undefined;
|
|
44
|
-
open?: boolean | undefined;
|
|
45
|
-
options: Option[];
|
|
46
|
-
outerDiv?: HTMLDivElement | null | undefined;
|
|
47
|
-
outerDivClass?: string | undefined;
|
|
48
|
-
parseLabelsAsHtml?: boolean | undefined;
|
|
49
|
-
pattern?: string | null | undefined;
|
|
50
|
-
placeholder?: string | null | undefined;
|
|
51
|
-
removeAllTitle?: string | undefined;
|
|
52
|
-
removeBtnTitle?: string | undefined;
|
|
53
|
-
minSelect?: number | null | undefined;
|
|
54
|
-
required?: number | boolean | undefined;
|
|
55
|
-
resetFilterOnAdd?: boolean | undefined;
|
|
56
|
-
searchText?: string | undefined;
|
|
57
|
-
selected?: Option[] | undefined;
|
|
58
|
-
sortSelected?: boolean | ((op1: Option, op2: Option) => number) | undefined;
|
|
59
|
-
selectedOptionsDraggable?: boolean | undefined;
|
|
60
|
-
style?: string | null | undefined;
|
|
61
|
-
ulOptionsClass?: string | undefined;
|
|
62
|
-
ulSelectedClass?: string | undefined;
|
|
63
|
-
ulSelectedStyle?: string | null | undefined;
|
|
64
|
-
ulOptionsStyle?: string | null | undefined;
|
|
65
|
-
value?: Option | Option[] | null | undefined;
|
|
66
|
-
};
|
|
67
|
-
events(): MultiSelectEvents;
|
|
68
|
-
slots(): {
|
|
69
|
-
'expand-icon': {
|
|
70
|
-
open: boolean;
|
|
71
|
-
};
|
|
72
|
-
selected: {
|
|
73
|
-
option: Option;
|
|
74
|
-
idx: any;
|
|
75
|
-
};
|
|
76
|
-
default: {
|
|
77
|
-
option: Option;
|
|
78
|
-
idx: any;
|
|
79
|
-
};
|
|
80
|
-
'remove-icon': {};
|
|
81
|
-
'after-input': {
|
|
82
|
-
selected: Option[];
|
|
83
|
-
disabled: boolean;
|
|
84
|
-
invalid: boolean;
|
|
85
|
-
id: string | null;
|
|
86
|
-
placeholder: string | null;
|
|
87
|
-
open: boolean;
|
|
88
|
-
required: number | boolean;
|
|
89
|
-
};
|
|
90
|
-
spinner: {};
|
|
91
|
-
'disabled-icon': {};
|
|
92
|
-
option: {
|
|
93
|
-
option: Option;
|
|
94
|
-
idx: any;
|
|
95
|
-
};
|
|
96
|
-
'user-msg': {
|
|
97
|
-
searchText: string;
|
|
98
|
-
msgType: any;
|
|
99
|
-
msg: any;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
4
|
+
props(): MultiSelectProps<T>;
|
|
5
|
+
events(): {};
|
|
6
|
+
slots(): {};
|
|
7
|
+
bindings(): "value" | "selected" | "invalid" | "open" | "activeIndex" | "activeOption" | "form_input" | "input" | "matchingOptions" | "options" | "outerDiv" | "searchText";
|
|
8
|
+
exports(): {};
|
|
102
9
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
10
|
+
interface $$IsomorphicComponent {
|
|
11
|
+
new <Option extends T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Option>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Option>['props']>, ReturnType<__sveltets_Render<Option>['events']>, ReturnType<__sveltets_Render<Option>['slots']>> & {
|
|
12
|
+
$$bindings?: ReturnType<__sveltets_Render<Option>['bindings']>;
|
|
13
|
+
} & ReturnType<__sveltets_Render<Option>['exports']>;
|
|
14
|
+
<Option extends T>(internal: unknown, props: ReturnType<__sveltets_Render<Option>['props']> & {}): ReturnType<__sveltets_Render<Option>['exports']>;
|
|
15
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
107
16
|
}
|
|
108
|
-
|
|
17
|
+
declare const MultiSelect: $$IsomorphicComponent;
|
|
18
|
+
type MultiSelect<Option extends T> = InstanceType<typeof MultiSelect<Option>>;
|
|
19
|
+
export default MultiSelect;
|
package/dist/Wiggle.svelte
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let dy = 0; // try 10
|
|
9
|
-
export let duration = 200;
|
|
10
|
-
export let stiffness = 0.05;
|
|
11
|
-
export let damping = 0.1;
|
|
12
|
-
let rest_state = { angle: 0, scale: 1, dx: 0, dy: 0 };
|
|
13
|
-
let store = spring(rest_state, { stiffness, damping });
|
|
14
|
-
$: store.set(wiggle ? { scale, angle, dx, dy } : rest_state);
|
|
15
|
-
$: if (wiggle)
|
|
16
|
-
setTimeout(() => (wiggle = false), duration);
|
|
1
|
+
<script lang="ts">import { Spring } from 'svelte/motion';
|
|
2
|
+
let { wiggle = $bindable(false), angle = 0, scale = 1, dx = 0, dy = 0, duration = 200, stiffness = 0.05, damping = 0.1, children, } = $props();
|
|
3
|
+
const store = Spring.of(() => (wiggle ? { scale, angle, dx, dy } : { angle: 0, scale: 1, dx: 0, dy: 0 }), { stiffness, damping });
|
|
4
|
+
$effect.pre(() => {
|
|
5
|
+
if (wiggle)
|
|
6
|
+
setTimeout(() => (wiggle = false), duration);
|
|
7
|
+
});
|
|
17
8
|
</script>
|
|
18
9
|
|
|
19
10
|
<span
|
|
20
|
-
style:transform="rotate({
|
|
21
|
-
{
|
|
11
|
+
style:transform="rotate({store.current.angle}deg) scale({store.current.scale})
|
|
12
|
+
translate({store.current.dx}px, {store.current.dy}px)"
|
|
22
13
|
>
|
|
23
|
-
|
|
14
|
+
{@render children?.()}
|
|
24
15
|
</span>
|
package/dist/Wiggle.svelte.d.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
[evt: string]: CustomEvent<any>;
|
|
15
|
-
};
|
|
16
|
-
slots: {
|
|
17
|
-
default: {};
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type WiggleProps = typeof __propDef.props;
|
|
21
|
-
export type WiggleEvents = typeof __propDef.events;
|
|
22
|
-
export type WiggleSlots = typeof __propDef.slots;
|
|
23
|
-
export default class Wiggle extends SvelteComponent<WiggleProps, WiggleEvents, WiggleSlots> {
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
wiggle?: boolean;
|
|
4
|
+
angle?: number;
|
|
5
|
+
scale?: number;
|
|
6
|
+
dx?: number;
|
|
7
|
+
dy?: number;
|
|
8
|
+
duration?: number;
|
|
9
|
+
stiffness?: number;
|
|
10
|
+
damping?: number;
|
|
11
|
+
children?: Snippet;
|
|
24
12
|
}
|
|
25
|
-
|
|
13
|
+
declare const Wiggle: import("svelte").Component<Props, {}, "wiggle">;
|
|
14
|
+
type Wiggle = ReturnType<typeof Wiggle>;
|
|
15
|
+
export default Wiggle;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
<
|
|
1
|
+
<script lang="ts">let { ...props } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg {...props} fill="currentColor" viewBox="0 0 16 16">
|
|
2
6
|
<path
|
|
3
7
|
d="M3.646 9.146a.5.5 0 0 1 .708 0L8 12.793l3.646-3.647a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 0-.708zm0-2.292a.5.5 0 0 0 .708 0L8 3.207l3.646 3.647a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 0 0 0 .708z"
|
|
4
8
|
/>
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type ChevronExpandProps = typeof __propDef.props;
|
|
11
|
-
export type ChevronExpandEvents = typeof __propDef.events;
|
|
12
|
-
export type ChevronExpandSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
declare const ChevronExpand: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
|
|
3
|
+
type ChevronExpand = ReturnType<typeof ChevronExpand>;
|
|
4
|
+
export default ChevronExpand;
|
package/dist/icons/Cross.svelte
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
<
|
|
1
|
+
<script lang="ts">let { ...props } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<!-- https://api.iconify.design/ic:round-clear.svg -->
|
|
6
|
+
<svg {...props} viewBox="0 0 24 24" fill="currentColor">
|
|
2
7
|
<path
|
|
3
8
|
d="M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59L7.11 5.7A.996.996 0 1 0 5.7 7.11L10.59 12L5.7 16.89a.996.996 0 1 0 1.41 1.41L12 13.41l4.89 4.89a.996.996 0 1 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"
|
|
4
9
|
/>
|
|
5
10
|
</svg>
|
|
6
|
-
<!-- https://api.iconify.design/ic:round-clear.svg -->
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type CrossProps = typeof __propDef.props;
|
|
11
|
-
export type CrossEvents = typeof __propDef.events;
|
|
12
|
-
export type CrossSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
declare const Cross: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
|
|
3
|
+
type Cross = ReturnType<typeof Cross>;
|
|
4
|
+
export default Cross;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
<script lang="ts">let { ...props } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<!-- https://api.iconify.design/fe:disabled.svg -->
|
|
2
|
-
<svg {
|
|
6
|
+
<svg {...props} viewBox="0 0 24 24" fill="currentColor">
|
|
3
7
|
<path
|
|
4
8
|
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12s4.477 10 10 10Zm-4.906-3.68L18.32 7.094A8 8 0 0 1 7.094 18.32ZM5.68 16.906A8 8 0 0 1 16.906 5.68L5.68 16.906Z"
|
|
5
9
|
/>
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type DisabledProps = typeof __propDef.props;
|
|
11
|
-
export type DisabledEvents = typeof __propDef.events;
|
|
12
|
-
export type DisabledSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
declare const Disabled: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
|
|
3
|
+
type Disabled = ReturnType<typeof Disabled>;
|
|
4
|
+
export default Disabled;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
<
|
|
1
|
+
<script lang="ts">let { ...props } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg {...props} viewBox="0 0 24 24" fill="currentColor">
|
|
2
6
|
<path
|
|
3
7
|
d="M8.422 20.081c0 .896.01 1.753.016 2.285a.617.617 0 0 0 .422.58c2.078.686 4.317.718 6.414.091l.292-.087a.67.67 0 0 0 .478-.638c.005-.733.017-2.017.017-3.53c0-1.372-.477-2.25-1.031-2.707c3.399-.366 6.97-1.61 6.97-7.227c0-1.61-.592-2.91-1.566-3.934c.153-.366.688-1.866-.153-3.878c0 0-1.28-.403-4.201 1.5a14.76 14.76 0 0 0-3.82-.494c-1.298 0-2.597.165-3.819.494C5.52.65 4.24 1.036 4.24 1.036c-.84 2.012-.306 3.512-.153 3.878a5.565 5.565 0 0 0-1.566 3.934c0 5.598 3.552 6.86 6.951 7.227c-.439.366-.84 1.006-.973 1.957c-.879.384-3.075 1.006-4.45-1.207c-.286-.44-1.146-1.519-2.349-1.5c-1.28.018-.516.695.02.97c.648.347 1.393 1.646 1.565 2.067c.306.823 1.299 2.396 5.137 1.72Z"
|
|
4
8
|
/>
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type OctocatProps = typeof __propDef.props;
|
|
11
|
-
export type OctocatEvents = typeof __propDef.events;
|
|
12
|
-
export type OctocatSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
declare const Octocat: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
|
|
3
|
+
type Octocat = ReturnType<typeof Octocat>;
|
|
4
|
+
export default Octocat;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export { default as CircleSpinner } from './CircleSpinner.svelte';
|
|
|
2
2
|
export { default as CmdPalette } from './CmdPalette.svelte';
|
|
3
3
|
export { default as MultiSelect, default } from './MultiSelect.svelte';
|
|
4
4
|
export { default as Wiggle } from './Wiggle.svelte';
|
|
5
|
+
export * from './props';
|
|
5
6
|
export * from './types';
|
|
6
|
-
export declare function scroll_into_view_if_needed_polyfill(centerIfNeeded?: boolean): IntersectionObserver;
|
|
7
|
+
export declare function scroll_into_view_if_needed_polyfill(element: Element, centerIfNeeded?: boolean): IntersectionObserver;
|
package/dist/index.js
CHANGED
|
@@ -2,30 +2,32 @@ export { default as CircleSpinner } from './CircleSpinner.svelte';
|
|
|
2
2
|
export { default as CmdPalette } from './CmdPalette.svelte';
|
|
3
3
|
export { default as MultiSelect, default } from './MultiSelect.svelte';
|
|
4
4
|
export { default as Wiggle } from './Wiggle.svelte';
|
|
5
|
+
export * from './props';
|
|
5
6
|
export * from './types';
|
|
6
7
|
// Firefox lacks support for scrollIntoViewIfNeeded (https://caniuse.com/scrollintoviewifneeded).
|
|
7
8
|
// See https://github.com/janosh/svelte-multiselect/issues/87
|
|
8
9
|
// Polyfill copied from
|
|
9
10
|
// https://github.com/nuxodin/lazyfill/blob/a8e63/polyfills/Element/prototype/scrollIntoViewIfNeeded.js
|
|
10
11
|
// exported for testing
|
|
11
|
-
export function scroll_into_view_if_needed_polyfill(centerIfNeeded = true) {
|
|
12
|
-
const
|
|
13
|
-
const observer = new IntersectionObserver(function ([entry]) {
|
|
12
|
+
export function scroll_into_view_if_needed_polyfill(element, centerIfNeeded = true) {
|
|
13
|
+
const observer = new IntersectionObserver(([entry], obs) => {
|
|
14
14
|
const ratio = entry.intersectionRatio;
|
|
15
15
|
if (ratio < 1) {
|
|
16
16
|
const place = ratio <= 0 && centerIfNeeded ? `center` : `nearest`;
|
|
17
|
-
|
|
17
|
+
element.scrollIntoView({
|
|
18
18
|
block: place,
|
|
19
19
|
inline: place,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
obs.disconnect();
|
|
23
23
|
});
|
|
24
|
-
observer.observe(
|
|
24
|
+
observer.observe(element);
|
|
25
25
|
return observer; // return for testing
|
|
26
26
|
}
|
|
27
27
|
if (typeof Element !== `undefined` &&
|
|
28
28
|
!Element.prototype?.scrollIntoViewIfNeeded &&
|
|
29
29
|
typeof IntersectionObserver !== `undefined`) {
|
|
30
|
-
Element.prototype.scrollIntoViewIfNeeded =
|
|
30
|
+
Element.prototype.scrollIntoViewIfNeeded = function scrollIntoViewIfNeeded() {
|
|
31
|
+
scroll_into_view_if_needed_polyfill(this);
|
|
32
|
+
};
|
|
31
33
|
}
|
package/dist/props.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { FocusEventHandler, HTMLInputAttributes, KeyboardEventHandler, MouseEventHandler, TouchEventHandler } from 'svelte/elements';
|
|
3
|
+
import type { Option } from './types';
|
|
4
|
+
export interface MultiSelectNativeEvents {
|
|
5
|
+
onblur?: FocusEventHandler<HTMLInputElement>;
|
|
6
|
+
onclick?: MouseEventHandler<HTMLInputElement>;
|
|
7
|
+
onfocus?: FocusEventHandler<HTMLInputElement>;
|
|
8
|
+
onkeydown?: KeyboardEventHandler<HTMLInputElement>;
|
|
9
|
+
onkeyup?: KeyboardEventHandler<HTMLInputElement>;
|
|
10
|
+
onmousedown?: MouseEventHandler<HTMLInputElement>;
|
|
11
|
+
onmouseenter?: MouseEventHandler<HTMLInputElement>;
|
|
12
|
+
onmouseleave?: MouseEventHandler<HTMLInputElement>;
|
|
13
|
+
ontouchcancel?: TouchEventHandler<HTMLInputElement>;
|
|
14
|
+
ontouchend?: TouchEventHandler<HTMLInputElement>;
|
|
15
|
+
ontouchmove?: TouchEventHandler<HTMLInputElement>;
|
|
16
|
+
ontouchstart?: TouchEventHandler<HTMLInputElement>;
|
|
17
|
+
}
|
|
18
|
+
export interface MultiSelectComponentEvents<T extends Option = Option> {
|
|
19
|
+
onadd?: (data: {
|
|
20
|
+
option: T;
|
|
21
|
+
}) => unknown;
|
|
22
|
+
oncreate?: (data: {
|
|
23
|
+
option: T;
|
|
24
|
+
}) => unknown;
|
|
25
|
+
onremove?: (data: {
|
|
26
|
+
option: T;
|
|
27
|
+
}) => unknown;
|
|
28
|
+
onremoveAll?: (data: {
|
|
29
|
+
options: T[];
|
|
30
|
+
}) => unknown;
|
|
31
|
+
onchange?: (data: {
|
|
32
|
+
option?: T;
|
|
33
|
+
options?: T[];
|
|
34
|
+
type: `add` | `remove` | `removeAll`;
|
|
35
|
+
}) => unknown;
|
|
36
|
+
onopen?: (data: {
|
|
37
|
+
event: Event;
|
|
38
|
+
}) => unknown;
|
|
39
|
+
onclose?: (data: {
|
|
40
|
+
event: Event;
|
|
41
|
+
}) => unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface MultiSelectSnippets<T extends Option = Option> {
|
|
44
|
+
expandIcon?: Snippet<[{
|
|
45
|
+
open: boolean;
|
|
46
|
+
}]>;
|
|
47
|
+
selectedItem?: Snippet<[{
|
|
48
|
+
option: T;
|
|
49
|
+
idx: number;
|
|
50
|
+
}]>;
|
|
51
|
+
children?: Snippet<[{
|
|
52
|
+
option: T;
|
|
53
|
+
idx: number;
|
|
54
|
+
}]>;
|
|
55
|
+
removeIcon?: Snippet;
|
|
56
|
+
afterInput?: Snippet<[
|
|
57
|
+
Pick<MultiSelectParameters, `selected` | `disabled` | `invalid` | `id` | `placeholder` | `open` | `required`>
|
|
58
|
+
]>;
|
|
59
|
+
spinner?: Snippet;
|
|
60
|
+
disabledIcon?: Snippet;
|
|
61
|
+
option?: Snippet<[{
|
|
62
|
+
option: T;
|
|
63
|
+
idx: number;
|
|
64
|
+
}]>;
|
|
65
|
+
userMsg?: Snippet<[
|
|
66
|
+
{
|
|
67
|
+
searchText: string;
|
|
68
|
+
msgType: false | `dupe` | `create` | `no-match`;
|
|
69
|
+
msg: null | string;
|
|
70
|
+
}
|
|
71
|
+
]>;
|
|
72
|
+
}
|
|
73
|
+
export interface MultiSelectParameters<T extends Option = Option> {
|
|
74
|
+
activeIndex?: number | null;
|
|
75
|
+
activeOption?: T | null;
|
|
76
|
+
createOptionMsg?: string | null;
|
|
77
|
+
allowUserOptions?: boolean | `append`;
|
|
78
|
+
allowEmpty?: boolean;
|
|
79
|
+
autocomplete?: HTMLInputAttributes[`autocomplete`];
|
|
80
|
+
autoScroll?: boolean;
|
|
81
|
+
breakpoint?: number;
|
|
82
|
+
defaultDisabledTitle?: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
disabledInputTitle?: string;
|
|
85
|
+
duplicateOptionMsg?: string;
|
|
86
|
+
duplicates?: boolean;
|
|
87
|
+
key?: (opt: T) => unknown;
|
|
88
|
+
filterFunc?: (opt: T, searchText: string) => boolean;
|
|
89
|
+
closeDropdownOnSelect?: boolean | `desktop`;
|
|
90
|
+
form_input?: HTMLInputElement | null;
|
|
91
|
+
highlightMatches?: boolean;
|
|
92
|
+
id?: string | null;
|
|
93
|
+
input?: HTMLInputElement | null;
|
|
94
|
+
inputClass?: string;
|
|
95
|
+
inputStyle?: string | null;
|
|
96
|
+
inputmode?: HTMLInputAttributes[`inputmode`] | null;
|
|
97
|
+
invalid?: boolean;
|
|
98
|
+
liActiveOptionClass?: string;
|
|
99
|
+
liActiveUserMsgClass?: string;
|
|
100
|
+
liOptionClass?: string;
|
|
101
|
+
liOptionStyle?: string | null;
|
|
102
|
+
liSelectedClass?: string;
|
|
103
|
+
liSelectedStyle?: string | null;
|
|
104
|
+
liUserMsgClass?: string;
|
|
105
|
+
loading?: boolean;
|
|
106
|
+
matchingOptions?: T[];
|
|
107
|
+
maxOptions?: number | undefined;
|
|
108
|
+
maxSelect?: number | null;
|
|
109
|
+
maxSelectMsg?: ((current: number, max: number) => string) | null;
|
|
110
|
+
maxSelectMsgClass?: string;
|
|
111
|
+
name?: string | null;
|
|
112
|
+
noMatchingOptionsMsg?: string;
|
|
113
|
+
open?: boolean;
|
|
114
|
+
options: T[];
|
|
115
|
+
outerDiv?: HTMLDivElement | null;
|
|
116
|
+
outerDivClass?: string;
|
|
117
|
+
parseLabelsAsHtml?: boolean;
|
|
118
|
+
pattern?: string | null;
|
|
119
|
+
placeholder?: string | null;
|
|
120
|
+
removeAllTitle?: string;
|
|
121
|
+
removeBtnTitle?: string;
|
|
122
|
+
minSelect?: number | null;
|
|
123
|
+
required?: boolean | number;
|
|
124
|
+
resetFilterOnAdd?: boolean;
|
|
125
|
+
searchText?: string;
|
|
126
|
+
selected?: T[];
|
|
127
|
+
sortSelected?: boolean | ((op1: T, op2: T) => number);
|
|
128
|
+
selectedOptionsDraggable?: boolean;
|
|
129
|
+
style?: string | null;
|
|
130
|
+
ulOptionsClass?: string;
|
|
131
|
+
ulSelectedClass?: string;
|
|
132
|
+
ulSelectedStyle?: string | null;
|
|
133
|
+
ulOptionsStyle?: string | null;
|
|
134
|
+
value?: T | T[] | null;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
}
|
|
137
|
+
export interface MultiSelectProps<T extends Option = Option> extends MultiSelectNativeEvents, MultiSelectComponentEvents<T>, MultiSelectSnippets<T>, MultiSelectParameters<T> {
|
|
138
|
+
}
|
package/dist/props.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -14,43 +14,3 @@ export type ObjectOption = {
|
|
|
14
14
|
style?: OptionStyle;
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
};
|
|
17
|
-
export type DispatchEvents<T = Option> = {
|
|
18
|
-
add: {
|
|
19
|
-
option: T;
|
|
20
|
-
};
|
|
21
|
-
create: {
|
|
22
|
-
option: T;
|
|
23
|
-
};
|
|
24
|
-
remove: {
|
|
25
|
-
option: T;
|
|
26
|
-
};
|
|
27
|
-
removeAll: {
|
|
28
|
-
options: T[];
|
|
29
|
-
};
|
|
30
|
-
change: {
|
|
31
|
-
option?: T;
|
|
32
|
-
options?: T[];
|
|
33
|
-
type: 'add' | 'remove' | 'removeAll';
|
|
34
|
-
};
|
|
35
|
-
open: {
|
|
36
|
-
event: Event;
|
|
37
|
-
};
|
|
38
|
-
close: {
|
|
39
|
-
event: Event;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export type MultiSelectEvents = {
|
|
43
|
-
[key in keyof DispatchEvents]: CustomEvent<DispatchEvents[key]>;
|
|
44
|
-
} & {
|
|
45
|
-
blur: FocusEvent;
|
|
46
|
-
click: MouseEvent;
|
|
47
|
-
focus: FocusEvent;
|
|
48
|
-
keydown: KeyboardEvent;
|
|
49
|
-
keyup: KeyboardEvent;
|
|
50
|
-
mouseenter: MouseEvent;
|
|
51
|
-
mouseleave: MouseEvent;
|
|
52
|
-
touchcancel: TouchEvent;
|
|
53
|
-
touchend: TouchEvent;
|
|
54
|
-
touchmove: TouchEvent;
|
|
55
|
-
touchstart: TouchEvent;
|
|
56
|
-
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import type { Option, OptionStyle } from '
|
|
2
|
-
|
|
1
|
+
import type { Option, OptionStyle } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the label key from an option object or the option itself if it's a string or number
|
|
4
|
+
* @param opt Option
|
|
5
|
+
* @returns Label
|
|
6
|
+
*/
|
|
7
|
+
export declare const get_label: (opt: Option) => any;
|
|
8
|
+
/**
|
|
9
|
+
* This function is used extract CSS strings from a {selected, option} style object to be used in the style attribute of the option.
|
|
10
|
+
* If the style is a string, it will be returned as is
|
|
11
|
+
* @param option Option
|
|
12
|
+
* @param key
|
|
13
|
+
* @returns CSS string
|
|
14
|
+
*/
|
|
3
15
|
export declare function get_style(option: {
|
|
4
16
|
style?: OptionStyle;
|
|
5
17
|
[key: string]: unknown;
|
|
6
|
-
} | string | number, key?:
|
|
18
|
+
} | string | number, key?: `selected` | `option` | null): any;
|
|
19
|
+
/**
|
|
20
|
+
* Highlights text nodes that matching the string query
|
|
21
|
+
* @param element Parent element
|
|
22
|
+
* @param query Search query
|
|
23
|
+
* @param noMatchingOptionsMsg Text for empty node
|
|
24
|
+
*/
|
|
25
|
+
export declare function highlight_matching_nodes(element: HTMLElement, query?: string, noMatchingOptionsMsg?: string): void;
|