svelte-multiselect 11.2.3 → 11.3.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.d.ts +3 -3
- package/dist/CmdPalette.svelte +20 -13
- package/dist/CmdPalette.svelte.d.ts +61 -14
- package/dist/CodeExample.svelte +10 -3
- package/dist/CodeExample.svelte.d.ts +6 -3
- package/dist/CopyButton.svelte +26 -4
- package/dist/CopyButton.svelte.d.ts +4 -4
- package/dist/FileDetails.svelte +3 -3
- package/dist/FileDetails.svelte.d.ts +6 -3
- package/dist/GitHubCorner.svelte.d.ts +3 -3
- package/dist/Icon.svelte.d.ts +4 -4
- package/dist/MultiSelect.svelte +86 -62
- package/dist/MultiSelect.svelte.d.ts +9 -9
- package/dist/Nav.svelte +447 -0
- package/dist/Nav.svelte.d.ts +42 -0
- package/dist/PrevNext.svelte +11 -10
- package/dist/PrevNext.svelte.d.ts +16 -15
- package/dist/Toggle.svelte +4 -8
- package/dist/Toggle.svelte.d.ts +5 -10
- package/dist/Wiggle.svelte.d.ts +3 -3
- package/dist/attachments.d.ts +9 -6
- package/dist/attachments.js +124 -35
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +4 -20
- package/dist/utils.d.ts +3 -8
- package/dist/utils.js +24 -48
- package/package.json +19 -19
- package/readme.md +4 -6
- package/dist/RadioButtons.svelte +0 -67
- package/dist/RadioButtons.svelte.d.ts +0 -51
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type $$ComponentProps = {
|
|
2
2
|
color?: string;
|
|
3
3
|
duration?: string;
|
|
4
4
|
size?: string;
|
|
5
|
-
}
|
|
6
|
-
declare const CircleSpinner: import("svelte").Component
|
|
5
|
+
};
|
|
6
|
+
declare const CircleSpinner: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
7
|
type CircleSpinner = ReturnType<typeof CircleSpinner>;
|
|
8
8
|
export default CircleSpinner;
|
package/dist/CmdPalette.svelte
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
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();
|
|
4
7
|
$effect(() => {
|
|
5
|
-
if (open && input && document.activeElement !== input)
|
|
8
|
+
if (open && input && document.activeElement !== input)
|
|
6
9
|
input.focus();
|
|
7
|
-
}
|
|
8
10
|
});
|
|
9
11
|
async function toggle(event) {
|
|
10
|
-
|
|
12
|
+
const is_trigger = triggers.includes(event.key) &&
|
|
13
|
+
(event.metaKey || event.ctrlKey);
|
|
14
|
+
if (is_trigger && !open)
|
|
11
15
|
open = true;
|
|
12
|
-
|
|
13
|
-
else if (close_keys.includes(event.key) && open) {
|
|
16
|
+
else if (close_keys.includes(event.key) && open)
|
|
14
17
|
open = false;
|
|
15
|
-
}
|
|
16
18
|
}
|
|
17
19
|
function close_if_outside(event) {
|
|
18
|
-
|
|
20
|
+
const target = event.target;
|
|
21
|
+
if (!target || !(target instanceof HTMLElement))
|
|
22
|
+
return;
|
|
23
|
+
if (open && !dialog?.contains(target) && !target.closest(`ul.options`)) {
|
|
19
24
|
open = false;
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
|
-
function trigger_action_and_close(
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
function trigger_action_and_close({ option }) {
|
|
28
|
+
if (!option?.action)
|
|
29
|
+
return;
|
|
30
|
+
option.action(option.label);
|
|
25
31
|
open = false;
|
|
26
32
|
}
|
|
27
33
|
</script>
|
|
@@ -34,6 +40,7 @@ function trigger_action_and_close(data) {
|
|
|
34
40
|
bind:this={dialog}
|
|
35
41
|
transition:fade={{ duration: fade_duration }}
|
|
36
42
|
style={dialog_style}
|
|
43
|
+
{...dialog_props}
|
|
37
44
|
>
|
|
38
45
|
<MultiSelect
|
|
39
46
|
options={actions}
|
|
@@ -1,19 +1,66 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
declare function $$render<Action extends {
|
|
3
3
|
label: string;
|
|
4
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(): {};
|
|
5
38
|
}
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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']>;
|
|
16
57
|
}
|
|
17
|
-
declare const CmdPalette:
|
|
18
|
-
type CmdPalette
|
|
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>>;
|
|
19
66
|
export default CmdPalette;
|
package/dist/CodeExample.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">// see svelte.config.js where this component is passed to mdsvexamples
|
|
2
2
|
import { Icon } from './';
|
|
3
|
-
let { src = ``, meta = {}, open = $bindable(!meta.collapsible), title, example, code,
|
|
3
|
+
let { src = ``, meta = {}, open = $bindable(!meta.collapsible), title, example, code, link_props, // Applied after computed attributes (href, title, etc.), allowing override
|
|
4
|
+
button_props, } = $props();
|
|
4
5
|
let { id, collapsible, code_above, repl, github, repo, file } = $derived(meta);
|
|
5
6
|
const links = { target: `_blank`, rel: `noreferrer` };
|
|
6
7
|
</script>
|
|
@@ -17,13 +18,19 @@ const links = { target: `_blank`, rel: `noreferrer` };
|
|
|
17
18
|
{ cond, href, icon }
|
|
18
19
|
(icon)
|
|
19
20
|
}
|
|
20
|
-
<a
|
|
21
|
+
<a
|
|
22
|
+
{href}
|
|
23
|
+
{...links}
|
|
24
|
+
title={icon}
|
|
25
|
+
style:display={cond ? `inline-block` : `none`}
|
|
26
|
+
{...link_props}
|
|
27
|
+
>
|
|
21
28
|
<Icon {icon} />
|
|
22
29
|
</a>
|
|
23
30
|
{/each}
|
|
24
31
|
{#if collapsible}
|
|
25
32
|
{@render title?.()}
|
|
26
|
-
<button onclick={() => (open = !open)}>
|
|
33
|
+
<button onclick={() => (open = !open)} {...button_props}>
|
|
27
34
|
<Icon icon={open ? `Collapse` : `Expand`} />
|
|
28
35
|
{open ? `Close` : `View code`}
|
|
29
36
|
</button>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = {
|
|
3
4
|
src?: string;
|
|
4
5
|
meta?: {
|
|
5
6
|
collapsible?: boolean;
|
|
@@ -16,7 +17,9 @@ interface Props {
|
|
|
16
17
|
title?: Snippet<[]>;
|
|
17
18
|
example?: Snippet<[]>;
|
|
18
19
|
code?: Snippet<[]>;
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
link_props?: HTMLAttributes<HTMLAnchorElement>;
|
|
21
|
+
button_props?: HTMLAttributes<HTMLButtonElement>;
|
|
22
|
+
};
|
|
23
|
+
declare const CodeExample: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
21
24
|
type CodeExample = ReturnType<typeof CodeExample>;
|
|
22
25
|
export default CodeExample;
|
package/dist/CopyButton.svelte
CHANGED
|
@@ -9,14 +9,23 @@ $effect(() => {
|
|
|
9
9
|
if (!global && !global_selector)
|
|
10
10
|
return;
|
|
11
11
|
const apply_copy_buttons = () => {
|
|
12
|
-
const btn_style = `position: absolute; top:
|
|
12
|
+
const btn_style = `position: absolute; top: 6pt; right: 6pt; ${rest.style ?? ``}`;
|
|
13
|
+
const skip_sel = skip_selector ?? as;
|
|
13
14
|
for (const code of document.querySelectorAll(global_selector ?? `pre > code`)) {
|
|
14
15
|
const pre = code.parentElement;
|
|
15
16
|
const content = code.textContent ?? ``;
|
|
16
|
-
if (pre && !
|
|
17
|
+
if (pre && !pre.querySelector(`[data-sms-copy]`) &&
|
|
18
|
+
!(skip_sel && pre.querySelector(skip_sel))) {
|
|
17
19
|
mount(CopyButton, {
|
|
18
20
|
target: pre,
|
|
19
|
-
props: {
|
|
21
|
+
props: {
|
|
22
|
+
content,
|
|
23
|
+
as,
|
|
24
|
+
labels,
|
|
25
|
+
...rest,
|
|
26
|
+
style: btn_style,
|
|
27
|
+
'data-sms-copy': ``,
|
|
28
|
+
},
|
|
20
29
|
});
|
|
21
30
|
}
|
|
22
31
|
}
|
|
@@ -41,7 +50,20 @@ async function copy() {
|
|
|
41
50
|
|
|
42
51
|
{#if !(global || global_selector)}
|
|
43
52
|
{@const { text, icon } = labels[state]}
|
|
44
|
-
<svelte:element
|
|
53
|
+
<svelte:element
|
|
54
|
+
this={as}
|
|
55
|
+
onclick={copy}
|
|
56
|
+
onkeydown={(event) => {
|
|
57
|
+
if (event.key === `Enter` || event.key === ` `) {
|
|
58
|
+
event.preventDefault()
|
|
59
|
+
copy()
|
|
60
|
+
}
|
|
61
|
+
}}
|
|
62
|
+
role="button"
|
|
63
|
+
tabindex={0}
|
|
64
|
+
data-sms-copy=""
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
45
67
|
{#if children}
|
|
46
68
|
{@render children({ state, icon, text })}
|
|
47
69
|
{:else}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CopyButton } from './';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import type { IconName } from './icons';
|
|
4
5
|
type State = `ready` | `success` | `error`;
|
|
5
|
-
|
|
6
|
+
type $$ComponentProps = Omit<HTMLAttributes<HTMLButtonElement>, `children`> & {
|
|
6
7
|
content?: string;
|
|
7
8
|
state?: State;
|
|
8
9
|
global_selector?: string | null;
|
|
@@ -18,8 +19,7 @@ interface Props {
|
|
|
18
19
|
icon: IconName;
|
|
19
20
|
text: string;
|
|
20
21
|
}]>;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
declare const CopyButton: import("svelte").Component<Props, {}, "state">;
|
|
22
|
+
};
|
|
23
|
+
declare const CopyButton: import("svelte").Component<$$ComponentProps, {}, "state">;
|
|
24
24
|
type CopyButton = ReturnType<typeof CopyButton>;
|
|
25
25
|
export default CopyButton;
|
package/dist/FileDetails.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">let { files = $bindable([]), toggle_all_btn_title = `Toggle all`, default_lang = `typescript`, as = `ol`, style = null, title_snippet, } = $props();
|
|
1
|
+
<script lang="ts">let { files = $bindable([]), toggle_all_btn_title = `Toggle all`, default_lang = `typescript`, as = `ol`, style = null, title_snippet, button_props, details_props, } = $props();
|
|
2
2
|
function toggle_all() {
|
|
3
3
|
const any_open = files.some((file) => file.node?.open);
|
|
4
4
|
for (const file of files) {
|
|
@@ -11,7 +11,7 @@ export {};
|
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
{#if files?.length > 1}
|
|
14
|
-
<button onclick={toggle_all} title={toggle_all_btn_title}>
|
|
14
|
+
<button onclick={toggle_all} title={toggle_all_btn_title} {...button_props}>
|
|
15
15
|
{files.some((file) => file.node?.open) ? `Close` : `Open`} all
|
|
16
16
|
</button>
|
|
17
17
|
{/if}
|
|
@@ -21,7 +21,7 @@ export {};
|
|
|
21
21
|
{@const { title, content, language = default_lang } = file ?? {}}
|
|
22
22
|
<li>
|
|
23
23
|
<!-- https://github.com/sveltejs/svelte/issues/12721#issuecomment-2269544690 -->
|
|
24
|
-
<details bind:this={file.node}>
|
|
24
|
+
<details bind:this={file.node} {...details_props}>
|
|
25
25
|
{#if title || title_snippet}
|
|
26
26
|
<summary>
|
|
27
27
|
{#if title_snippet}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes, HTMLDetailsAttributes } from 'svelte/elements';
|
|
2
3
|
type File = {
|
|
3
4
|
title: string;
|
|
4
5
|
content: string;
|
|
5
6
|
language?: string;
|
|
6
7
|
node?: HTMLDetailsElement | null;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
type $$ComponentProps = {
|
|
9
10
|
files?: File[];
|
|
10
11
|
toggle_all_btn_title?: string;
|
|
11
12
|
default_lang?: string;
|
|
@@ -14,7 +15,9 @@ interface Props {
|
|
|
14
15
|
title_snippet?: Snippet<[{
|
|
15
16
|
idx: number;
|
|
16
17
|
} & File]>;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
button_props?: HTMLAttributes<HTMLButtonElement>;
|
|
19
|
+
details_props?: HTMLDetailsAttributes;
|
|
20
|
+
};
|
|
21
|
+
declare const FileDetails: import("svelte").Component<$$ComponentProps, {}, "files">;
|
|
19
22
|
type FileDetails = ReturnType<typeof FileDetails>;
|
|
20
23
|
export default FileDetails;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type $$ComponentProps = {
|
|
2
2
|
href: string;
|
|
3
3
|
title?: string;
|
|
4
4
|
aria_label?: string;
|
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
fill?: string | null;
|
|
8
8
|
corner?: `top-left` | `top-right` | `bottom-left` | `bottom-right`;
|
|
9
9
|
style?: string;
|
|
10
|
-
}
|
|
11
|
-
declare const GitHubCorner: import("svelte").Component
|
|
10
|
+
};
|
|
11
|
+
declare const GitHubCorner: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
12
|
type GitHubCorner = ReturnType<typeof GitHubCorner>;
|
|
13
13
|
export default GitHubCorner;
|
package/dist/Icon.svelte.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
1
2
|
import { type IconName } from './icons';
|
|
2
|
-
|
|
3
|
+
type $$ComponentProps = HTMLAttributes<SVGSVGElement> & {
|
|
3
4
|
icon: IconName;
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const Icon: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
};
|
|
6
|
+
declare const Icon: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
7
|
type Icon = ReturnType<typeof Icon>;
|
|
8
8
|
export default Icon;
|