kosui 0.2.0 → 0.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.
- package/README.md +34 -3
- package/dist/alert/alert.svelte +16 -157
- package/dist/alert/alert.svelte.d.ts +3 -26
- package/dist/alert/index.d.ts +1 -1
- package/dist/alert/index.js +1 -1
- package/dist/autocomplete/autocomplete.svelte +126 -12
- package/dist/autocomplete/autocomplete.svelte.d.ts +30 -6
- package/dist/autocomplete/index.d.ts +1 -5
- package/dist/autocomplete/index.js +1 -5
- package/dist/avatar/avatar.svelte +16 -10
- package/dist/badge/badge.svelte +31 -20
- package/dist/badge/badge.svelte.d.ts +8 -4
- package/dist/badge/index.d.ts +1 -1
- package/dist/base.d.ts +4 -8
- package/dist/base.js +14 -28
- package/dist/box/box.svelte +2 -14
- package/dist/box/box.svelte.d.ts +0 -2
- package/dist/breadcrumbs/breadcrumbs.svelte +38 -19
- package/dist/breadcrumbs/breadcrumbs.svelte.d.ts +6 -4
- package/dist/breadcrumbs/index.d.ts +1 -1
- package/dist/breadcrumbs/index.js +1 -1
- package/dist/button/button.svelte +96 -31
- package/dist/button/button.svelte.d.ts +11 -5
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.js +1 -1
- package/dist/chip/chip.svelte +62 -14
- package/dist/chip/chip.svelte.d.ts +2 -1
- package/dist/command/action.svelte.js +13 -18
- package/dist/command/command-palette.svelte +163 -0
- package/dist/command/command-palette.svelte.d.ts +11 -0
- package/dist/command/index.d.ts +1 -8
- package/dist/command/index.js +1 -8
- package/dist/common/divider.svelte +10 -5
- package/dist/common/divider.svelte.d.ts +3 -3
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.js +0 -2
- package/dist/dialog/dialog-provider.svelte +70 -0
- package/dist/dialog/dialog-provider.svelte.d.ts +7 -0
- package/dist/dialog/dialog.svelte +33 -35
- package/dist/dialog/dialog.svelte.d.ts +4 -8
- package/dist/dialog/dialogs.svelte.d.ts +49 -0
- package/dist/dialog/dialogs.svelte.js +73 -0
- package/dist/dialog/index.d.ts +2 -3
- package/dist/dialog/index.js +2 -3
- package/dist/drawer/drawer.svelte +51 -0
- package/dist/drawer/drawer.svelte.d.ts +8 -0
- package/dist/drawer/index.d.ts +1 -0
- package/dist/drawer/index.js +1 -0
- package/dist/fab/fab.svelte +30 -10
- package/dist/fab/fab.svelte.d.ts +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/input/field.d.ts +8 -0
- package/dist/input/field.js +7 -0
- package/dist/input/index.d.ts +2 -1
- package/dist/input/index.js +2 -1
- package/dist/input/input.svelte +21 -66
- package/dist/input/input.svelte.d.ts +6 -16
- package/dist/link/link.svelte +33 -42
- package/dist/link/link.svelte.d.ts +4 -3
- package/dist/markdown/index.d.ts +2 -25
- package/dist/markdown/index.js +0 -24
- package/dist/markdown/markdown-tokens.svelte +166 -6
- package/dist/markdown/markdown-tokens.svelte.d.ts +2 -0
- package/dist/markdown/markdown.svelte +62 -173
- package/dist/markdown/markdown.svelte.d.ts +7 -27
- package/dist/markdown/parse.d.ts +5 -0
- package/dist/markdown/parse.js +30 -0
- package/dist/markdown/types.d.ts +28 -0
- package/dist/markdown/types.js +1 -0
- package/dist/menu/index.d.ts +3 -6
- package/dist/menu/index.js +3 -6
- package/dist/menu/menu-actions.svelte +44 -38
- package/dist/menu/menu-context.d.ts +4 -0
- package/dist/menu/menu-context.js +2 -0
- package/dist/menu/menu-group.svelte +40 -0
- package/dist/menu/menu-group.svelte.d.ts +11 -0
- package/dist/menu/menu-item.svelte +31 -54
- package/dist/menu/menu-item.svelte.d.ts +7 -5
- package/dist/menu/menu.svelte +160 -15
- package/dist/menu/menu.svelte.d.ts +15 -4
- package/dist/merge-props.d.ts +1 -1
- package/dist/merge-props.js +10 -5
- package/dist/modal/modal.svelte +67 -84
- package/dist/modal/modal.svelte.d.ts +7 -4
- package/dist/nav/index.d.ts +2 -0
- package/dist/nav/index.js +2 -0
- package/dist/nav/nav-group.svelte +40 -0
- package/dist/nav/nav-group.svelte.d.ts +10 -0
- package/dist/nav/nav-item.svelte +65 -0
- package/dist/nav/nav-item.svelte.d.ts +14 -0
- package/dist/popover/index.d.ts +1 -1
- package/dist/popover/index.js +1 -1
- package/dist/popover/popover.svelte +58 -111
- package/dist/popover/popover.svelte.d.ts +6 -8
- package/dist/progress/circular-progress.svelte +64 -30
- package/dist/progress/circular-progress.svelte.d.ts +7 -8
- package/dist/shortcut/index.d.ts +2 -2
- package/dist/shortcut/index.js +1 -1
- package/dist/shortcut/shortcut-hint.svelte +36 -0
- package/dist/shortcut/shortcut-hint.svelte.d.ts +9 -0
- package/dist/shortcut/shortcut.d.ts +19 -14
- package/dist/shortcut/shortcut.js +105 -52
- package/dist/skeleton/skeleton.svelte +13 -8
- package/dist/skeleton/skeleton.svelte.d.ts +2 -5
- package/dist/slider/index.d.ts +1 -8
- package/dist/slider/index.js +1 -8
- package/dist/slider/slider.svelte +180 -211
- package/dist/slider/slider.svelte.d.ts +11 -32
- package/dist/switch/index.d.ts +1 -2
- package/dist/switch/index.js +1 -2
- package/dist/switch/switch.svelte +36 -60
- package/dist/switch/switch.svelte.d.ts +6 -17
- package/dist/textarea/index.d.ts +1 -1
- package/dist/textarea/index.js +1 -1
- package/dist/textarea/textarea.svelte +23 -63
- package/dist/textarea/textarea.svelte.d.ts +8 -18
- package/dist/theme.css +191 -0
- package/dist/toggle/index.d.ts +0 -1
- package/dist/toggle/index.js +0 -1
- package/dist/toggle/toggle-button.svelte +72 -38
- package/dist/toggle/toggle-button.svelte.d.ts +4 -4
- package/dist/toggle/toggle-context.d.ts +10 -0
- package/dist/toggle/toggle-context.js +2 -0
- package/dist/toggle/toggle-group.svelte +41 -22
- package/dist/toggle/toggle-group.svelte.d.ts +7 -4
- package/dist/tooltip/tooltip.svelte +67 -26
- package/dist/tooltip/tooltip.svelte.d.ts +10 -4
- package/dist/utils.d.ts +9 -3
- package/dist/utils.js +10 -0
- package/package.json +6 -5
- package/dist/autocomplete/autocomplete-content.svelte +0 -47
- package/dist/autocomplete/autocomplete-content.svelte.d.ts +0 -10
- package/dist/autocomplete/autocomplete-context.svelte.d.ts +0 -12
- package/dist/autocomplete/autocomplete-context.svelte.js +0 -34
- package/dist/autocomplete/autocomplete-input.svelte +0 -36
- package/dist/autocomplete/autocomplete-input.svelte.d.ts +0 -5
- package/dist/autocomplete/autocomplete-item.svelte +0 -68
- package/dist/autocomplete/autocomplete-item.svelte.d.ts +0 -11
- package/dist/base.css +0 -71
- package/dist/bindable.svelte.d.ts +0 -7
- package/dist/bindable.svelte.js +0 -25
- package/dist/command/command-content.svelte +0 -15
- package/dist/command/command-content.svelte.d.ts +0 -8
- package/dist/command/command-context.svelte.d.ts +0 -5
- package/dist/command/command-context.svelte.js +0 -13
- package/dist/command/command-input.svelte +0 -44
- package/dist/command/command-input.svelte.d.ts +0 -7
- package/dist/command/command-item.svelte +0 -66
- package/dist/command/command-item.svelte.d.ts +0 -11
- package/dist/command/command-search.svelte +0 -28
- package/dist/command/command-search.svelte.d.ts +0 -5
- package/dist/command/command.svelte +0 -19
- package/dist/command/command.svelte.d.ts +0 -8
- package/dist/command/commander.svelte +0 -107
- package/dist/command/commander.svelte.d.ts +0 -9
- package/dist/common/header.svelte +0 -35
- package/dist/common/header.svelte.d.ts +0 -10
- package/dist/common/item-context.svelte.d.ts +0 -12
- package/dist/common/item-context.svelte.js +0 -77
- package/dist/dialog/dialog-button.svelte +0 -25
- package/dist/dialog/dialog-button.svelte.d.ts +0 -32
- package/dist/dialog/dialoguer-context.svelte.d.ts +0 -53
- package/dist/dialog/dialoguer-context.svelte.js +0 -85
- package/dist/dialog/dialoguer.svelte +0 -65
- package/dist/dialog/dialoguer.svelte.d.ts +0 -7
- package/dist/markdown/markdown-blockquote.svelte +0 -14
- package/dist/markdown/markdown-blockquote.svelte.d.ts +0 -7
- package/dist/markdown/markdown-br.svelte +0 -12
- package/dist/markdown/markdown-br.svelte.d.ts +0 -7
- package/dist/markdown/markdown-code.svelte +0 -14
- package/dist/markdown/markdown-code.svelte.d.ts +0 -7
- package/dist/markdown/markdown-codespan.svelte +0 -15
- package/dist/markdown/markdown-codespan.svelte.d.ts +0 -7
- package/dist/markdown/markdown-context.svelte.d.ts +0 -26
- package/dist/markdown/markdown-context.svelte.js +0 -31
- package/dist/markdown/markdown-def.svelte +0 -15
- package/dist/markdown/markdown-def.svelte.d.ts +0 -7
- package/dist/markdown/markdown-del.svelte +0 -14
- package/dist/markdown/markdown-del.svelte.d.ts +0 -7
- package/dist/markdown/markdown-em.svelte +0 -14
- package/dist/markdown/markdown-em.svelte.d.ts +0 -7
- package/dist/markdown/markdown-escape.svelte +0 -8
- package/dist/markdown/markdown-escape.svelte.d.ts +0 -5
- package/dist/markdown/markdown-heading.svelte +0 -16
- package/dist/markdown/markdown-heading.svelte.d.ts +0 -7
- package/dist/markdown/markdown-hr.svelte +0 -12
- package/dist/markdown/markdown-hr.svelte.d.ts +0 -7
- package/dist/markdown/markdown-html.svelte +0 -9
- package/dist/markdown/markdown-html.svelte.d.ts +0 -5
- package/dist/markdown/markdown-image.svelte +0 -12
- package/dist/markdown/markdown-image.svelte.d.ts +0 -7
- package/dist/markdown/markdown-link.svelte +0 -17
- package/dist/markdown/markdown-link.svelte.d.ts +0 -7
- package/dist/markdown/markdown-list-item.svelte +0 -14
- package/dist/markdown/markdown-list-item.svelte.d.ts +0 -7
- package/dist/markdown/markdown-list.svelte +0 -19
- package/dist/markdown/markdown-list.svelte.d.ts +0 -7
- package/dist/markdown/markdown-paragraph.svelte +0 -16
- package/dist/markdown/markdown-paragraph.svelte.d.ts +0 -7
- package/dist/markdown/markdown-space.svelte +0 -8
- package/dist/markdown/markdown-space.svelte.d.ts +0 -5
- package/dist/markdown/markdown-strong.svelte +0 -15
- package/dist/markdown/markdown-strong.svelte.d.ts +0 -7
- package/dist/markdown/markdown-table-cell.svelte +0 -16
- package/dist/markdown/markdown-table-cell.svelte.d.ts +0 -7
- package/dist/markdown/markdown-table.svelte +0 -36
- package/dist/markdown/markdown-table.svelte.d.ts +0 -7
- package/dist/markdown/markdown-text.svelte +0 -8
- package/dist/markdown/markdown-text.svelte.d.ts +0 -5
- package/dist/markdown/markdown-token.svelte +0 -25
- package/dist/markdown/markdown-token.svelte.d.ts +0 -7
- package/dist/menu/menu-content.svelte +0 -47
- package/dist/menu/menu-content.svelte.d.ts +0 -10
- package/dist/menu/menu-context.svelte.d.ts +0 -18
- package/dist/menu/menu-context.svelte.js +0 -118
- package/dist/menu/menu-trigger-button.svelte +0 -31
- package/dist/menu/menu-trigger-button.svelte.d.ts +0 -5
- package/dist/menu/menu-trigger.svelte +0 -42
- package/dist/menu/menu-trigger.svelte.d.ts +0 -10
- package/dist/ordered-html-elements.d.ts +0 -7
- package/dist/ordered-html-elements.js +0 -29
- package/dist/portal/index.d.ts +0 -2
- package/dist/portal/index.js +0 -2
- package/dist/portal/portal.svelte +0 -15
- package/dist/portal/portal.svelte.d.ts +0 -8
- package/dist/portal/proxy.svelte +0 -13
- package/dist/portal/proxy.svelte.d.ts +0 -7
- package/dist/shortcut/shortcut-badge.svelte +0 -41
- package/dist/shortcut/shortcut-badge.svelte.d.ts +0 -11
- package/dist/slider/slider-context.svelte.d.ts +0 -50
- package/dist/slider/slider-context.svelte.js +0 -216
- package/dist/slider/slider-handle-label-arrow.svelte +0 -18
- package/dist/slider/slider-handle-label-arrow.svelte.d.ts +0 -6
- package/dist/slider/slider-handle-label.svelte +0 -35
- package/dist/slider/slider-handle-label.svelte.d.ts +0 -6
- package/dist/slider/slider-handle.svelte +0 -54
- package/dist/slider/slider-handle.svelte.d.ts +0 -6
- package/dist/slider/slider-mark-dot.svelte +0 -25
- package/dist/slider/slider-mark-dot.svelte.d.ts +0 -6
- package/dist/slider/slider-mark-label.svelte +0 -37
- package/dist/slider/slider-mark-label.svelte.d.ts +0 -9
- package/dist/slider/slider-mark.svelte +0 -33
- package/dist/slider/slider-mark.svelte.d.ts +0 -9
- package/dist/switch/switch-thumb.svelte +0 -52
- package/dist/switch/switch-thumb.svelte.d.ts +0 -7
- package/dist/toggle/toggle-context.svelte.d.ts +0 -9
- package/dist/toggle/toggle-context.svelte.js +0 -32
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Variants } from "../base.js";
|
|
2
|
-
import type { ClassName, ElementRef } from "../utils.js";
|
|
3
|
-
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
-
export type CommandInputProps = {} & ElementRef & ClassName & Variants & HTMLInputAttributes;
|
|
5
|
-
declare const CommandInput: import("svelte").Component<CommandInputProps, {}, "value">;
|
|
6
|
-
type CommandInput = ReturnType<typeof CommandInput>;
|
|
7
|
-
export default CommandInput;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { baseClasses, type Variants } from "../base.js";
|
|
3
|
-
import { getCommandContext } from "./index.js";
|
|
4
|
-
import { mergeProps } from "../merge-props.js";
|
|
5
|
-
import type { ClassName, ElementRef } from "../utils.js";
|
|
6
|
-
import type { Snippet } from "svelte";
|
|
7
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
8
|
-
import { twMerge } from "tailwind-merge";
|
|
9
|
-
|
|
10
|
-
export type CommandItemProps = {
|
|
11
|
-
onSelect?: (el: HTMLElement) => void;
|
|
12
|
-
children: Snippet<[]>;
|
|
13
|
-
} & ElementRef &
|
|
14
|
-
ClassName &
|
|
15
|
-
Variants &
|
|
16
|
-
HTMLAttributes<HTMLDivElement>;
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<script lang="ts">
|
|
20
|
-
let {
|
|
21
|
-
onSelect,
|
|
22
|
-
children,
|
|
23
|
-
el = $bindable(),
|
|
24
|
-
class: className,
|
|
25
|
-
variant = "plain",
|
|
26
|
-
color = "secondary",
|
|
27
|
-
shape = "rounded",
|
|
28
|
-
...restProps
|
|
29
|
-
}: CommandItemProps = $props();
|
|
30
|
-
|
|
31
|
-
const ctx = getCommandContext();
|
|
32
|
-
|
|
33
|
-
function handleClick() {
|
|
34
|
-
if (el) {
|
|
35
|
-
onSelect?.(el);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function handleMouseEnter() {
|
|
40
|
-
ctx.focused = el;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
$effect(() => {
|
|
44
|
-
if (el) {
|
|
45
|
-
return ctx.add(el);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<div
|
|
51
|
-
bind:this={el}
|
|
52
|
-
role="option"
|
|
53
|
-
tabindex="-1"
|
|
54
|
-
aria-selected={ctx.focused === el}
|
|
55
|
-
class={twMerge(
|
|
56
|
-
baseClasses({ variant, color, shape }),
|
|
57
|
-
"flex w-full cursor-pointer items-center gap-1 px-2 py-1 text-left text-sm focus:ring-0 disabled:bg-transparent aria-selected:bg-m3-secondary/15",
|
|
58
|
-
className,
|
|
59
|
-
)}
|
|
60
|
-
{...mergeProps(restProps, {
|
|
61
|
-
onclick: handleClick,
|
|
62
|
-
onmouseenter: handleMouseEnter,
|
|
63
|
-
})}
|
|
64
|
-
>
|
|
65
|
-
{@render children()}
|
|
66
|
-
</div>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Variants } from "../base.js";
|
|
2
|
-
import type { ClassName, ElementRef } from "../utils.js";
|
|
3
|
-
import type { Snippet } from "svelte";
|
|
4
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
5
|
-
export type CommandItemProps = {
|
|
6
|
-
onSelect?: (el: HTMLElement) => void;
|
|
7
|
-
children: Snippet<[]>;
|
|
8
|
-
} & ElementRef & ClassName & Variants & HTMLAttributes<HTMLDivElement>;
|
|
9
|
-
declare const CommandItem: import("svelte").Component<CommandItemProps, {}, "el">;
|
|
10
|
-
type CommandItem = ReturnType<typeof CommandItem>;
|
|
11
|
-
export default CommandItem;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { CommandInput, type CommandInputProps } from "./index.js";
|
|
3
|
-
import { SearchIcon } from "@lucide/svelte";
|
|
4
|
-
|
|
5
|
-
export type CommandSearchProps = {} & CommandInputProps;
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<script lang="ts">
|
|
9
|
-
import { twMerge } from "tailwind-merge";
|
|
10
|
-
|
|
11
|
-
let {
|
|
12
|
-
value = $bindable(""),
|
|
13
|
-
placeholder = "Search...",
|
|
14
|
-
class: className,
|
|
15
|
-
...restProps
|
|
16
|
-
}: CommandSearchProps = $props();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<div class={twMerge("flex items-center gap-2 px-2", className)}>
|
|
20
|
-
<SearchIcon size={16} />
|
|
21
|
-
<CommandInput
|
|
22
|
-
autofocus
|
|
23
|
-
bind:value
|
|
24
|
-
{placeholder}
|
|
25
|
-
class="h-10"
|
|
26
|
-
{...restProps}
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type CommandInputProps } from "./index.js";
|
|
2
|
-
export type CommandSearchProps = {} & CommandInputProps;
|
|
3
|
-
declare const CommandSearch: import("svelte").Component<CommandSearchProps, {}, "value">;
|
|
4
|
-
type CommandSearch = ReturnType<typeof CommandSearch>;
|
|
5
|
-
export default CommandSearch;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { CommandContext, setCommandContext } from "./index.js";
|
|
3
|
-
import type { ClassName } from "../utils.js";
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
import { twMerge } from "tailwind-merge";
|
|
6
|
-
|
|
7
|
-
export type CommandProps = {
|
|
8
|
-
children: Snippet<[]>;
|
|
9
|
-
} & ClassName;
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<script lang="ts">
|
|
13
|
-
let { children, class: className }: CommandProps = $props();
|
|
14
|
-
setCommandContext(new CommandContext());
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<div class={twMerge("flex h-full flex-col p-1", className)}>
|
|
18
|
-
{@render children()}
|
|
19
|
-
</div>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ClassName } from "../utils.js";
|
|
2
|
-
import type { Snippet } from "svelte";
|
|
3
|
-
export type CommandProps = {
|
|
4
|
-
children: Snippet<[]>;
|
|
5
|
-
} & ClassName;
|
|
6
|
-
declare const Command: import("svelte").Component<CommandProps, {}, "">;
|
|
7
|
-
type Command = ReturnType<typeof Command>;
|
|
8
|
-
export default Command;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
Action,
|
|
4
|
-
Command,
|
|
5
|
-
CommandContent,
|
|
6
|
-
CommandDivider,
|
|
7
|
-
CommandItem,
|
|
8
|
-
CommandSearch,
|
|
9
|
-
Registry,
|
|
10
|
-
} from "./index.js";
|
|
11
|
-
import { events } from "../index.js";
|
|
12
|
-
import { Modal } from "../modal/index.js";
|
|
13
|
-
import { Shortcut, ShortcutBadge } from "../shortcut/index.js";
|
|
14
|
-
import { match } from "../utils.js";
|
|
15
|
-
import { Check, ChevronRight } from "@lucide/svelte";
|
|
16
|
-
|
|
17
|
-
export type CommanderProps = {
|
|
18
|
-
open?: boolean;
|
|
19
|
-
query?: string;
|
|
20
|
-
command: Registry;
|
|
21
|
-
};
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
let {
|
|
26
|
-
open = $bindable(false),
|
|
27
|
-
query = $bindable(""),
|
|
28
|
-
command,
|
|
29
|
-
}: CommanderProps = $props();
|
|
30
|
-
|
|
31
|
-
let actions = $derived(
|
|
32
|
-
command.actions.filter(
|
|
33
|
-
(action) =>
|
|
34
|
-
action.enabled() &&
|
|
35
|
-
(match(action.id, query) ||
|
|
36
|
-
(action.category && match(action.category, query)) ||
|
|
37
|
-
match(action.name, query) ||
|
|
38
|
-
match(action.description, query)),
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
let categoryHasSelected = $derived(
|
|
43
|
-
actions.reduce(
|
|
44
|
-
(acc, { category, selected }) => ({
|
|
45
|
-
...acc,
|
|
46
|
-
[category]: acc[category] || selected !== undefined,
|
|
47
|
-
}),
|
|
48
|
-
{} as Record<string, boolean>,
|
|
49
|
-
),
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
function handleSelect(action: Action) {
|
|
53
|
-
action.callback();
|
|
54
|
-
open = false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function handleKeyDown(event: KeyboardEvent) {
|
|
58
|
-
const action = command.getByShortcut(Shortcut.fromEvent(event));
|
|
59
|
-
if (action && action.enabled()) {
|
|
60
|
-
action.callback();
|
|
61
|
-
event.preventDefault();
|
|
62
|
-
event.stopImmediatePropagation();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
$effect(() => {
|
|
67
|
-
return events.on("keydown", handleKeyDown);
|
|
68
|
-
});
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<Modal
|
|
72
|
-
bind:open
|
|
73
|
-
onoutroend={() => (query = "")}
|
|
74
|
-
class="h-[min(60%,48em)] w-[min(calc(100%-1em),36em)] rounded-lg bg-m3-surface-container p-0"
|
|
75
|
-
>
|
|
76
|
-
<Command>
|
|
77
|
-
<CommandSearch bind:value={query} />
|
|
78
|
-
<CommandDivider />
|
|
79
|
-
<CommandContent>
|
|
80
|
-
{#if actions.length > 0}
|
|
81
|
-
{#each actions as action (action.id)}
|
|
82
|
-
<CommandItem
|
|
83
|
-
onSelect={() => handleSelect(action)}
|
|
84
|
-
title={action.description}
|
|
85
|
-
>
|
|
86
|
-
<action.icon size={14} class="mr-2" />
|
|
87
|
-
<div>{action.category}</div>
|
|
88
|
-
<ChevronRight size={14} />
|
|
89
|
-
{#if categoryHasSelected[action.category]}
|
|
90
|
-
{#if action.selected?.()}
|
|
91
|
-
<Check size={16} class="text-m3-primary" />
|
|
92
|
-
{:else}
|
|
93
|
-
<div class="size-4"></div>
|
|
94
|
-
{/if}
|
|
95
|
-
{/if}
|
|
96
|
-
<div>{action.name}</div>
|
|
97
|
-
{#if action.shortcut}
|
|
98
|
-
<ShortcutBadge class="ml-auto" shortcut={action.shortcut} />
|
|
99
|
-
{/if}
|
|
100
|
-
</CommandItem>
|
|
101
|
-
{/each}
|
|
102
|
-
{:else}
|
|
103
|
-
<div class="text-center">No results found.</div>
|
|
104
|
-
{/if}
|
|
105
|
-
</CommandContent>
|
|
106
|
-
</Command>
|
|
107
|
-
</Modal>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Registry } from "./index.js";
|
|
2
|
-
export type CommanderProps = {
|
|
3
|
-
open?: boolean;
|
|
4
|
-
query?: string;
|
|
5
|
-
command: Registry;
|
|
6
|
-
};
|
|
7
|
-
declare const Commander: import("svelte").Component<CommanderProps, {}, "open" | "query">;
|
|
8
|
-
type Commander = ReturnType<typeof Commander>;
|
|
9
|
-
export default Commander;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { baseClasses, type Variants } from "../base.js";
|
|
3
|
-
import type { ClassName } from "../utils.js";
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
6
|
-
import { twMerge } from "tailwind-merge";
|
|
7
|
-
|
|
8
|
-
export type HeaderProps = {
|
|
9
|
-
children: Snippet;
|
|
10
|
-
} & ClassName &
|
|
11
|
-
Variants &
|
|
12
|
-
HTMLAttributes<HTMLDivElement>;
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
let {
|
|
17
|
-
children,
|
|
18
|
-
class: className,
|
|
19
|
-
variant = "plain",
|
|
20
|
-
color = "primary",
|
|
21
|
-
shape = "rounded",
|
|
22
|
-
...restProps
|
|
23
|
-
}: HeaderProps = $props();
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<div
|
|
27
|
-
class={twMerge(
|
|
28
|
-
baseClasses({ variant, color, shape }),
|
|
29
|
-
"px-2 py-1 text-xs uppercase",
|
|
30
|
-
className,
|
|
31
|
-
)}
|
|
32
|
-
{...restProps}
|
|
33
|
-
>
|
|
34
|
-
{@render children()}
|
|
35
|
-
</div>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Variants } from "../base.js";
|
|
2
|
-
import type { ClassName } from "../utils.js";
|
|
3
|
-
import type { Snippet } from "svelte";
|
|
4
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
5
|
-
export type HeaderProps = {
|
|
6
|
-
children: Snippet;
|
|
7
|
-
} & ClassName & Variants & HTMLAttributes<HTMLDivElement>;
|
|
8
|
-
declare const Header: import("svelte").Component<HeaderProps, {}, "">;
|
|
9
|
-
type Header = ReturnType<typeof Header>;
|
|
10
|
-
export default Header;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class ItemContext {
|
|
2
|
-
#private;
|
|
3
|
-
get input(): string;
|
|
4
|
-
set input(value: string);
|
|
5
|
-
bindInput(getInput: () => string, setInput: (val: string) => void): void;
|
|
6
|
-
get items(): HTMLElement[];
|
|
7
|
-
add(item: HTMLElement): () => void;
|
|
8
|
-
delete(item: HTMLElement): void;
|
|
9
|
-
get focused(): HTMLElement | undefined;
|
|
10
|
-
set focused(value: HTMLElement | undefined);
|
|
11
|
-
handleKeyDown(event: KeyboardEvent): void;
|
|
12
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Bindable } from "../bindable.svelte.js";
|
|
2
|
-
import { OrderedHTMLElements } from "../ordered-html-elements.js";
|
|
3
|
-
import { Shortcut } from "../shortcut/index.js";
|
|
4
|
-
export class ItemContext {
|
|
5
|
-
#input = new Bindable("");
|
|
6
|
-
#items = new OrderedHTMLElements();
|
|
7
|
-
#focused = $state();
|
|
8
|
-
get input() {
|
|
9
|
-
return this.#input.value;
|
|
10
|
-
}
|
|
11
|
-
set input(value) {
|
|
12
|
-
this.#input.value = value;
|
|
13
|
-
}
|
|
14
|
-
bindInput(getInput, setInput) {
|
|
15
|
-
this.#input.bind(getInput, setInput);
|
|
16
|
-
}
|
|
17
|
-
get items() {
|
|
18
|
-
return this.#items.items;
|
|
19
|
-
}
|
|
20
|
-
add(item) {
|
|
21
|
-
this.#items.add(item);
|
|
22
|
-
this.focused = this.#input.value === "" ? undefined : this.items[0];
|
|
23
|
-
return () => this.delete(item);
|
|
24
|
-
}
|
|
25
|
-
delete(item) {
|
|
26
|
-
this.#items.delete(item);
|
|
27
|
-
this.focused = this.#input.value === "" ? undefined : this.items[0];
|
|
28
|
-
}
|
|
29
|
-
get focused() {
|
|
30
|
-
return this.#focused;
|
|
31
|
-
}
|
|
32
|
-
set focused(value) {
|
|
33
|
-
this.#focused = value;
|
|
34
|
-
}
|
|
35
|
-
handleKeyDown(event) {
|
|
36
|
-
if (!this.items)
|
|
37
|
-
return;
|
|
38
|
-
if (Shortcut.ARROW_UP.matches(event)) {
|
|
39
|
-
if (this.items.length !== 0) {
|
|
40
|
-
if (!this.focused) {
|
|
41
|
-
this.focused = this.items[this.items.length - 1];
|
|
42
|
-
this.focused.scrollIntoView(false);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
const index = this.items.indexOf(this.focused);
|
|
46
|
-
this.focused =
|
|
47
|
-
this.items[(index - 1 + this.items.length) % this.items.length];
|
|
48
|
-
this.focused.scrollIntoView(false);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
event.stopImmediatePropagation();
|
|
53
|
-
}
|
|
54
|
-
else if (Shortcut.ARROW_DOWN.matches(event)) {
|
|
55
|
-
if (this.items.length !== 0) {
|
|
56
|
-
if (!this.focused) {
|
|
57
|
-
this.focused = this.items[0];
|
|
58
|
-
this.focused.scrollIntoView(false);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
const index = this.items.indexOf(this.focused);
|
|
62
|
-
this.focused = this.items[(index + 1) % this.items.length];
|
|
63
|
-
this.focused.scrollIntoView(false);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
event.preventDefault();
|
|
67
|
-
event.stopImmediatePropagation();
|
|
68
|
-
}
|
|
69
|
-
else if (Shortcut.ENTER.matches(event)) {
|
|
70
|
-
if (this.focused) {
|
|
71
|
-
this.focused.click();
|
|
72
|
-
event.preventDefault();
|
|
73
|
-
event.stopImmediatePropagation();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { Button, type ButtonProps } from "../button/index.js";
|
|
3
|
-
import type { Snippet } from "svelte";
|
|
4
|
-
|
|
5
|
-
export type DialogButtonProps<T> = {
|
|
6
|
-
value: T | undefined;
|
|
7
|
-
autofocus?: boolean;
|
|
8
|
-
onSelect: (value: T | undefined) => void;
|
|
9
|
-
children: Snippet;
|
|
10
|
-
} & Omit<ButtonProps, "value">;
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<script lang="ts" generics="T">
|
|
14
|
-
let {
|
|
15
|
-
value,
|
|
16
|
-
onSelect,
|
|
17
|
-
autofocus = false,
|
|
18
|
-
children,
|
|
19
|
-
...restProps
|
|
20
|
-
}: DialogButtonProps<T> = $props();
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Button onclick={() => onSelect(value)} {autofocus} {...restProps}>
|
|
24
|
-
{@render children()}
|
|
25
|
-
</Button>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type ButtonProps } from "../button/index.js";
|
|
2
|
-
import type { Snippet } from "svelte";
|
|
3
|
-
export type DialogButtonProps<T> = {
|
|
4
|
-
value: T | undefined;
|
|
5
|
-
autofocus?: boolean;
|
|
6
|
-
onSelect: (value: T | undefined) => void;
|
|
7
|
-
children: Snippet;
|
|
8
|
-
} & Omit<ButtonProps, "value">;
|
|
9
|
-
declare function $$render<T>(): {
|
|
10
|
-
props: DialogButtonProps<T>;
|
|
11
|
-
exports: {};
|
|
12
|
-
bindings: "";
|
|
13
|
-
slots: {};
|
|
14
|
-
events: {};
|
|
15
|
-
};
|
|
16
|
-
declare class __sveltets_Render<T> {
|
|
17
|
-
props(): ReturnType<typeof $$render<T>>['props'];
|
|
18
|
-
events(): ReturnType<typeof $$render<T>>['events'];
|
|
19
|
-
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
20
|
-
bindings(): "";
|
|
21
|
-
exports(): {};
|
|
22
|
-
}
|
|
23
|
-
interface $$IsomorphicComponent {
|
|
24
|
-
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
25
|
-
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
26
|
-
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
27
|
-
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
28
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
29
|
-
}
|
|
30
|
-
declare const DialogButton: $$IsomorphicComponent;
|
|
31
|
-
type DialogButton<T> = InstanceType<typeof DialogButton<T>>;
|
|
32
|
-
export default DialogButton;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Variants } from "../base.js";
|
|
2
|
-
import type { InputProps } from "../input/index.js";
|
|
3
|
-
import type { LucideIcon } from "@lucide/svelte";
|
|
4
|
-
import { type Snippet } from "svelte";
|
|
5
|
-
export type DialoguerButtonProps<T> = {
|
|
6
|
-
text: string;
|
|
7
|
-
value: T;
|
|
8
|
-
default?: boolean;
|
|
9
|
-
} & Variants;
|
|
10
|
-
type ShowDialogProps<T> = {
|
|
11
|
-
icon?: LucideIcon;
|
|
12
|
-
title?: string;
|
|
13
|
-
inputProps?: InputProps;
|
|
14
|
-
message: Snippet<[]> | string;
|
|
15
|
-
buttons: DialoguerButtonProps<T>[];
|
|
16
|
-
};
|
|
17
|
-
type NoticeDialogProps = {
|
|
18
|
-
icon?: LucideIcon;
|
|
19
|
-
title?: string;
|
|
20
|
-
message: Snippet<[]> | string;
|
|
21
|
-
acceptText?: string;
|
|
22
|
-
};
|
|
23
|
-
type ConfirmDialogProps = {
|
|
24
|
-
icon?: LucideIcon;
|
|
25
|
-
title?: string;
|
|
26
|
-
message: Snippet<[]> | string;
|
|
27
|
-
cancelText?: string;
|
|
28
|
-
acceptText?: string;
|
|
29
|
-
};
|
|
30
|
-
type InputDialogProps = {
|
|
31
|
-
icon?: LucideIcon;
|
|
32
|
-
title?: string;
|
|
33
|
-
props: InputProps;
|
|
34
|
-
message: Snippet<[]> | string;
|
|
35
|
-
cancelText?: string;
|
|
36
|
-
acceptText?: string;
|
|
37
|
-
};
|
|
38
|
-
export declare class DialoguerContext {
|
|
39
|
-
message: Snippet<[]> | string;
|
|
40
|
-
icon: LucideIcon | undefined;
|
|
41
|
-
title: string | undefined;
|
|
42
|
-
inputProps: InputProps | undefined;
|
|
43
|
-
buttons: DialoguerButtonProps<unknown>[];
|
|
44
|
-
resolve: (value: unknown) => void;
|
|
45
|
-
open: boolean;
|
|
46
|
-
show<T>(dialog: ShowDialogProps<T>): Promise<T>;
|
|
47
|
-
notice(dialog: NoticeDialogProps): Promise<void>;
|
|
48
|
-
confirm(dialog: ConfirmDialogProps): Promise<boolean>;
|
|
49
|
-
input(dialog: InputDialogProps): Promise<string | undefined>;
|
|
50
|
-
}
|
|
51
|
-
export declare function setDialoguerContext(state: DialoguerContext): DialoguerContext;
|
|
52
|
-
export declare function getDialoguerContext(): DialoguerContext;
|
|
53
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { getContext, setContext } from "svelte";
|
|
2
|
-
export class DialoguerContext {
|
|
3
|
-
message = $state("");
|
|
4
|
-
icon = $state();
|
|
5
|
-
title = $state();
|
|
6
|
-
inputProps = $state();
|
|
7
|
-
buttons = $state.raw([]);
|
|
8
|
-
resolve = $state(() => { });
|
|
9
|
-
open = $state(false);
|
|
10
|
-
show(dialog) {
|
|
11
|
-
({
|
|
12
|
-
icon: this.icon,
|
|
13
|
-
title: this.title,
|
|
14
|
-
inputProps: this.inputProps,
|
|
15
|
-
message: this.message,
|
|
16
|
-
buttons: this.buttons,
|
|
17
|
-
} = dialog);
|
|
18
|
-
this.open = true;
|
|
19
|
-
return new Promise((newResolve) => (this.resolve = newResolve));
|
|
20
|
-
}
|
|
21
|
-
async notice(dialog) {
|
|
22
|
-
await this.show({
|
|
23
|
-
icon: dialog.icon,
|
|
24
|
-
title: dialog.title,
|
|
25
|
-
inputProps: undefined,
|
|
26
|
-
message: dialog.message,
|
|
27
|
-
buttons: [
|
|
28
|
-
{
|
|
29
|
-
text: dialog.acceptText ?? "OK",
|
|
30
|
-
value: null,
|
|
31
|
-
default: true,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async confirm(dialog) {
|
|
37
|
-
return await this.show({
|
|
38
|
-
icon: dialog.icon,
|
|
39
|
-
title: dialog.title,
|
|
40
|
-
inputProps: undefined,
|
|
41
|
-
message: dialog.message,
|
|
42
|
-
buttons: [
|
|
43
|
-
{
|
|
44
|
-
text: dialog.cancelText ?? "Cancel",
|
|
45
|
-
value: false,
|
|
46
|
-
default: false,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
text: dialog.acceptText ?? "Accept",
|
|
50
|
-
value: true,
|
|
51
|
-
variant: "filled",
|
|
52
|
-
default: true,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async input(dialog) {
|
|
58
|
-
return await this.show({
|
|
59
|
-
icon: dialog.icon,
|
|
60
|
-
title: dialog.title,
|
|
61
|
-
inputProps: dialog.props,
|
|
62
|
-
message: dialog.message,
|
|
63
|
-
buttons: [
|
|
64
|
-
{
|
|
65
|
-
text: dialog.cancelText ?? "Cancel",
|
|
66
|
-
value: "cancel",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
text: dialog.acceptText ?? "Accept",
|
|
70
|
-
value: "accept",
|
|
71
|
-
variant: "filled",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
export function setDialoguerContext(state) {
|
|
78
|
-
return setContext(DialoguerContext, state);
|
|
79
|
-
}
|
|
80
|
-
export function getDialoguerContext() {
|
|
81
|
-
const ctx = getContext(DialoguerContext);
|
|
82
|
-
if (!ctx)
|
|
83
|
-
throw new Error("DialoguerContext is undefined");
|
|
84
|
-
return ctx;
|
|
85
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
DialoguerContext,
|
|
4
|
-
setDialoguerContext,
|
|
5
|
-
type DialoguerButtonProps,
|
|
6
|
-
} from "./index.js";
|
|
7
|
-
import { Input } from "../input/index.js";
|
|
8
|
-
import type { Snippet } from "svelte";
|
|
9
|
-
import DialogButton from "./dialog-button.svelte";
|
|
10
|
-
import Dialog from "./dialog.svelte";
|
|
11
|
-
|
|
12
|
-
const dialog = setDialoguerContext(new DialoguerContext());
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
children: Snippet;
|
|
16
|
-
};
|
|
17
|
-
let { children }: Props = $props();
|
|
18
|
-
|
|
19
|
-
let value: string = $derived(dialog.inputProps?.value ?? "");
|
|
20
|
-
|
|
21
|
-
function getValue(button: DialoguerButtonProps<unknown>) {
|
|
22
|
-
if (dialog.inputProps === undefined) {
|
|
23
|
-
return button.value;
|
|
24
|
-
}
|
|
25
|
-
if (button.value === "cancel") {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
if (button.value === "accept") {
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
throw new Error("Invalid state");
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<Dialog
|
|
36
|
-
bind:open={dialog.open}
|
|
37
|
-
icon={dialog.icon}
|
|
38
|
-
title={dialog.title}
|
|
39
|
-
onSelect={dialog.resolve}
|
|
40
|
-
>
|
|
41
|
-
{#if typeof dialog.message === "function"}
|
|
42
|
-
{@render dialog.message()}
|
|
43
|
-
{:else}
|
|
44
|
-
{dialog.message}
|
|
45
|
-
{/if}
|
|
46
|
-
|
|
47
|
-
{#if dialog.inputProps !== undefined}
|
|
48
|
-
<Input class="mt-2 w-full" bind:value autofocus {...dialog.inputProps} />
|
|
49
|
-
{/if}
|
|
50
|
-
|
|
51
|
-
{#snippet actions(props)}
|
|
52
|
-
{#each dialog.buttons as button (button)}
|
|
53
|
-
<DialogButton
|
|
54
|
-
variant={button.variant}
|
|
55
|
-
value={getValue(button)}
|
|
56
|
-
autofocus={button.default}
|
|
57
|
-
{...props}
|
|
58
|
-
>
|
|
59
|
-
{button.text}
|
|
60
|
-
</DialogButton>
|
|
61
|
-
{/each}
|
|
62
|
-
{/snippet}
|
|
63
|
-
</Dialog>
|
|
64
|
-
|
|
65
|
-
{@render children()}
|