kosui 0.4.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/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 +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/modal/modal.svelte +11 -5
- package/dist/modal/modal.svelte.d.ts +2 -0
- 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/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Modal, type ModalProps } from "../modal/index.js";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
import { prefersReducedMotion } from "svelte/motion";
|
|
5
|
+
import { fly } from "svelte/transition";
|
|
6
|
+
|
|
7
|
+
export type DrawerSide = "start" | "end";
|
|
8
|
+
|
|
9
|
+
export type DrawerProps = {
|
|
10
|
+
side?: DrawerSide;
|
|
11
|
+
} & Omit<ModalProps, "transition">;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
let {
|
|
16
|
+
el = $bindable(),
|
|
17
|
+
open = $bindable(),
|
|
18
|
+
side = "start",
|
|
19
|
+
shape = "lg",
|
|
20
|
+
class: className,
|
|
21
|
+
children,
|
|
22
|
+
...restProps
|
|
23
|
+
}: DrawerProps = $props();
|
|
24
|
+
|
|
25
|
+
function slide(node: Element) {
|
|
26
|
+
const rtl = getComputedStyle(node).direction === "rtl";
|
|
27
|
+
const fromLeft = (side === "start") !== rtl;
|
|
28
|
+
return fly(node, {
|
|
29
|
+
x: fromLeft ? "-100%" : "100%",
|
|
30
|
+
opacity: 1,
|
|
31
|
+
duration: prefersReducedMotion.current ? 0 : 200,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<Modal
|
|
37
|
+
bind:el
|
|
38
|
+
bind:open
|
|
39
|
+
{shape}
|
|
40
|
+
transition={slide}
|
|
41
|
+
class={cn(
|
|
42
|
+
"my-0 h-full max-h-none w-80 max-w-[calc(100%-3.5rem)] overflow-y-auto bg-m3-surface-container-low p-3",
|
|
43
|
+
side === "start"
|
|
44
|
+
? "ms-0 me-auto rounded-s-none"
|
|
45
|
+
: "ms-auto me-0 rounded-e-none",
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...restProps}
|
|
49
|
+
>
|
|
50
|
+
{@render children()}
|
|
51
|
+
</Modal>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ModalProps } from "../modal/index.js";
|
|
2
|
+
export type DrawerSide = "start" | "end";
|
|
3
|
+
export type DrawerProps = {
|
|
4
|
+
side?: DrawerSide;
|
|
5
|
+
} & Omit<ModalProps, "transition">;
|
|
6
|
+
declare const Drawer: import("svelte").Component<DrawerProps, {}, "el" | "open">;
|
|
7
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
8
|
+
export default Drawer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Drawer, type DrawerProps, type DrawerSide, } from "./drawer.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Drawer, } from "./drawer.svelte";
|
package/dist/fab/fab.svelte
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
class={cn(
|
|
37
37
|
"sticky top-[calc(100%-var(--fab-height))] bottom-0 left-[calc(100%-var(--fab-width))] flex transition",
|
|
38
38
|
restProps.children && "w-fit",
|
|
39
|
-
!clear && "mt-
|
|
39
|
+
!clear && "-mt-(--fab-height)",
|
|
40
40
|
className,
|
|
41
41
|
)}
|
|
42
42
|
style="--fab-width: {width}px; --fab-height: {height}px; {style ?? ''}"
|
package/dist/index.d.ts
CHANGED
|
@@ -22,12 +22,14 @@ export * from "./chip/index.js";
|
|
|
22
22
|
export * from "./command/index.js";
|
|
23
23
|
export * from "./common/index.js";
|
|
24
24
|
export * from "./dialog/index.js";
|
|
25
|
+
export * from "./drawer/index.js";
|
|
25
26
|
export * from "./fab/index.js";
|
|
26
27
|
export * from "./input/index.js";
|
|
27
28
|
export * from "./link/index.js";
|
|
28
29
|
export * from "./markdown/index.js";
|
|
29
30
|
export * from "./menu/index.js";
|
|
30
31
|
export * from "./modal/index.js";
|
|
32
|
+
export * from "./nav/index.js";
|
|
31
33
|
export * from "./popover/index.js";
|
|
32
34
|
export * from "./progress/index.js";
|
|
33
35
|
export * from "./shortcut/index.js";
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,14 @@ export * from "./chip/index.js";
|
|
|
22
22
|
export * from "./command/index.js";
|
|
23
23
|
export * from "./common/index.js";
|
|
24
24
|
export * from "./dialog/index.js";
|
|
25
|
+
export * from "./drawer/index.js";
|
|
25
26
|
export * from "./fab/index.js";
|
|
26
27
|
export * from "./input/index.js";
|
|
27
28
|
export * from "./link/index.js";
|
|
28
29
|
export * from "./markdown/index.js";
|
|
29
30
|
export * from "./menu/index.js";
|
|
30
31
|
export * from "./modal/index.js";
|
|
32
|
+
export * from "./nav/index.js";
|
|
31
33
|
export * from "./popover/index.js";
|
|
32
34
|
export * from "./progress/index.js";
|
|
33
35
|
export * from "./shortcut/index.js";
|
package/dist/modal/modal.svelte
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
import type { Snippet } from "svelte";
|
|
7
7
|
import type { HTMLDialogAttributes } from "svelte/elements";
|
|
8
8
|
import { prefersReducedMotion } from "svelte/motion";
|
|
9
|
-
import { scale } from "svelte/transition";
|
|
9
|
+
import { scale, type TransitionConfig } from "svelte/transition";
|
|
10
10
|
|
|
11
11
|
export type ModalProps = {
|
|
12
12
|
el?: HTMLDialogElement;
|
|
13
13
|
onCancel?: () => void;
|
|
14
|
+
transition?: (node: Element) => TransitionConfig;
|
|
14
15
|
children: Snippet;
|
|
15
16
|
} & ClassName &
|
|
16
17
|
ShapeProp &
|
|
@@ -20,6 +21,13 @@
|
|
|
20
21
|
|
|
21
22
|
const layers: Layer[] = [];
|
|
22
23
|
|
|
24
|
+
function zoom(node: Element) {
|
|
25
|
+
return scale(node, {
|
|
26
|
+
duration: prefersReducedMotion.current ? 0 : 150,
|
|
27
|
+
start: 0.95,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
function focusedElement() {
|
|
24
32
|
const active = document.activeElement;
|
|
25
33
|
return active instanceof HTMLElement && active !== document.body
|
|
@@ -46,6 +54,7 @@
|
|
|
46
54
|
el = $bindable(),
|
|
47
55
|
open = $bindable(),
|
|
48
56
|
onCancel,
|
|
57
|
+
transition = zoom,
|
|
49
58
|
children,
|
|
50
59
|
shape = "xl",
|
|
51
60
|
class: className,
|
|
@@ -85,10 +94,7 @@
|
|
|
85
94
|
baseClasses({ shape }),
|
|
86
95
|
className,
|
|
87
96
|
)}
|
|
88
|
-
transition:
|
|
89
|
-
duration: prefersReducedMotion.current ? 0 : 150,
|
|
90
|
-
start: 0.95,
|
|
91
|
-
}}
|
|
97
|
+
transition:transition
|
|
92
98
|
{...mergeProps(restProps, {
|
|
93
99
|
oncancel,
|
|
94
100
|
onintrostart: () => el?.removeAttribute("data-closing"),
|
|
@@ -2,9 +2,11 @@ import { type ShapeProp } from "../base.js";
|
|
|
2
2
|
import { type ClassName } from "../utils.js";
|
|
3
3
|
import type { Snippet } from "svelte";
|
|
4
4
|
import type { HTMLDialogAttributes } from "svelte/elements";
|
|
5
|
+
import { type TransitionConfig } from "svelte/transition";
|
|
5
6
|
export type ModalProps = {
|
|
6
7
|
el?: HTMLDialogElement;
|
|
7
8
|
onCancel?: () => void;
|
|
9
|
+
transition?: (node: Element) => TransitionConfig;
|
|
8
10
|
children: Snippet;
|
|
9
11
|
} & ClassName & ShapeProp & Omit<HTMLDialogAttributes, "class">;
|
|
10
12
|
declare const Modal: import("svelte").Component<ModalProps, {}, "el" | "open">;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { cn, type ClassName, type ElementRef } from "../utils.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
5
|
+
|
|
6
|
+
export type NavGroupProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
children: Snippet;
|
|
9
|
+
} & ElementRef &
|
|
10
|
+
ClassName &
|
|
11
|
+
Omit<HTMLAttributes<HTMLDivElement>, "class">;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
let {
|
|
16
|
+
label,
|
|
17
|
+
children,
|
|
18
|
+
el = $bindable(),
|
|
19
|
+
class: className,
|
|
20
|
+
...restProps
|
|
21
|
+
}: NavGroupProps = $props();
|
|
22
|
+
|
|
23
|
+
const id = $props.id();
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
bind:this={el}
|
|
28
|
+
role="group"
|
|
29
|
+
aria-labelledby="{id}-label"
|
|
30
|
+
class={cn("flex flex-col gap-0.5", className)}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<div
|
|
34
|
+
id="{id}-label"
|
|
35
|
+
class="px-4 pt-4 pb-1 text-xs font-medium tracking-wide text-m3-on-surface-variant uppercase"
|
|
36
|
+
>
|
|
37
|
+
{label}
|
|
38
|
+
</div>
|
|
39
|
+
{@render children()}
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ClassName, type ElementRef } from "../utils.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
export type NavGroupProps = {
|
|
5
|
+
label: string;
|
|
6
|
+
children: Snippet;
|
|
7
|
+
} & ElementRef & ClassName & Omit<HTMLAttributes<HTMLDivElement>, "class">;
|
|
8
|
+
declare const NavGroup: import("svelte").Component<NavGroupProps, {}, "el">;
|
|
9
|
+
type NavGroup = ReturnType<typeof NavGroup>;
|
|
10
|
+
export default NavGroup;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
baseClasses,
|
|
4
|
+
type ShapeProp,
|
|
5
|
+
type Size,
|
|
6
|
+
type SizeProp,
|
|
7
|
+
} from "../base.js";
|
|
8
|
+
import { cn, type ClassName, type ElementRef } from "../utils.js";
|
|
9
|
+
import type { LucideIcon } from "@lucide/svelte";
|
|
10
|
+
import type { Snippet } from "svelte";
|
|
11
|
+
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
12
|
+
|
|
13
|
+
export type NavItemProps = {
|
|
14
|
+
href: string;
|
|
15
|
+
current?: boolean;
|
|
16
|
+
icon?: LucideIcon;
|
|
17
|
+
children: Snippet;
|
|
18
|
+
} & ElementRef &
|
|
19
|
+
ClassName &
|
|
20
|
+
ShapeProp &
|
|
21
|
+
SizeProp &
|
|
22
|
+
Omit<HTMLAnchorAttributes, "href">;
|
|
23
|
+
|
|
24
|
+
const SIZES: Record<Size, string> = {
|
|
25
|
+
xs: "h-7 gap-2 px-3 text-xs",
|
|
26
|
+
sm: "h-9 gap-3 px-4 text-sm",
|
|
27
|
+
md: "h-11 gap-3 px-4 text-sm",
|
|
28
|
+
lg: "h-13 gap-3 px-4 text-base",
|
|
29
|
+
xl: "h-15 gap-4 px-5 text-base",
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
let {
|
|
35
|
+
href,
|
|
36
|
+
current = false,
|
|
37
|
+
icon: Icon,
|
|
38
|
+
children,
|
|
39
|
+
el = $bindable(),
|
|
40
|
+
class: className,
|
|
41
|
+
shape = "full",
|
|
42
|
+
size = "md",
|
|
43
|
+
...restProps
|
|
44
|
+
}: NavItemProps = $props();
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<!-- eslint-disable svelte/no-navigation-without-resolve -->
|
|
48
|
+
<a
|
|
49
|
+
bind:this={el}
|
|
50
|
+
{href}
|
|
51
|
+
aria-current={current ? "page" : undefined}
|
|
52
|
+
class={cn(
|
|
53
|
+
baseClasses({ shape }),
|
|
54
|
+
SIZES[size],
|
|
55
|
+
"flex shrink-0 items-center text-m3-on-surface-variant hover:bg-m3-on-surface/8 focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-m3-secondary aria-[current=page]:bg-m3-secondary-container aria-[current=page]:font-medium aria-[current=page]:text-m3-on-secondary-container",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...restProps}
|
|
59
|
+
>
|
|
60
|
+
{#if Icon}
|
|
61
|
+
<Icon class="size-[1.25em] shrink-0" />
|
|
62
|
+
{/if}
|
|
63
|
+
{@render children()}
|
|
64
|
+
</a>
|
|
65
|
+
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ShapeProp, type SizeProp } from "../base.js";
|
|
2
|
+
import { type ClassName, type ElementRef } from "../utils.js";
|
|
3
|
+
import type { LucideIcon } from "@lucide/svelte";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
6
|
+
export type NavItemProps = {
|
|
7
|
+
href: string;
|
|
8
|
+
current?: boolean;
|
|
9
|
+
icon?: LucideIcon;
|
|
10
|
+
children: Snippet;
|
|
11
|
+
} & ElementRef & ClassName & ShapeProp & SizeProp & Omit<HTMLAnchorAttributes, "href">;
|
|
12
|
+
declare const NavItem: import("svelte").Component<NavItemProps, {}, "el">;
|
|
13
|
+
type NavItem = ReturnType<typeof NavItem>;
|
|
14
|
+
export default NavItem;
|