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.
@@ -1,74 +0,0 @@
1
- <script lang="ts">import { mount } from 'svelte';
2
- import CopyButton from './CopyButton.svelte';
3
- import Icon from './Icon.svelte';
4
- let { content = ``, state = $bindable(`ready`), global_selector = null, global = false, skip_selector = `button`, as = `button`, labels = {
5
- ready: { icon: `Copy`, text: `` },
6
- success: { icon: `Check`, text: `` },
7
- error: { icon: `Alert`, text: `` },
8
- }, children, ...rest } = $props();
9
- $effect(() => {
10
- if (!global && !global_selector)
11
- return;
12
- const apply_copy_buttons = () => {
13
- const btn_style = `position: absolute; top: 6pt; right: 6pt; ${rest.style ?? ``}`;
14
- const skip_sel = skip_selector ?? as;
15
- for (const code of document.querySelectorAll(global_selector ?? `pre > code`)) {
16
- const pre = code.parentElement;
17
- const content = code.textContent ?? ``;
18
- if (pre && !pre.querySelector(`[data-sms-copy]`) &&
19
- !(skip_sel && pre.querySelector(skip_sel))) {
20
- mount(CopyButton, {
21
- target: pre,
22
- props: {
23
- content,
24
- as,
25
- labels,
26
- ...rest,
27
- style: btn_style,
28
- 'data-sms-copy': ``,
29
- },
30
- });
31
- }
32
- }
33
- };
34
- apply_copy_buttons();
35
- const observer = new MutationObserver(apply_copy_buttons);
36
- observer.observe(document.body, { childList: true, subtree: true });
37
- return () => observer.disconnect();
38
- });
39
- async function copy() {
40
- try {
41
- await navigator.clipboard.writeText(content);
42
- state = `success`;
43
- }
44
- catch (err) {
45
- console.error(err);
46
- state = `error`;
47
- }
48
- setTimeout(() => (state = `ready`), 2000);
49
- }
50
- </script>
51
-
52
- {#if !(global || global_selector)}
53
- {@const { text, icon } = labels[state]}
54
- <svelte:element
55
- this={as}
56
- onclick={copy}
57
- onkeydown={(event) => {
58
- if (event.key === `Enter` || event.key === ` `) {
59
- event.preventDefault()
60
- copy()
61
- }
62
- }}
63
- role="button"
64
- tabindex={0}
65
- data-sms-copy=""
66
- {...rest}
67
- >
68
- {#if children}
69
- {@render children({ state, icon, text })}
70
- {:else}
71
- <Icon {icon} />{@html text}
72
- {/if}
73
- </svelte:element>
74
- {/if}
@@ -1,25 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- import CopyButton from './CopyButton.svelte';
4
- import type { IconName } from './icons';
5
- type State = `ready` | `success` | `error`;
6
- type $$ComponentProps = Omit<HTMLAttributes<HTMLButtonElement>, `children`> & {
7
- content?: string;
8
- state?: State;
9
- global_selector?: string | null;
10
- global?: boolean;
11
- skip_selector?: string | null;
12
- as?: string;
13
- labels?: Record<State, {
14
- icon: IconName;
15
- text: string;
16
- }>;
17
- children?: Snippet<[{
18
- state: State;
19
- icon: IconName;
20
- text: string;
21
- }]>;
22
- };
23
- declare const CopyButton: import("svelte").Component<$$ComponentProps, {}, "state">;
24
- type CopyButton = ReturnType<typeof CopyButton>;
25
- export default CopyButton;
@@ -1,52 +0,0 @@
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
- function toggle_all() {
3
- const any_open = files.some((file) => file.node?.open);
4
- for (const file of files) {
5
- if (!file.node)
6
- continue;
7
- file.node.open = !any_open;
8
- }
9
- }
10
- export {};
11
- </script>
12
-
13
- {#if files?.length > 1}
14
- <button onclick={toggle_all} title={toggle_all_btn_title} {...button_props}>
15
- {files.some((file) => file.node?.open) ? `Close` : `Open`} all
16
- </button>
17
- {/if}
18
-
19
- <svelte:element this={as} {style}>
20
- {#each files as file, idx (file.title)}
21
- {@const { title, content, language = default_lang } = file ?? {}}
22
- <li>
23
- <!-- https://github.com/sveltejs/svelte/issues/12721#issuecomment-2269544690 -->
24
- <details bind:this={file.node} {...details_props}>
25
- {#if title || title_snippet}
26
- <summary>
27
- {#if title_snippet}
28
- {@render title_snippet({ idx, ...file })}
29
- {:else}
30
- {@html title}
31
- {/if}
32
- </summary>
33
- {/if}
34
-
35
- <pre class="language-{language}"><code>{content}</code></pre>
36
- <!-- <pre><code>{@html hljs.highlight(content, { language }).value}</code></pre> -->
37
- </details>
38
- </li>
39
- {/each}
40
- </svelte:element>
41
-
42
- <style>
43
- button {
44
- float: right;
45
- }
46
- ol {
47
- padding: 0;
48
- }
49
- ol > li {
50
- margin: 1ex 0;
51
- }
52
- </style>
@@ -1,23 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import type { HTMLAttributes, HTMLDetailsAttributes } from 'svelte/elements';
3
- type File = {
4
- title: string;
5
- content: string;
6
- language?: string;
7
- node?: HTMLDetailsElement | null;
8
- };
9
- type $$ComponentProps = {
10
- files?: File[];
11
- toggle_all_btn_title?: string;
12
- default_lang?: string;
13
- as?: string;
14
- style?: string | null;
15
- title_snippet?: Snippet<[{
16
- idx: number;
17
- } & File]>;
18
- button_props?: HTMLAttributes<HTMLButtonElement>;
19
- details_props?: HTMLDetailsAttributes;
20
- };
21
- declare const FileDetails: import("svelte").Component<$$ComponentProps, {}, "files">;
22
- type FileDetails = ReturnType<typeof FileDetails>;
23
- export default FileDetails;
@@ -1,82 +0,0 @@
1
- <script lang="ts">"use strict";
2
- // Display an animated Octocat in a corner of the screen to link to the GitHub repo.
3
- let { href, title = `View code on GitHub`, aria_label, target = `_self`, color = null, fill = null, corner = `top-right`, style = ``, } = $props();
4
- </script>
5
-
6
- <a
7
- {href}
8
- {target}
9
- {title}
10
- aria-label={aria_label ?? title}
11
- {style}
12
- class={corner}
13
- style:color
14
- style:fill
15
- >
16
- <svg viewBox="0 0 250 250" aria-hidden="true">
17
- <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
18
- <path
19
- d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
20
- fill="currentColor"
21
- style="transform-origin: 130px 106px"
22
- class="octo-arm"
23
- />
24
- <path
25
- d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
26
- fill="currentColor"
27
- class="octo-body"
28
- />
29
- </svg>
30
- </a>
31
-
32
- <style>
33
- a {
34
- position: fixed;
35
- z-index: 1;
36
- fill: var(--github-corner-bg, black);
37
- color: var(--github-corner-color, white);
38
- width: var(--github-corner-size, 70px);
39
- }
40
- a.top-right {
41
- top: 0;
42
- right: 0;
43
- }
44
- a.top-left {
45
- top: 0;
46
- left: 0;
47
- transform: rotate(-90deg);
48
- }
49
- a.bottom-left {
50
- bottom: 0;
51
- left: 0;
52
- transform: rotate(180deg);
53
- }
54
- a.bottom-right {
55
- bottom: 0;
56
- right: 0;
57
- transform: rotate(90deg);
58
- }
59
- a:hover .octo-arm {
60
- animation: octocat-wave 0.5s ease-in-out;
61
- }
62
- @keyframes octocat-wave {
63
- 0%,
64
- 100% {
65
- transform: rotate(0);
66
- }
67
- 20%,
68
- 60% {
69
- transform: rotate(-25deg);
70
- }
71
- 40%,
72
- 80% {
73
- transform: rotate(10deg);
74
- }
75
- }
76
- /* hide this component by default when printing since it would show up on every page */
77
- @media print {
78
- a {
79
- display: var(--github-corner-print-display, none);
80
- }
81
- }
82
- </style>
@@ -1,13 +0,0 @@
1
- type $$ComponentProps = {
2
- href: string;
3
- title?: string;
4
- aria_label?: string;
5
- target?: `_self` | `_blank`;
6
- color?: string | null;
7
- fill?: string | null;
8
- corner?: `top-left` | `top-right` | `bottom-left` | `bottom-right`;
9
- style?: string;
10
- };
11
- declare const GitHubCorner: import("svelte").Component<$$ComponentProps, {}, "">;
12
- type GitHubCorner = ReturnType<typeof GitHubCorner>;
13
- export default GitHubCorner;
package/dist/Icon.svelte DELETED
@@ -1,23 +0,0 @@
1
- <script lang="ts">import { icon_data } from './icons';
2
- let { icon, ...rest } = $props();
3
- const data = $derived.by(() => {
4
- if (!(icon in icon_data)) {
5
- console.error(`Icon '${icon}' not found`);
6
- return icon_data.Alert; // fallback
7
- }
8
- return icon_data[icon];
9
- });
10
- </script>
11
-
12
- <svg viewBox={data.viewBox} fill="currentColor" {...rest}>
13
- <path d={data.path} />
14
- </svg>
15
-
16
- <style>
17
- svg {
18
- width: 1em;
19
- height: 1em;
20
- display: inline-block;
21
- vertical-align: middle;
22
- }
23
- </style>
@@ -1,8 +0,0 @@
1
- import type { HTMLAttributes } from 'svelte/elements';
2
- import { type IconName } from './icons';
3
- type $$ComponentProps = HTMLAttributes<SVGSVGElement> & {
4
- icon: IconName;
5
- };
6
- declare const Icon: import("svelte").Component<$$ComponentProps, {}, "">;
7
- type Icon = ReturnType<typeof Icon>;
8
- export default Icon;