svelte-multiselect 11.0.0-rc.1 → 11.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/dist/CircleSpinner.svelte +3 -4
- package/dist/CircleSpinner.svelte.d.ts +7 -19
- package/dist/CmdPalette.svelte +19 -37
- package/dist/CmdPalette.svelte.d.ts +19 -32
- package/dist/MultiSelect.svelte +322 -288
- package/dist/MultiSelect.svelte.d.ts +16 -105
- package/dist/Wiggle.svelte +10 -19
- package/dist/Wiggle.svelte.d.ts +14 -26
- package/dist/icons/ChevronExpand.svelte +5 -1
- package/dist/icons/ChevronExpand.svelte.d.ts +4 -25
- package/dist/icons/Cross.svelte +6 -2
- package/dist/icons/Cross.svelte.d.ts +4 -25
- package/dist/icons/Disabled.svelte +5 -1
- package/dist/icons/Disabled.svelte.d.ts +4 -25
- package/dist/icons/Octocat.svelte +5 -1
- package/dist/icons/Octocat.svelte.d.ts +4 -25
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -7
- package/dist/props.d.ts +143 -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 +34 -31
- package/readme.md +45 -66
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
export let size = `1em`;
|
|
1
|
+
<script lang="ts">"use strict";
|
|
2
|
+
let { color = `cornflowerblue`, duration = `1.5s`, size = `1em` } = $props();
|
|
4
3
|
</script>
|
|
5
4
|
|
|
6
5
|
<div
|
|
@@ -9,7 +8,7 @@ export let size = `1em`;
|
|
|
9
8
|
{color}"
|
|
10
9
|
style:width={size}
|
|
11
10
|
style:height={size}
|
|
12
|
-
|
|
11
|
+
></div>
|
|
13
12
|
|
|
14
13
|
<style>
|
|
15
14
|
div {
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
duration?: string;
|
|
6
|
-
size?: string;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type CircleSpinnerProps = typeof __propDef.props;
|
|
16
|
-
export type CircleSpinnerEvents = typeof __propDef.events;
|
|
17
|
-
export type CircleSpinnerSlots = typeof __propDef.slots;
|
|
18
|
-
export default class CircleSpinner extends SvelteComponent<CircleSpinnerProps, CircleSpinnerEvents, CircleSpinnerSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
color?: string;
|
|
3
|
+
duration?: string;
|
|
4
|
+
size?: string;
|
|
19
5
|
}
|
|
20
|
-
|
|
6
|
+
declare const CircleSpinner: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type CircleSpinner = ReturnType<typeof CircleSpinner>;
|
|
8
|
+
export default CircleSpinner;
|
package/dist/CmdPalette.svelte
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { fade } from 'svelte/transition';
|
|
1
|
+
<script lang="ts">import { fade } from 'svelte/transition';
|
|
3
2
|
import Select from './MultiSelect.svelte';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// for span in option slot, has no effect when passing a slot
|
|
10
|
-
export let span_style = ``;
|
|
11
|
-
export let open = false;
|
|
12
|
-
export let dialog = null;
|
|
13
|
-
export let input = null;
|
|
14
|
-
export let placeholder = `Filter actions...`;
|
|
3
|
+
let { actions, triggers = [`k`], close_keys = [`Escape`], fade_duration = 200, style = ``, open = $bindable(false), dialog = $bindable(null), input = $bindable(null), placeholder = `Filter actions...`, ...rest } = $props();
|
|
4
|
+
$effect(() => {
|
|
5
|
+
if (open && input)
|
|
6
|
+
input?.focus(); // focus input when palette is opened
|
|
7
|
+
});
|
|
15
8
|
async function toggle(event) {
|
|
16
9
|
if (triggers.includes(event.key) && event.metaKey && !open) {
|
|
17
|
-
// open on cmd+trigger
|
|
18
10
|
open = true;
|
|
19
|
-
await tick(); // wait for dialog to open and input to be mounted
|
|
20
|
-
input?.focus();
|
|
21
11
|
}
|
|
22
12
|
else if (close_keys.includes(event.key) && open) {
|
|
23
13
|
open = false;
|
|
@@ -28,13 +18,13 @@ function close_if_outside(event) {
|
|
|
28
18
|
open = false;
|
|
29
19
|
}
|
|
30
20
|
}
|
|
31
|
-
function trigger_action_and_close(
|
|
32
|
-
|
|
21
|
+
function trigger_action_and_close({ option }) {
|
|
22
|
+
option.action(option.label);
|
|
33
23
|
open = false;
|
|
34
24
|
}
|
|
35
25
|
</script>
|
|
36
26
|
|
|
37
|
-
<svelte:window
|
|
27
|
+
<svelte:window onkeydown={toggle} onclick={close_if_outside} />
|
|
38
28
|
|
|
39
29
|
{#if open}
|
|
40
30
|
<dialog open bind:this={dialog} transition:fade={{ duration: fade_duration }} {style}>
|
|
@@ -42,16 +32,16 @@ function trigger_action_and_close(event) {
|
|
|
42
32
|
options={actions}
|
|
43
33
|
bind:input
|
|
44
34
|
{placeholder}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
onadd={trigger_action_and_close}
|
|
36
|
+
onkeydown={toggle}
|
|
37
|
+
{...rest}
|
|
38
|
+
--sms-bg="var(--sms-options-bg)"
|
|
39
|
+
--sms-width="min(20em, 90vw)"
|
|
40
|
+
--sms-max-width="none"
|
|
41
|
+
--sms-placeholder-color="lightgray"
|
|
42
|
+
--sms-options-margin="1px 0"
|
|
43
|
+
--sms-options-border-radius="0 0 1ex 1ex"
|
|
44
|
+
/>
|
|
55
45
|
</dialog>
|
|
56
46
|
{/if}
|
|
57
47
|
|
|
@@ -67,12 +57,4 @@ function trigger_action_and_close(event) {
|
|
|
67
57
|
z-index: 10;
|
|
68
58
|
font-size: 2.4ex;
|
|
69
59
|
}
|
|
70
|
-
dialog :global(div.multiselect) {
|
|
71
|
-
--sms-bg: var(--sms-options-bg);
|
|
72
|
-
--sms-width: min(20em, 90vw);
|
|
73
|
-
--sms-max-width: none;
|
|
74
|
-
--sms-placeholder-color: lightgray;
|
|
75
|
-
--sms-options-margin: 1px 0;
|
|
76
|
-
--sms-options-border-radius: 0 0 1ex 1ex;
|
|
77
|
-
}
|
|
78
60
|
</style>
|
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
label: string;
|
|
7
|
-
action: () => void;
|
|
8
|
-
}[];
|
|
9
|
-
triggers?: string[] | undefined;
|
|
10
|
-
close_keys?: string[] | undefined;
|
|
11
|
-
fade_duration?: number | undefined;
|
|
12
|
-
style?: string | undefined;
|
|
13
|
-
span_style?: string | undefined;
|
|
14
|
-
open?: boolean | undefined;
|
|
15
|
-
dialog?: (HTMLDialogElement | null) | undefined;
|
|
16
|
-
input?: (HTMLInputElement | null) | undefined;
|
|
17
|
-
placeholder?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
events: {
|
|
20
|
-
[evt: string]: CustomEvent<any>;
|
|
21
|
-
};
|
|
22
|
-
slots: {
|
|
23
|
-
default: {};
|
|
24
|
-
};
|
|
25
|
-
exports?: undefined;
|
|
26
|
-
bindings?: undefined;
|
|
27
|
-
};
|
|
28
|
-
export type CmdPaletteProps = typeof __propDef.props;
|
|
29
|
-
export type CmdPaletteEvents = typeof __propDef.events;
|
|
30
|
-
export type CmdPaletteSlots = typeof __propDef.slots;
|
|
31
|
-
export default class CmdPalette extends SvelteComponent<CmdPaletteProps, CmdPaletteEvents, CmdPaletteSlots> {
|
|
1
|
+
import type { MultiSelectProps } from './props';
|
|
2
|
+
import type { ObjectOption } from './types';
|
|
3
|
+
interface Action extends ObjectOption {
|
|
4
|
+
label: string;
|
|
5
|
+
action: (label: string) => void;
|
|
32
6
|
}
|
|
33
|
-
|
|
7
|
+
interface Props extends Omit<MultiSelectProps<Action>, `options` | `onadd` | `onkeydown` | `placeholder`> {
|
|
8
|
+
actions: Action[];
|
|
9
|
+
triggers?: string[];
|
|
10
|
+
close_keys?: string[];
|
|
11
|
+
fade_duration?: number;
|
|
12
|
+
style?: string;
|
|
13
|
+
open?: boolean;
|
|
14
|
+
dialog?: HTMLDialogElement | null;
|
|
15
|
+
input?: HTMLInputElement | null;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const CmdPalette: import("svelte").Component<Props, {}, "open" | "input" | "dialog">;
|
|
19
|
+
type CmdPalette = ReturnType<typeof CmdPalette>;
|
|
20
|
+
export default CmdPalette;
|