kosui 0.0.7
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/LICENSE +7 -0
- package/README.md +3 -0
- package/dist/alert/alert.svelte +28 -0
- package/dist/alert/alert.svelte.d.ts +5 -0
- package/dist/alert/index.d.ts +1 -0
- package/dist/alert/index.js +1 -0
- package/dist/autocomplete/autocomplete-content.svelte +47 -0
- package/dist/autocomplete/autocomplete-content.svelte.d.ts +10 -0
- package/dist/autocomplete/autocomplete-context.svelte.d.ts +12 -0
- package/dist/autocomplete/autocomplete-context.svelte.js +34 -0
- package/dist/autocomplete/autocomplete-input.svelte +43 -0
- package/dist/autocomplete/autocomplete-input.svelte.d.ts +7 -0
- package/dist/autocomplete/autocomplete-item.svelte +68 -0
- package/dist/autocomplete/autocomplete-item.svelte.d.ts +11 -0
- package/dist/autocomplete/autocomplete.svelte +20 -0
- package/dist/autocomplete/autocomplete.svelte.d.ts +8 -0
- package/dist/autocomplete/index.d.ts +4 -0
- package/dist/autocomplete/index.js +4 -0
- package/dist/avatar/avatar.svelte +47 -0
- package/dist/avatar/avatar.svelte.d.ts +8 -0
- package/dist/avatar/index.d.ts +1 -0
- package/dist/avatar/index.js +1 -0
- package/dist/badge/badge.svelte +43 -0
- package/dist/badge/badge.svelte.d.ts +9 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +1 -0
- package/dist/base.d.ts +21 -0
- package/dist/base.js +70 -0
- package/dist/bindable.svelte.d.ts +7 -0
- package/dist/bindable.svelte.js +25 -0
- package/dist/box/box.svelte +42 -0
- package/dist/box/box.svelte.d.ts +12 -0
- package/dist/box/index.d.ts +1 -0
- package/dist/box/index.js +1 -0
- package/dist/breadcrumbs/breadcrumbs.svelte +39 -0
- package/dist/breadcrumbs/breadcrumbs.svelte.d.ts +13 -0
- package/dist/breadcrumbs/index.d.ts +1 -0
- package/dist/breadcrumbs/index.js +1 -0
- package/dist/button/button.svelte +70 -0
- package/dist/button/button.svelte.d.ts +13 -0
- package/dist/button/index.d.ts +1 -0
- package/dist/button/index.js +1 -0
- package/dist/chip/chip.svelte +57 -0
- package/dist/chip/chip.svelte.d.ts +11 -0
- package/dist/chip/index.d.ts +1 -0
- package/dist/chip/index.js +1 -0
- package/dist/command/action.svelte.d.ts +35 -0
- package/dist/command/action.svelte.js +76 -0
- package/dist/command/command-content.svelte +15 -0
- package/dist/command/command-content.svelte.d.ts +8 -0
- package/dist/command/command-context.svelte.d.ts +5 -0
- package/dist/command/command-context.svelte.js +13 -0
- package/dist/command/command-input.svelte +44 -0
- package/dist/command/command-input.svelte.d.ts +7 -0
- package/dist/command/command-item.svelte +66 -0
- package/dist/command/command-item.svelte.d.ts +11 -0
- package/dist/command/command-search.svelte +29 -0
- package/dist/command/command-search.svelte.d.ts +5 -0
- package/dist/command/command.svelte +19 -0
- package/dist/command/command.svelte.d.ts +8 -0
- package/dist/command/commander.svelte +107 -0
- package/dist/command/commander.svelte.d.ts +9 -0
- package/dist/command/index.d.ts +8 -0
- package/dist/command/index.js +8 -0
- package/dist/common/divider.svelte +13 -0
- package/dist/common/divider.svelte.d.ts +6 -0
- package/dist/common/header.svelte +35 -0
- package/dist/common/header.svelte.d.ts +10 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.js +3 -0
- package/dist/common/item-context.svelte.d.ts +12 -0
- package/dist/common/item-context.svelte.js +77 -0
- package/dist/dialog/dialog-button.svelte +25 -0
- package/dist/dialog/dialog-button.svelte.d.ts +32 -0
- package/dist/dialog/dialog.svelte +69 -0
- package/dist/dialog/dialog.svelte.d.ts +37 -0
- package/dist/dialog/dialoguer-context.svelte.d.ts +53 -0
- package/dist/dialog/dialoguer-context.svelte.js +85 -0
- package/dist/dialog/dialoguer.svelte +65 -0
- package/dist/dialog/dialoguer.svelte.d.ts +7 -0
- package/dist/dialog/index.d.ts +4 -0
- package/dist/dialog/index.js +4 -0
- package/dist/event-manager.d.ts +15 -0
- package/dist/event-manager.js +47 -0
- package/dist/fab/fab.svelte +28 -0
- package/dist/fab/fab.svelte.d.ts +6 -0
- package/dist/fab/index.d.ts +1 -0
- package/dist/fab/index.js +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +39 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/input/input.svelte +41 -0
- package/dist/input/input.svelte.d.ts +7 -0
- package/dist/link/index.d.ts +1 -0
- package/dist/link/index.js +1 -0
- package/dist/link/link.svelte +51 -0
- package/dist/link/link.svelte.d.ts +10 -0
- package/dist/markdown/index.d.ts +25 -0
- package/dist/markdown/index.js +25 -0
- package/dist/markdown/markdown-blockquote.svelte +14 -0
- package/dist/markdown/markdown-blockquote.svelte.d.ts +7 -0
- package/dist/markdown/markdown-br.svelte +12 -0
- package/dist/markdown/markdown-br.svelte.d.ts +7 -0
- package/dist/markdown/markdown-code.svelte +14 -0
- package/dist/markdown/markdown-code.svelte.d.ts +7 -0
- package/dist/markdown/markdown-codespan.svelte +15 -0
- package/dist/markdown/markdown-codespan.svelte.d.ts +7 -0
- package/dist/markdown/markdown-context.svelte.d.ts +26 -0
- package/dist/markdown/markdown-context.svelte.js +30 -0
- package/dist/markdown/markdown-def.svelte +15 -0
- package/dist/markdown/markdown-def.svelte.d.ts +7 -0
- package/dist/markdown/markdown-del.svelte +14 -0
- package/dist/markdown/markdown-del.svelte.d.ts +7 -0
- package/dist/markdown/markdown-em.svelte +14 -0
- package/dist/markdown/markdown-em.svelte.d.ts +7 -0
- package/dist/markdown/markdown-escape.svelte +8 -0
- package/dist/markdown/markdown-escape.svelte.d.ts +5 -0
- package/dist/markdown/markdown-heading.svelte +16 -0
- package/dist/markdown/markdown-heading.svelte.d.ts +7 -0
- package/dist/markdown/markdown-hr.svelte +12 -0
- package/dist/markdown/markdown-hr.svelte.d.ts +7 -0
- package/dist/markdown/markdown-html.svelte +9 -0
- package/dist/markdown/markdown-html.svelte.d.ts +5 -0
- package/dist/markdown/markdown-image.svelte +12 -0
- package/dist/markdown/markdown-image.svelte.d.ts +7 -0
- package/dist/markdown/markdown-link.svelte +15 -0
- package/dist/markdown/markdown-link.svelte.d.ts +7 -0
- package/dist/markdown/markdown-list-item.svelte +14 -0
- package/dist/markdown/markdown-list-item.svelte.d.ts +7 -0
- package/dist/markdown/markdown-list.svelte +19 -0
- package/dist/markdown/markdown-list.svelte.d.ts +7 -0
- package/dist/markdown/markdown-paragraph.svelte +16 -0
- package/dist/markdown/markdown-paragraph.svelte.d.ts +7 -0
- package/dist/markdown/markdown-space.svelte +8 -0
- package/dist/markdown/markdown-space.svelte.d.ts +5 -0
- package/dist/markdown/markdown-strong.svelte +15 -0
- package/dist/markdown/markdown-strong.svelte.d.ts +7 -0
- package/dist/markdown/markdown-table-cell.svelte +16 -0
- package/dist/markdown/markdown-table-cell.svelte.d.ts +7 -0
- package/dist/markdown/markdown-table.svelte +34 -0
- package/dist/markdown/markdown-table.svelte.d.ts +7 -0
- package/dist/markdown/markdown-text.svelte +8 -0
- package/dist/markdown/markdown-text.svelte.d.ts +5 -0
- package/dist/markdown/markdown-token.svelte +25 -0
- package/dist/markdown/markdown-token.svelte.d.ts +7 -0
- package/dist/markdown/markdown-tokens.svelte +13 -0
- package/dist/markdown/markdown-tokens.svelte.d.ts +7 -0
- package/dist/markdown/markdown.svelte +186 -0
- package/dist/markdown/markdown.svelte.d.ts +31 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +7 -0
- package/dist/menu/menu-actions.svelte +51 -0
- package/dist/menu/menu-actions.svelte.d.ts +7 -0
- package/dist/menu/menu-content.svelte +47 -0
- package/dist/menu/menu-content.svelte.d.ts +10 -0
- package/dist/menu/menu-context.svelte.d.ts +18 -0
- package/dist/menu/menu-context.svelte.js +118 -0
- package/dist/menu/menu-item.svelte +85 -0
- package/dist/menu/menu-item.svelte.d.ts +11 -0
- package/dist/menu/menu-trigger-button.svelte +31 -0
- package/dist/menu/menu-trigger-button.svelte.d.ts +5 -0
- package/dist/menu/menu-trigger.svelte +42 -0
- package/dist/menu/menu-trigger.svelte.d.ts +10 -0
- package/dist/menu/menu.svelte +29 -0
- package/dist/menu/menu.svelte.d.ts +9 -0
- package/dist/merge-props.d.ts +13 -0
- package/dist/merge-props.js +84 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/modal/index.js +1 -0
- package/dist/modal/modal.svelte +123 -0
- package/dist/modal/modal.svelte.d.ts +11 -0
- package/dist/ordered-html-elements.d.ts +7 -0
- package/dist/ordered-html-elements.js +29 -0
- package/dist/popover/index.d.ts +1 -0
- package/dist/popover/index.js +1 -0
- package/dist/popover/popover.svelte +184 -0
- package/dist/popover/popover.svelte.d.ts +18 -0
- package/dist/portal/index.d.ts +1 -0
- package/dist/portal/index.js +1 -0
- package/dist/portal/portal.svelte +12 -0
- package/dist/portal/portal.svelte.d.ts +8 -0
- package/dist/portal/proxy.svelte +10 -0
- package/dist/portal/proxy.svelte.d.ts +7 -0
- package/dist/progress/circular-progress.svelte +86 -0
- package/dist/progress/circular-progress.svelte.d.ts +13 -0
- package/dist/progress/index.d.ts +1 -0
- package/dist/progress/index.js +1 -0
- package/dist/shortcut/index.d.ts +2 -0
- package/dist/shortcut/index.js +2 -0
- package/dist/shortcut/shortcut-badge.svelte +41 -0
- package/dist/shortcut/shortcut-badge.svelte.d.ts +11 -0
- package/dist/shortcut/shortcut.d.ts +29 -0
- package/dist/shortcut/shortcut.js +95 -0
- package/dist/toggle/index.d.ts +2 -0
- package/dist/toggle/index.js +2 -0
- package/dist/toggle/toggle-button.svelte +60 -0
- package/dist/toggle/toggle-button.svelte.d.ts +32 -0
- package/dist/toggle/toggle-context.svelte.d.ts +9 -0
- package/dist/toggle/toggle-context.svelte.js +32 -0
- package/dist/toggle/toggle-group.svelte +41 -0
- package/dist/toggle/toggle-group.svelte.d.ts +32 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/tooltip/tooltip.svelte +94 -0
- package/dist/tooltip/tooltip.svelte.d.ts +25 -0
- package/dist/utils.d.ts +43 -0
- package/dist/utils.js +72 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright © 2025 Koso Labs
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { Box, type BoxProps } from "../box";
|
|
4
|
+
|
|
5
|
+
export type AlertProps = BoxProps;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
let {
|
|
10
|
+
el = $bindable(),
|
|
11
|
+
class: className,
|
|
12
|
+
variant = "elevated",
|
|
13
|
+
color = "primary",
|
|
14
|
+
shape = "rounded",
|
|
15
|
+
backdrop = true,
|
|
16
|
+
...restProps
|
|
17
|
+
}: AlertProps = $props();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Box
|
|
21
|
+
bind:el
|
|
22
|
+
{variant}
|
|
23
|
+
{color}
|
|
24
|
+
{shape}
|
|
25
|
+
{backdrop}
|
|
26
|
+
class={twMerge("p-3", className)}
|
|
27
|
+
{...restProps}
|
|
28
|
+
/>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Alert, type AlertProps } from "./alert.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Alert } from "./alert.svelte";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
import { baseClasses, type Variants } from "../base";
|
|
5
|
+
import { Popover, type PopoverProps } from "../popover";
|
|
6
|
+
import type { ClassName } from "../utils";
|
|
7
|
+
import { getAutocompleteContext } from "./autocomplete-context.svelte";
|
|
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>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { type Variants } from "../base";
|
|
3
|
+
import { type PopoverProps } from "../popover";
|
|
4
|
+
import type { ClassName } from "../utils";
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ItemContext } from "../common";
|
|
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;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
import { Bindable } from "../bindable.svelte";
|
|
3
|
+
import { ItemContext } from "../common";
|
|
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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
import { type Variants } from "../base";
|
|
4
|
+
import { Input } from "../input";
|
|
5
|
+
import type { ClassName, ElementRef } from "../utils";
|
|
6
|
+
import { getAutocompleteContext } from "./autocomplete-context.svelte";
|
|
7
|
+
|
|
8
|
+
export type AutocompleteInputProps = {} & ElementRef &
|
|
9
|
+
ClassName &
|
|
10
|
+
Variants &
|
|
11
|
+
Omit<HTMLInputAttributes, "autocomplete">;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { mergeComponentProps } from "../merge-props";
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
el = $bindable(),
|
|
19
|
+
value = $bindable(""),
|
|
20
|
+
...restProps
|
|
21
|
+
}: AutocompleteInputProps = $props();
|
|
22
|
+
|
|
23
|
+
const ctx = getAutocompleteContext();
|
|
24
|
+
ctx.bindInput(
|
|
25
|
+
() => value,
|
|
26
|
+
(newval) => (value = newval),
|
|
27
|
+
);
|
|
28
|
+
ctx.bindAnchorEl(
|
|
29
|
+
() => el,
|
|
30
|
+
(newval) => (el = newval),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
function handleKeyDown(event: KeyboardEvent) {
|
|
34
|
+
ctx.handleKeyDown(event);
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<Input
|
|
39
|
+
bind:el={ctx.anchorEl}
|
|
40
|
+
bind:value={ctx.input}
|
|
41
|
+
autocomplete="off"
|
|
42
|
+
{...mergeComponentProps(Input, { onkeydown: handleKeyDown }, restProps)}
|
|
43
|
+
/>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
2
|
+
import { type Variants } from "../base";
|
|
3
|
+
import type { ClassName, ElementRef } from "../utils";
|
|
4
|
+
export type AutocompleteInputProps = {} & ElementRef & ClassName & Variants & Omit<HTMLInputAttributes, "autocomplete">;
|
|
5
|
+
declare const AutocompleteInput: import("svelte").Component<AutocompleteInputProps, {}, "el" | "value">;
|
|
6
|
+
type AutocompleteInput = ReturnType<typeof AutocompleteInput>;
|
|
7
|
+
export default AutocompleteInput;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { type Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
5
|
+
import { baseClasses, type Variants } from "../base";
|
|
6
|
+
import { mergeProps } from "../merge-props";
|
|
7
|
+
import { type ClassName, type ElementRef } from "../utils";
|
|
8
|
+
import { getAutocompleteContext } from "./autocomplete-context.svelte";
|
|
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>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { type Variants } from "../base";
|
|
4
|
+
import { type ClassName, type ElementRef } from "../utils";
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { ClassName } from "../utils";
|
|
4
|
+
import {
|
|
5
|
+
AutocompleteContext,
|
|
6
|
+
setAutocompleteContext,
|
|
7
|
+
} from "./autocomplete-context.svelte";
|
|
8
|
+
|
|
9
|
+
export type AutocompleteProps = {
|
|
10
|
+
children: Snippet;
|
|
11
|
+
} & ClassName;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
let { children }: AutocompleteProps = $props();
|
|
16
|
+
|
|
17
|
+
setAutocompleteContext(new AutocompleteContext());
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{@render children()}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { ClassName } from "../utils";
|
|
3
|
+
export type AutocompleteProps = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
} & ClassName;
|
|
6
|
+
declare const Autocomplete: import("svelte").Component<AutocompleteProps, {}, "">;
|
|
7
|
+
type Autocomplete = ReturnType<typeof Autocomplete>;
|
|
8
|
+
export default Autocomplete;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as AutocompleteContent } from "./autocomplete-content.svelte";
|
|
2
|
+
export { default as AutocompleteInput } from "./autocomplete-input.svelte";
|
|
3
|
+
export { default as AutocompleteItem } from "./autocomplete-item.svelte";
|
|
4
|
+
export { default as Autocomplete } from "./autocomplete.svelte";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as AutocompleteContent } from "./autocomplete-content.svelte";
|
|
2
|
+
export { default as AutocompleteInput } from "./autocomplete-input.svelte";
|
|
3
|
+
export { default as AutocompleteItem } from "./autocomplete-item.svelte";
|
|
4
|
+
export { default as Autocomplete } from "./autocomplete.svelte";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { Box, type BoxProps } from "../box";
|
|
4
|
+
|
|
5
|
+
export type AvatarProps = {
|
|
6
|
+
src?: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
} & BoxProps;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
let {
|
|
13
|
+
src,
|
|
14
|
+
alt,
|
|
15
|
+
children,
|
|
16
|
+
el = $bindable(),
|
|
17
|
+
class: className,
|
|
18
|
+
variant = "tonal",
|
|
19
|
+
color = "secondary",
|
|
20
|
+
shape = "rounded",
|
|
21
|
+
centered = true,
|
|
22
|
+
...restProps
|
|
23
|
+
}: AvatarProps = $props();
|
|
24
|
+
|
|
25
|
+
let error: boolean = $state(false);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Box
|
|
29
|
+
bind:el
|
|
30
|
+
{variant}
|
|
31
|
+
{color}
|
|
32
|
+
{shape}
|
|
33
|
+
{centered}
|
|
34
|
+
class={twMerge("aspect-square h-9 overflow-clip text-xl", className)}
|
|
35
|
+
{...restProps}
|
|
36
|
+
>
|
|
37
|
+
{#if src && !error}
|
|
38
|
+
<img
|
|
39
|
+
{src}
|
|
40
|
+
{alt}
|
|
41
|
+
onerror={() => (error = true)}
|
|
42
|
+
referrerpolicy="no-referrer"
|
|
43
|
+
/>
|
|
44
|
+
{:else}
|
|
45
|
+
{@render children?.()}
|
|
46
|
+
{/if}
|
|
47
|
+
</Box>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar, type AvatarProps } from "./avatar.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar } from "./avatar.svelte";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { Box, type BoxProps } from "../box";
|
|
4
|
+
|
|
5
|
+
export type BadgeProps = {
|
|
6
|
+
verticalAlignment?: "top" | "bottom";
|
|
7
|
+
horizontalAlignment?: "left" | "right";
|
|
8
|
+
content?: string;
|
|
9
|
+
} & BoxProps;
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
verticalAlignment = "top",
|
|
13
|
+
horizontalAlignment = "right",
|
|
14
|
+
content,
|
|
15
|
+
children,
|
|
16
|
+
class: className,
|
|
17
|
+
variant = "filled",
|
|
18
|
+
color = "primary",
|
|
19
|
+
centered = true,
|
|
20
|
+
}: BadgeProps = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class="relative">
|
|
24
|
+
{#if content}
|
|
25
|
+
<Box
|
|
26
|
+
{variant}
|
|
27
|
+
{color}
|
|
28
|
+
{centered}
|
|
29
|
+
shape="circle"
|
|
30
|
+
class={twMerge(
|
|
31
|
+
"absolute z-10 size-5 p-1 text-xs",
|
|
32
|
+
|
|
33
|
+
verticalAlignment === "top" && "top-0 -translate-y-1/2",
|
|
34
|
+
verticalAlignment === "bottom" && "bottom-0 translate-y-1/2",
|
|
35
|
+
horizontalAlignment === "left" && "left-0 -translate-x-1/2",
|
|
36
|
+
horizontalAlignment === "right" && "right-0 translate-x-1/2",
|
|
37
|
+
|
|
38
|
+
className,
|
|
39
|
+
)}>{content}</Box
|
|
40
|
+
>
|
|
41
|
+
{/if}
|
|
42
|
+
{@render children?.()}
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BoxProps } from "../box";
|
|
2
|
+
export type BadgeProps = {
|
|
3
|
+
verticalAlignment?: "top" | "bottom";
|
|
4
|
+
horizontalAlignment?: "left" | "right";
|
|
5
|
+
content?: string;
|
|
6
|
+
} & BoxProps;
|
|
7
|
+
declare const Badge: import("svelte").Component<BadgeProps, {}, "">;
|
|
8
|
+
type Badge = ReturnType<typeof Badge>;
|
|
9
|
+
export default Badge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Badge } from "./badge.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Badge } from "./badge.svelte";
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const variants: readonly ["elevated", "filled", "tonal", "outlined", "plain", "text"];
|
|
2
|
+
export declare const colors: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
3
|
+
export declare const shapes: readonly ["square", "rounded", "circle"];
|
|
4
|
+
export declare const underlines: readonly ["always", "hover", "none"];
|
|
5
|
+
export type Variant = {
|
|
6
|
+
variant?: (typeof variants)[number];
|
|
7
|
+
};
|
|
8
|
+
export type Color = {
|
|
9
|
+
color?: (typeof colors)[number];
|
|
10
|
+
};
|
|
11
|
+
export type Shape = {
|
|
12
|
+
shape?: (typeof shapes)[number];
|
|
13
|
+
};
|
|
14
|
+
export type Underline = {
|
|
15
|
+
underline?: (typeof underlines)[number];
|
|
16
|
+
};
|
|
17
|
+
export type Variants = Variant & Color & Shape & Underline & {
|
|
18
|
+
hover?: boolean;
|
|
19
|
+
focus?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const baseClasses: ({ variant, color, shape, underline, hover, focus, }: Variants) => string;
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
export const variants = [
|
|
3
|
+
"elevated",
|
|
4
|
+
"filled",
|
|
5
|
+
"tonal",
|
|
6
|
+
"outlined",
|
|
7
|
+
"plain",
|
|
8
|
+
"text",
|
|
9
|
+
];
|
|
10
|
+
export const colors = [
|
|
11
|
+
"primary",
|
|
12
|
+
"secondary",
|
|
13
|
+
"tertiary",
|
|
14
|
+
"error",
|
|
15
|
+
"inherit",
|
|
16
|
+
];
|
|
17
|
+
export const shapes = ["square", "rounded", "circle"];
|
|
18
|
+
export const underlines = ["always", "hover", "none"];
|
|
19
|
+
const hoverBaseClasses = ({ variant, color }) => twMerge("disabled:text-m3-on-surface/38 disabled:bg-m3-on-surface/12 disabled:cursor-not-allowed", variant === "filled" && "hover:opacity-90", variant === "tonal" && "hover:opacity-80", variant === "text" && "hover:opacity-80", variant === "elevated" &&
|
|
20
|
+
color === "primary" &&
|
|
21
|
+
"hover:bg-m3-primary-container/30", variant === "elevated" &&
|
|
22
|
+
color === "secondary" &&
|
|
23
|
+
"hover:bg-m3-secondary-container/30", variant === "elevated" &&
|
|
24
|
+
color === "tertiary" &&
|
|
25
|
+
"hover:bg-m3-tertiary-container/30", variant === "elevated" &&
|
|
26
|
+
color === "error" &&
|
|
27
|
+
"hover:bg-m3-error-container/30", (variant === "outlined" || variant === "plain") &&
|
|
28
|
+
color === "primary" &&
|
|
29
|
+
"hover:bg-m3-primary/15", (variant === "outlined" || variant === "plain") &&
|
|
30
|
+
color === "secondary" &&
|
|
31
|
+
"hover:bg-m3-secondary/15", (variant === "outlined" || variant === "plain") &&
|
|
32
|
+
color === "tertiary" &&
|
|
33
|
+
"hover:bg-m3-tertiary/15", (variant === "outlined" || variant === "plain") &&
|
|
34
|
+
color === "error" &&
|
|
35
|
+
"hover:bg-m3-error/15");
|
|
36
|
+
const focusBaseClasses = ({ variant, color }) => twMerge("disabled:text-m3-on-surface/38 disabled:bg-m3-on-surface/12 disabled:cursor-not-allowed", "focus:ring-1 focus-visible:outline-hidden", variant === "filled" && "focus:opacity-90", variant === "tonal" && "focus:opacity-80", variant === "text" && "focus:opacity-80", color === "primary" && "focus:ring-m3-primary", color === "secondary" && "focus:ring-m3-secondary", color === "tertiary" && "focus:ring-m3-tertiary", color === "error" && "focus:ring-m3-error", variant === "filled" && color === "primary" && "focus:ring-m3-on-primary", variant === "filled" &&
|
|
37
|
+
color === "secondary" &&
|
|
38
|
+
"focus:ring-m3-on-secondary", variant === "filled" && color === "tertiary" && "focus:ring-m3-on-tertiary", variant === "filled" && color === "error" && "focus:ring-m3-on-error", variant === "elevated" &&
|
|
39
|
+
color === "primary" &&
|
|
40
|
+
"focus:bg-m3-primary-container/30", variant === "elevated" &&
|
|
41
|
+
color === "secondary" &&
|
|
42
|
+
"focus:bg-m3-secondary-container/30", variant === "elevated" &&
|
|
43
|
+
color === "tertiary" &&
|
|
44
|
+
"focus:bg-m3-tertiary-container/30", variant === "elevated" &&
|
|
45
|
+
color === "error" &&
|
|
46
|
+
"focus:bg-m3-error-container/30", (variant === "outlined" || variant === "plain") &&
|
|
47
|
+
color === "primary" &&
|
|
48
|
+
"focus:bg-m3-primary/15", (variant === "outlined" || variant === "plain") &&
|
|
49
|
+
color === "secondary" &&
|
|
50
|
+
"focus:bg-m3-secondary/15", (variant === "outlined" || variant === "plain") &&
|
|
51
|
+
color === "tertiary" &&
|
|
52
|
+
"focus:bg-m3-tertiary/15", (variant === "outlined" || variant === "plain") &&
|
|
53
|
+
color === "error" &&
|
|
54
|
+
"focus:bg-m3-error/15");
|
|
55
|
+
export const baseClasses = ({ variant, color, shape, underline, hover = false, focus = false, }) => twMerge(variant === "elevated" &&
|
|
56
|
+
"bg-m3-surface-container-low shadow shadow-m3-shadow/20", variant === "outlined" && "ring-1", variant === "plain" && "", variant === "text" && "underline-offset-4", color === "primary" && "text-m3-primary", color === "secondary" && "text-m3-secondary", color === "tertiary" && "text-m3-tertiary", color === "error" && "text-m3-error", shape === "square" && "", shape === "rounded" && "rounded-md", shape === "circle" && "rounded-full", underline === "always" && "underline", underline === "hover" && "hover:underline", underline === "none" && "", variant === "filled" &&
|
|
57
|
+
color === "primary" &&
|
|
58
|
+
"bg-m3-primary text-m3-on-primary", variant === "filled" &&
|
|
59
|
+
color === "secondary" &&
|
|
60
|
+
"bg-m3-secondary text-m3-on-secondary", variant === "filled" &&
|
|
61
|
+
color === "tertiary" &&
|
|
62
|
+
"bg-m3-tertiary text-m3-on-tertiary", variant === "filled" && color === "error" && "bg-m3-error text-m3-on-error", variant === "tonal" &&
|
|
63
|
+
color === "primary" &&
|
|
64
|
+
"bg-m3-primary-container text-m3-on-primary-container", variant === "tonal" &&
|
|
65
|
+
color === "secondary" &&
|
|
66
|
+
"bg-m3-secondary-container text-m3-on-secondary-container", variant === "tonal" &&
|
|
67
|
+
color === "tertiary" &&
|
|
68
|
+
"bg-m3-tertiary-container text-m3-on-tertiary-container", variant === "tonal" &&
|
|
69
|
+
color === "error" &&
|
|
70
|
+
"bg-m3-error-container text-m3-on-error-container", hover && hoverBaseClasses({ variant, color }), focus && focusBaseClasses({ variant, color }));
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
5
|
+
import { baseClasses, type Variants } from "../base";
|
|
6
|
+
import { noop, type ClassName, type ElementRef } from "../utils";
|
|
7
|
+
|
|
8
|
+
export type BoxProps = {
|
|
9
|
+
centered?: boolean;
|
|
10
|
+
backdrop?: boolean;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
} & ElementRef &
|
|
13
|
+
ClassName &
|
|
14
|
+
Variants &
|
|
15
|
+
HTMLAttributes<HTMLDivElement>;
|
|
16
|
+
let {
|
|
17
|
+
backdrop = false,
|
|
18
|
+
centered = false,
|
|
19
|
+
children,
|
|
20
|
+
el = $bindable(),
|
|
21
|
+
ref = noop,
|
|
22
|
+
class: className,
|
|
23
|
+
variant,
|
|
24
|
+
color,
|
|
25
|
+
shape,
|
|
26
|
+
...restProps
|
|
27
|
+
}: BoxProps = $props();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<div
|
|
31
|
+
bind:this={el}
|
|
32
|
+
use:ref
|
|
33
|
+
class={twMerge(
|
|
34
|
+
backdrop && "bg-m3-surface-container",
|
|
35
|
+
baseClasses({ variant, color, shape }),
|
|
36
|
+
centered && "flex items-center justify-center",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...restProps}
|
|
40
|
+
>
|
|
41
|
+
{@render children?.()}
|
|
42
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { type Variants } from "../base";
|
|
4
|
+
import { type ClassName, type ElementRef } from "../utils";
|
|
5
|
+
export type BoxProps = {
|
|
6
|
+
centered?: boolean;
|
|
7
|
+
backdrop?: boolean;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
} & ElementRef & ClassName & Variants & HTMLAttributes<HTMLDivElement>;
|
|
10
|
+
declare const Box: import("svelte").Component<BoxProps, {}, "el">;
|
|
11
|
+
type Box = ReturnType<typeof Box>;
|
|
12
|
+
export default Box;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Box, type BoxProps } from "./box.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Box } from "./box.svelte";
|