kosui 0.2.0 → 0.4.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/fab/fab.svelte +30 -10
- package/dist/fab/fab.svelte.d.ts +3 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -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 +60 -83
- package/dist/modal/modal.svelte.d.ts +5 -4
- 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,14 +1,20 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import { mergeProps } from "../merge-props.js";
|
|
2
3
|
import { Popover, type PopoverProps } from "../popover/index.js";
|
|
3
|
-
import type
|
|
4
|
+
import { cn, type ClassName } from "../utils.js";
|
|
4
5
|
import type { Snippet } from "svelte";
|
|
5
|
-
import {
|
|
6
|
+
import { createAttachmentKey, type Attachment } from "svelte/attachments";
|
|
6
7
|
|
|
7
8
|
export type TooltipTriggerProps = {
|
|
8
|
-
|
|
9
|
+
[attachment: symbol]: Attachment<HTMLElement>;
|
|
10
|
+
"aria-describedby"?: string;
|
|
11
|
+
"aria-expanded"?: boolean;
|
|
12
|
+
"aria-controls"?: string;
|
|
9
13
|
onclick?: () => void;
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
onpointerenter?: (event: PointerEvent) => void;
|
|
15
|
+
onpointerleave?: (event: PointerEvent) => void;
|
|
16
|
+
onfocus?: (event: FocusEvent) => void;
|
|
17
|
+
onblur?: () => void;
|
|
12
18
|
ontouchstart?: () => void;
|
|
13
19
|
ontouchend?: () => void;
|
|
14
20
|
};
|
|
@@ -21,28 +27,36 @@
|
|
|
21
27
|
trigger?: Snippet<[TooltipTriggerProps]>;
|
|
22
28
|
} & ClassName &
|
|
23
29
|
PopoverProps;
|
|
30
|
+
|
|
31
|
+
const GRACE = 100;
|
|
24
32
|
</script>
|
|
25
33
|
|
|
26
34
|
<script lang="ts">
|
|
35
|
+
const generatedId = $props.id();
|
|
36
|
+
|
|
27
37
|
let {
|
|
38
|
+
id: providedId,
|
|
28
39
|
delay = 500,
|
|
29
40
|
open = $bindable(false),
|
|
30
41
|
click = false,
|
|
31
42
|
rich = false,
|
|
32
|
-
arrow,
|
|
33
43
|
trigger,
|
|
34
44
|
anchorEl,
|
|
35
45
|
class: className,
|
|
36
46
|
...restProps
|
|
37
47
|
}: TooltipProps = $props();
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
let id = $derived(providedId ?? generatedId);
|
|
50
|
+
|
|
51
|
+
const anchor = createAttachmentKey();
|
|
52
|
+
const attachAnchor: Attachment<HTMLElement> = (node) => {
|
|
53
|
+
anchorEl = node;
|
|
54
|
+
};
|
|
42
55
|
|
|
43
56
|
let timeout: number;
|
|
44
57
|
|
|
45
58
|
export function show(after?: number) {
|
|
59
|
+
cancel();
|
|
46
60
|
timeout = window.setTimeout(
|
|
47
61
|
() => (open = true),
|
|
48
62
|
after === undefined ? delay : after,
|
|
@@ -58,40 +72,67 @@
|
|
|
58
72
|
open = false;
|
|
59
73
|
}
|
|
60
74
|
|
|
75
|
+
function hideSoon() {
|
|
76
|
+
cancel();
|
|
77
|
+
timeout = window.setTimeout(() => (open = false), GRACE);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const notTouch =
|
|
81
|
+
(handler: () => void) =>
|
|
82
|
+
({ pointerType }: PointerEvent) => {
|
|
83
|
+
if (pointerType !== "touch") handler();
|
|
84
|
+
};
|
|
85
|
+
|
|
61
86
|
const triggerProps: TooltipTriggerProps = $derived(
|
|
62
87
|
click
|
|
63
88
|
? {
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
[anchor]: attachAnchor,
|
|
90
|
+
"aria-expanded": open,
|
|
91
|
+
"aria-controls": open ? id : undefined,
|
|
92
|
+
onclick: () => (open = !open),
|
|
66
93
|
}
|
|
67
94
|
: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
[anchor]: attachAnchor,
|
|
96
|
+
"aria-describedby": open ? id : undefined,
|
|
97
|
+
onpointerenter: notTouch(() => show()),
|
|
98
|
+
onpointerleave: notTouch(hideSoon),
|
|
99
|
+
onfocus: (event) => {
|
|
100
|
+
if (
|
|
101
|
+
event.target instanceof HTMLElement &&
|
|
102
|
+
event.target.matches(":focus-visible")
|
|
103
|
+
) {
|
|
104
|
+
cancel();
|
|
105
|
+
open = true;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onblur: () => hide(),
|
|
71
109
|
ontouchstart: () => show(delay),
|
|
72
110
|
ontouchend: () => cancel(),
|
|
73
111
|
},
|
|
74
112
|
);
|
|
113
|
+
|
|
114
|
+
const popupProps: Omit<PopoverProps, "children"> = $derived(
|
|
115
|
+
click
|
|
116
|
+
? {}
|
|
117
|
+
: {
|
|
118
|
+
role: "tooltip",
|
|
119
|
+
onpointerenter: notTouch(cancel),
|
|
120
|
+
onpointerleave: notTouch(hideSoon),
|
|
121
|
+
},
|
|
122
|
+
);
|
|
75
123
|
</script>
|
|
76
124
|
|
|
125
|
+
{@render trigger?.(triggerProps)}
|
|
126
|
+
|
|
77
127
|
<Popover
|
|
78
128
|
bind:open
|
|
79
|
-
|
|
129
|
+
{id}
|
|
80
130
|
{anchorEl}
|
|
81
|
-
{
|
|
82
|
-
class={twMerge(
|
|
83
|
-
arrow && "overflow-visible",
|
|
131
|
+
class={cn(
|
|
84
132
|
rich
|
|
85
133
|
? "rounded-md border bg-m3-surface-container p-2 text-sm shadow shadow-m3-shadow/20"
|
|
86
134
|
: "rounded-sm bg-m3-inverse-surface px-2 py-1 text-xs text-m3-inverse-on-surface",
|
|
87
135
|
className,
|
|
88
136
|
)}
|
|
89
|
-
|
|
90
|
-
rich
|
|
91
|
-
? "bg-m3-surface-container border-r border-b"
|
|
92
|
-
: "bg-m3-inverse-surface",
|
|
93
|
-
)}
|
|
94
|
-
{...restProps}
|
|
137
|
+
{...mergeProps(popupProps, restProps)}
|
|
95
138
|
/>
|
|
96
|
-
|
|
97
|
-
{@render trigger?.(triggerProps)}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { type PopoverProps } from "../popover/index.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ClassName } from "../utils.js";
|
|
3
3
|
import type { Snippet } from "svelte";
|
|
4
|
+
import { type Attachment } from "svelte/attachments";
|
|
4
5
|
export type TooltipTriggerProps = {
|
|
5
|
-
|
|
6
|
+
[attachment: symbol]: Attachment<HTMLElement>;
|
|
7
|
+
"aria-describedby"?: string;
|
|
8
|
+
"aria-expanded"?: boolean;
|
|
9
|
+
"aria-controls"?: string;
|
|
6
10
|
onclick?: () => void;
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
onpointerenter?: (event: PointerEvent) => void;
|
|
12
|
+
onpointerleave?: (event: PointerEvent) => void;
|
|
13
|
+
onfocus?: (event: FocusEvent) => void;
|
|
14
|
+
onblur?: () => void;
|
|
9
15
|
ontouchstart?: () => void;
|
|
10
16
|
ontouchend?: () => void;
|
|
11
17
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClassValue as ClassInput } from "clsx";
|
|
2
|
+
import type { ClassValue } from "svelte/elements";
|
|
2
3
|
export declare function noop(): void;
|
|
3
4
|
export type ElementRef = {
|
|
4
5
|
el?: HTMLElement;
|
|
5
|
-
ref?: (el: HTMLElement) => void;
|
|
6
6
|
};
|
|
7
7
|
export type ClassName = {
|
|
8
|
-
class?:
|
|
8
|
+
class?: ClassValue;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves class values the way Svelte's `class` attribute does (strings,
|
|
12
|
+
* arrays and objects), then merges conflicting Tailwind classes so later
|
|
13
|
+
* values win.
|
|
14
|
+
*/
|
|
15
|
+
export declare function cn(...values: ClassInput[]): string;
|
|
10
16
|
export type ToggleEventWithTarget<T extends HTMLElement> = ToggleEvent & {
|
|
11
17
|
currentTarget: EventTarget & T;
|
|
12
18
|
};
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
1
3
|
export function noop() { }
|
|
4
|
+
/**
|
|
5
|
+
* Resolves class values the way Svelte's `class` attribute does (strings,
|
|
6
|
+
* arrays and objects), then merges conflicting Tailwind classes so later
|
|
7
|
+
* values win.
|
|
8
|
+
*/
|
|
9
|
+
export function cn(...values) {
|
|
10
|
+
return twMerge(clsx(values));
|
|
11
|
+
}
|
|
2
12
|
export function uid({ prefix = "", separator = "-" } = {}) {
|
|
3
13
|
const parts = [];
|
|
4
14
|
if (prefix) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kosui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"svelte": "./dist/index.js"
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"./theme.css": "./dist/theme.css"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@floating-ui/dom": "^1.7.4",
|
|
31
31
|
"@lucide/svelte": "^1.1.0",
|
|
32
|
-
"
|
|
32
|
+
"clsx": "^2.1.1",
|
|
33
|
+
"marked": "^18.0.0",
|
|
34
|
+
"tailwind-merge": "^3.7.0"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
37
|
"svelte": "^5.0.0"
|
|
@@ -62,7 +64,6 @@
|
|
|
62
64
|
"publint": "0.3.25",
|
|
63
65
|
"svelte": "^5.57.3",
|
|
64
66
|
"svelte-check": "4.7.8",
|
|
65
|
-
"tailwind-merge": "3.7.0",
|
|
66
67
|
"tailwindcss": "4.3.3",
|
|
67
68
|
"typescript": "6.0.3",
|
|
68
69
|
"typescript-eslint": "8.72.1",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { getAutocompleteContext } from "./index.js";
|
|
3
|
-
import { baseClasses, type Variants } from "../base.js";
|
|
4
|
-
import { Popover, type PopoverProps } from "../popover/index.js";
|
|
5
|
-
import type { ClassName } from "../utils.js";
|
|
6
|
-
import type { Snippet } from "svelte";
|
|
7
|
-
import { twMerge } from "tailwind-merge";
|
|
8
|
-
|
|
9
|
-
export type AutocompleteProps = {
|
|
10
|
-
children: Snippet;
|
|
11
|
-
} & ClassName &
|
|
12
|
-
Variants &
|
|
13
|
-
Omit<PopoverProps, "children">;
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<script lang="ts">
|
|
17
|
-
let {
|
|
18
|
-
open = $bindable(false),
|
|
19
|
-
children,
|
|
20
|
-
class: className,
|
|
21
|
-
variant = "elevated",
|
|
22
|
-
color = "primary",
|
|
23
|
-
shape = "rounded",
|
|
24
|
-
...restProps
|
|
25
|
-
}: AutocompleteProps = $props();
|
|
26
|
-
|
|
27
|
-
const ctx = getAutocompleteContext();
|
|
28
|
-
ctx.bindOpen(
|
|
29
|
-
() => open,
|
|
30
|
-
(newval) => (open = newval),
|
|
31
|
-
);
|
|
32
|
-
</script>
|
|
33
|
-
|
|
34
|
-
<Popover
|
|
35
|
-
bind:open={ctx.open}
|
|
36
|
-
role="menu"
|
|
37
|
-
class={twMerge(
|
|
38
|
-
baseClasses({ variant, color, shape }),
|
|
39
|
-
"max-h-[40%] border bg-m3-surface-container-highest p-1 shadow",
|
|
40
|
-
className,
|
|
41
|
-
)}
|
|
42
|
-
anchorEl={ctx.anchorEl}
|
|
43
|
-
placement="bottom"
|
|
44
|
-
{...restProps}
|
|
45
|
-
>
|
|
46
|
-
{@render children()}
|
|
47
|
-
</Popover>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Variants } from "../base.js";
|
|
2
|
-
import { type PopoverProps } from "../popover/index.js";
|
|
3
|
-
import type { ClassName } from "../utils.js";
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
export type AutocompleteProps = {
|
|
6
|
-
children: Snippet;
|
|
7
|
-
} & ClassName & Variants & Omit<PopoverProps, "children">;
|
|
8
|
-
declare const AutocompleteContent: import("svelte").Component<AutocompleteProps, {}, "open">;
|
|
9
|
-
type AutocompleteContent = ReturnType<typeof AutocompleteContent>;
|
|
10
|
-
export default AutocompleteContent;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ItemContext } from "../common/index.js";
|
|
2
|
-
export declare class AutocompleteContext extends ItemContext {
|
|
3
|
-
#private;
|
|
4
|
-
get open(): boolean;
|
|
5
|
-
set open(value: boolean);
|
|
6
|
-
bindOpen(getOpen: () => boolean, setOpen: (val: boolean) => void): void;
|
|
7
|
-
get anchorEl(): HTMLElement | undefined;
|
|
8
|
-
set anchorEl(value: HTMLElement | undefined);
|
|
9
|
-
bindAnchorEl(getAnchorEl: () => HTMLElement | undefined, setAnchorEl: (val: HTMLElement | undefined) => void): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function setAutocompleteContext(state: AutocompleteContext): AutocompleteContext;
|
|
12
|
-
export declare function getAutocompleteContext(): AutocompleteContext;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Bindable } from "../bindable.svelte.js";
|
|
2
|
-
import { ItemContext } from "../common/index.js";
|
|
3
|
-
import { getContext, setContext } from "svelte";
|
|
4
|
-
export class AutocompleteContext extends ItemContext {
|
|
5
|
-
#open = new Bindable(false);
|
|
6
|
-
#anchorEl = new Bindable(undefined);
|
|
7
|
-
get open() {
|
|
8
|
-
return this.#open.value;
|
|
9
|
-
}
|
|
10
|
-
set open(value) {
|
|
11
|
-
this.#open.value = value;
|
|
12
|
-
}
|
|
13
|
-
bindOpen(getOpen, setOpen) {
|
|
14
|
-
this.#open.bind(getOpen, setOpen);
|
|
15
|
-
}
|
|
16
|
-
get anchorEl() {
|
|
17
|
-
return this.#anchorEl.value;
|
|
18
|
-
}
|
|
19
|
-
set anchorEl(value) {
|
|
20
|
-
this.#anchorEl.value = value;
|
|
21
|
-
}
|
|
22
|
-
bindAnchorEl(getAnchorEl, setAnchorEl) {
|
|
23
|
-
this.#anchorEl.bind(getAnchorEl, setAnchorEl);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export function setAutocompleteContext(state) {
|
|
27
|
-
return setContext(AutocompleteContext, state);
|
|
28
|
-
}
|
|
29
|
-
export function getAutocompleteContext() {
|
|
30
|
-
const ctx = getContext(AutocompleteContext);
|
|
31
|
-
if (!ctx)
|
|
32
|
-
throw new Error("AutocompleteContext is undefined");
|
|
33
|
-
return ctx;
|
|
34
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { getAutocompleteContext } from "./index.js";
|
|
3
|
-
import { Input, type InputProps } from "../input/index.js";
|
|
4
|
-
import { mergeComponentProps } from "../merge-props.js";
|
|
5
|
-
|
|
6
|
-
export type AutocompleteInputProps = InputProps;
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<script lang="ts">
|
|
10
|
-
let {
|
|
11
|
-
el = $bindable(),
|
|
12
|
-
value = $bindable(""),
|
|
13
|
-
...restProps
|
|
14
|
-
}: AutocompleteInputProps = $props();
|
|
15
|
-
|
|
16
|
-
const ctx = getAutocompleteContext();
|
|
17
|
-
ctx.bindInput(
|
|
18
|
-
() => value,
|
|
19
|
-
(newval) => (value = newval),
|
|
20
|
-
);
|
|
21
|
-
ctx.bindAnchorEl(
|
|
22
|
-
() => el,
|
|
23
|
-
(newval) => (el = newval),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
function handleKeyDown(event: KeyboardEvent) {
|
|
27
|
-
ctx.handleKeyDown(event);
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<Input
|
|
32
|
-
bind:el={ctx.anchorEl}
|
|
33
|
-
bind:value={ctx.input}
|
|
34
|
-
autocomplete="off"
|
|
35
|
-
{...mergeComponentProps(Input, { onkeydown: handleKeyDown }, restProps)}
|
|
36
|
-
/>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type InputProps } from "../input/index.js";
|
|
2
|
-
export type AutocompleteInputProps = InputProps;
|
|
3
|
-
declare const AutocompleteInput: import("svelte").Component<InputProps, {}, "el" | "value">;
|
|
4
|
-
type AutocompleteInput = ReturnType<typeof AutocompleteInput>;
|
|
5
|
-
export default AutocompleteInput;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { getAutocompleteContext } from "./index.js";
|
|
3
|
-
import { baseClasses, type Variants } from "../base.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 AutocompleteItemProps = {
|
|
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
|
-
}: AutocompleteItemProps = $props();
|
|
30
|
-
|
|
31
|
-
const ctx = getAutocompleteContext();
|
|
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
|
-
aria-selected={ctx.focused === el}
|
|
54
|
-
class={twMerge(
|
|
55
|
-
baseClasses({ variant, color, shape }),
|
|
56
|
-
"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",
|
|
57
|
-
className,
|
|
58
|
-
)}
|
|
59
|
-
{...mergeProps(
|
|
60
|
-
{
|
|
61
|
-
onclick: handleClick,
|
|
62
|
-
onmouseenter: handleMouseEnter,
|
|
63
|
-
},
|
|
64
|
-
restProps,
|
|
65
|
-
)}
|
|
66
|
-
>
|
|
67
|
-
{@render children()}
|
|
68
|
-
</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 AutocompleteItemProps = {
|
|
6
|
-
onSelect?: (el: HTMLElement) => void;
|
|
7
|
-
children: Snippet;
|
|
8
|
-
} & ElementRef & ClassName & Variants & HTMLAttributes<HTMLDivElement>;
|
|
9
|
-
declare const AutocompleteItem: import("svelte").Component<AutocompleteItemProps, {}, "el">;
|
|
10
|
-
type AutocompleteItem = ReturnType<typeof AutocompleteItem>;
|
|
11
|
-
export default AutocompleteItem;
|
package/dist/base.css
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
.radius-none {
|
|
2
|
-
--radius: none;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.radius-xs {
|
|
6
|
-
--radius: 0.125rem;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.radius-sm {
|
|
10
|
-
--radius: 0.25rem;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.radius-md {
|
|
14
|
-
--radius: 0.375rem;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.radius-lg {
|
|
18
|
-
--radius: 0.5rem;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.radius-xl {
|
|
22
|
-
--radius: 0.75rem;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.radius-2xl {
|
|
26
|
-
--radius: 1rem;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.radius-3xl {
|
|
30
|
-
--radius: 1.5rem;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.radius-4xl {
|
|
34
|
-
--radius: 2rem;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.radius-full {
|
|
38
|
-
--radius: calc(infinity * 1px);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.color-primary {
|
|
42
|
-
--color-main: var(--md-sys-color-primary);
|
|
43
|
-
--color-on-main: var(--md-sys-color-on-primary);
|
|
44
|
-
--color-tonal: var(--md-sys-color-primary-container);
|
|
45
|
-
--color-on-tonal: var(--md-sys-color-on-primary-container);
|
|
46
|
-
--color-shadow: var(--md-sys-color-shadow);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.color-secondary {
|
|
50
|
-
--color-main: var(--md-sys-color-secondary);
|
|
51
|
-
--color-on-main: var(--md-sys-color-on-secondary);
|
|
52
|
-
--color-tonal: var(--md-sys-color-secondary-container);
|
|
53
|
-
--color-on-tonal: var(--md-sys-color-on-secondary-container);
|
|
54
|
-
--color-shadow: var(--md-sys-color-shadow);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.color-tertiary {
|
|
58
|
-
--color-main: var(--md-sys-color-tertiary);
|
|
59
|
-
--color-on-main: var(--md-sys-color-on-tertiary);
|
|
60
|
-
--color-tonal: var(--md-sys-color-tertiary-container);
|
|
61
|
-
--color-on-tonal: var(--md-sys-color-on-tertiary-container);
|
|
62
|
-
--color-shadow: var(--md-sys-color-shadow);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.color-error {
|
|
66
|
-
--color-main: var(--md-sys-color-error);
|
|
67
|
-
--color-on-main: var(--md-sys-color-on-error);
|
|
68
|
-
--color-tonal: var(--md-sys-color-error-container);
|
|
69
|
-
--color-on-tonal: var(--md-sys-color-on-error-container);
|
|
70
|
-
--color-shadow: var(--md-sys-color-shadow);
|
|
71
|
-
}
|
package/dist/bindable.svelte.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export class Bindable {
|
|
2
|
-
#value = $state();
|
|
3
|
-
#setValue;
|
|
4
|
-
constructor(value) {
|
|
5
|
-
this.#value = value;
|
|
6
|
-
}
|
|
7
|
-
bind(getValue, setValue) {
|
|
8
|
-
this.#value = getValue();
|
|
9
|
-
this.#setValue = setValue;
|
|
10
|
-
$effect(() => {
|
|
11
|
-
if (this.#value !== getValue()) {
|
|
12
|
-
this.#value = getValue();
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
get value() {
|
|
17
|
-
return this.#value;
|
|
18
|
-
}
|
|
19
|
-
set value(value) {
|
|
20
|
-
if (this.#value !== value) {
|
|
21
|
-
this.#value = value;
|
|
22
|
-
this.#setValue?.(value);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import type { ClassName } from "../utils.js";
|
|
3
|
-
import type { Snippet } from "svelte";
|
|
4
|
-
import { twMerge } from "tailwind-merge";
|
|
5
|
-
|
|
6
|
-
export type CommandContentProps = { children: Snippet } & ClassName;
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<script lang="ts">
|
|
10
|
-
let { class: className, children }: CommandContentProps = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<div class={twMerge("h-full overflow-scroll", className)}>
|
|
14
|
-
{@render children()}
|
|
15
|
-
</div>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ClassName } from "../utils.js";
|
|
2
|
-
import type { Snippet } from "svelte";
|
|
3
|
-
export type CommandContentProps = {
|
|
4
|
-
children: Snippet;
|
|
5
|
-
} & ClassName;
|
|
6
|
-
declare const CommandContent: import("svelte").Component<CommandContentProps, {}, "">;
|
|
7
|
-
type CommandContent = ReturnType<typeof CommandContent>;
|
|
8
|
-
export default CommandContent;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ItemContext } from "../common/index.js";
|
|
2
|
-
import { getContext, setContext } from "svelte";
|
|
3
|
-
export class CommandContext extends ItemContext {
|
|
4
|
-
}
|
|
5
|
-
export function setCommandContext(state) {
|
|
6
|
-
return setContext(CommandContext, state);
|
|
7
|
-
}
|
|
8
|
-
export function getCommandContext() {
|
|
9
|
-
const ctx = getContext(CommandContext);
|
|
10
|
-
if (!ctx)
|
|
11
|
-
throw new Error("CommandContext is undefined");
|
|
12
|
-
return ctx;
|
|
13
|
-
}
|
|
@@ -1,44 +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 { HTMLInputAttributes } from "svelte/elements";
|
|
7
|
-
import { twMerge } from "tailwind-merge";
|
|
8
|
-
|
|
9
|
-
export type CommandInputProps = {} & ElementRef &
|
|
10
|
-
ClassName &
|
|
11
|
-
Variants &
|
|
12
|
-
HTMLInputAttributes;
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
let {
|
|
17
|
-
value = $bindable(""),
|
|
18
|
-
class: className,
|
|
19
|
-
variant = "plain",
|
|
20
|
-
color = "secondary",
|
|
21
|
-
shape = "rounded",
|
|
22
|
-
...restProps
|
|
23
|
-
}: CommandInputProps = $props();
|
|
24
|
-
|
|
25
|
-
const ctx = getCommandContext();
|
|
26
|
-
ctx.bindInput(
|
|
27
|
-
() => value,
|
|
28
|
-
(newValue) => (value = newValue),
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
function handleKeyDown(event: KeyboardEvent) {
|
|
32
|
-
ctx.handleKeyDown(event);
|
|
33
|
-
}
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<input
|
|
37
|
-
bind:value={ctx.input}
|
|
38
|
-
class={twMerge(
|
|
39
|
-
baseClasses({ variant, color, shape }),
|
|
40
|
-
"w-full p-1 focus-visible:outline-hidden",
|
|
41
|
-
className,
|
|
42
|
-
)}
|
|
43
|
-
{...mergeProps({ onkeydown: handleKeyDown }, restProps)}
|
|
44
|
-
/>
|