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
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ export * from "./markdown/index.js";
|
|
|
29
29
|
export * from "./menu/index.js";
|
|
30
30
|
export * from "./modal/index.js";
|
|
31
31
|
export * from "./popover/index.js";
|
|
32
|
-
export * from "./portal/index.js";
|
|
33
32
|
export * from "./progress/index.js";
|
|
34
33
|
export * from "./shortcut/index.js";
|
|
35
34
|
export * from "./skeleton/index.js";
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ export * from "./markdown/index.js";
|
|
|
29
29
|
export * from "./menu/index.js";
|
|
30
30
|
export * from "./modal/index.js";
|
|
31
31
|
export * from "./popover/index.js";
|
|
32
|
-
export * from "./portal/index.js";
|
|
33
32
|
export * from "./progress/index.js";
|
|
34
33
|
export * from "./shortcut/index.js";
|
|
35
34
|
export * from "./skeleton/index.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Color, type Shape } from "../base.js";
|
|
2
|
+
export declare const INPUT_VARIANTS: readonly ["outlined", "filled", "plain"];
|
|
3
|
+
export type InputVariant = (typeof INPUT_VARIANTS)[number];
|
|
4
|
+
export declare const fieldClasses: ({ variant, color, shape, }: {
|
|
5
|
+
variant: InputVariant;
|
|
6
|
+
color: Color;
|
|
7
|
+
shape: Shape;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { baseClasses } from "../base.js";
|
|
2
|
+
import { cn } from "../utils.js";
|
|
3
|
+
export const INPUT_VARIANTS = ["outlined", "filled", "plain"];
|
|
4
|
+
export const fieldClasses = ({ variant, color, shape, }) => cn("min-w-0 bg-transparent placeholder:text-m3-on-surface-variant focus-visible:outline-2 disabled:cursor-not-allowed disabled:text-m3-on-surface/38 disabled:placeholder:text-m3-on-surface/38", variant === "outlined" &&
|
|
5
|
+
"bg-m3-surface-container-lowest outline-1 outline-m3-outline hover:outline-m3-on-surface disabled:outline-m3-on-surface/12", variant === "filled" &&
|
|
6
|
+
"border-b border-m3-on-surface-variant bg-m3-surface-container-highest hover:border-m3-on-surface disabled:border-m3-on-surface/38 disabled:bg-m3-on-surface/4", color === "primary" && "focus-visible:outline-m3-primary", color === "secondary" && "focus-visible:outline-m3-secondary", color === "tertiary" && "focus-visible:outline-m3-tertiary", color === "error" && "focus-visible:outline-m3-error", (color === "plain" || color === "inherit") &&
|
|
7
|
+
"focus-visible:outline-current", "user-invalid:border-m3-error user-invalid:outline-m3-error user-invalid:focus-visible:outline-m3-error aria-invalid:border-m3-error aria-invalid:outline-m3-error", baseClasses({ shape }));
|
package/dist/input/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { INPUT_VARIANTS, type InputVariant } from "./field.js";
|
|
2
|
+
export { default as Input, type InputProps } from "./input.svelte";
|
package/dist/input/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { INPUT_VARIANTS } from "./field.js";
|
|
2
|
+
export { default as Input } from "./input.svelte";
|
package/dist/input/input.svelte
CHANGED
|
@@ -1,54 +1,36 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
SIZES,
|
|
6
|
-
type Color,
|
|
7
|
-
type ColorProp,
|
|
8
|
-
type Radius,
|
|
9
|
-
type RadiusProp,
|
|
10
|
-
type Size,
|
|
11
|
-
type SizeProp,
|
|
12
|
-
} from "../base.js";
|
|
13
|
-
import { noop, type ClassName, type ElementRef } from "../utils.js";
|
|
2
|
+
import type { ColorProp, ShapeProp, Size, SizeProp } from "../base.js";
|
|
3
|
+
import { fieldClasses, type InputVariant } from "./field.js";
|
|
4
|
+
import { cn, type ClassName } from "../utils.js";
|
|
14
5
|
import type { HTMLInputAttributes } from "svelte/elements";
|
|
15
|
-
import { twMerge } from "tailwind-merge";
|
|
16
6
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type InputProps = ElementRef &
|
|
34
|
-
ClassName &
|
|
35
|
-
InputVariantProp &
|
|
36
|
-
InputSizeProp &
|
|
37
|
-
InputRadiusProp &
|
|
38
|
-
InputColorProp &
|
|
39
|
-
Omit<HTMLInputAttributes, "size">;
|
|
7
|
+
export type InputProps = {
|
|
8
|
+
variant?: InputVariant;
|
|
9
|
+
el?: HTMLInputElement;
|
|
10
|
+
} & ClassName &
|
|
11
|
+
ColorProp &
|
|
12
|
+
SizeProp &
|
|
13
|
+
ShapeProp &
|
|
14
|
+
Omit<HTMLInputAttributes, "size" | "class">;
|
|
15
|
+
|
|
16
|
+
const SIZES: Record<Size, string> = {
|
|
17
|
+
xs: "h-7 px-2.5 text-xs",
|
|
18
|
+
sm: "h-9 px-3 text-sm",
|
|
19
|
+
md: "h-11 px-3.5 text-base",
|
|
20
|
+
lg: "h-13 px-4 text-lg",
|
|
21
|
+
xl: "h-15 px-5 text-xl",
|
|
22
|
+
};
|
|
40
23
|
</script>
|
|
41
24
|
|
|
42
25
|
<script lang="ts">
|
|
43
26
|
let {
|
|
44
27
|
value = $bindable(),
|
|
45
28
|
el = $bindable(),
|
|
46
|
-
ref = noop,
|
|
47
29
|
class: className,
|
|
48
30
|
variant = "outlined",
|
|
49
31
|
color = "primary",
|
|
50
32
|
size = "sm",
|
|
51
|
-
|
|
33
|
+
shape = "xs",
|
|
52
34
|
...restProps
|
|
53
35
|
}: InputProps = $props();
|
|
54
36
|
</script>
|
|
@@ -56,33 +38,6 @@
|
|
|
56
38
|
<input
|
|
57
39
|
bind:value
|
|
58
40
|
bind:this={el}
|
|
59
|
-
|
|
60
|
-
class={twMerge(
|
|
61
|
-
"disabled:cursor-not-allowed disabled:bg-m3-on-surface/12 disabled:text-m3-on-surface/38",
|
|
62
|
-
|
|
63
|
-
variant === "outlined" &&
|
|
64
|
-
"bg-m3-surface-container-lowest outline-1 outline-m3-outline-variant hover:outline-m3-outline/80 disabled:hover:outline-m3-outline-variant",
|
|
65
|
-
variant === "filled" &&
|
|
66
|
-
"bg-m3-surface-container hover:bg-m3-surface-container-high focus:outline-1",
|
|
67
|
-
|
|
68
|
-
color === "primary" && "focus-visible:outline-m3-primary",
|
|
69
|
-
color === "secondary" && "focus-visible:outline-m3-secondary",
|
|
70
|
-
color === "tertiary" && "focus-visible:outline-m3-tertiary",
|
|
71
|
-
color === "error" && "focus-visible:outline-m3-error",
|
|
72
|
-
|
|
73
|
-
size === "xs" && "px-2.5 py-1.5 text-xs",
|
|
74
|
-
size === "sm" && "px-3 py-1.5 text-sm",
|
|
75
|
-
size === "md" && "px-3.5 py-2 text-base",
|
|
76
|
-
size === "lg" && "px-4 py-2.5 text-lg",
|
|
77
|
-
size === "xl" && "px-5 py-4 text-xl",
|
|
78
|
-
|
|
79
|
-
radius == "xs" && "rounded-xs",
|
|
80
|
-
radius == "sm" && "rounded-sm",
|
|
81
|
-
radius == "md" && "rounded-lg",
|
|
82
|
-
radius == "lg" && "rounded-2xl",
|
|
83
|
-
radius == "xl" && "rounded-4xl",
|
|
84
|
-
|
|
85
|
-
className,
|
|
86
|
-
)}
|
|
41
|
+
class={cn(fieldClasses({ variant, color, shape }), SIZES[size], className)}
|
|
87
42
|
{...restProps}
|
|
88
43
|
/>
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type
|
|
1
|
+
import type { ColorProp, ShapeProp, SizeProp } from "../base.js";
|
|
2
|
+
import { type InputVariant } from "./field.js";
|
|
3
|
+
import { type ClassName } from "../utils.js";
|
|
3
4
|
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
-
export
|
|
5
|
-
export type InputVariant = (typeof INPUT_VARIANTS)[number];
|
|
6
|
-
export type InputVariantProp = {
|
|
5
|
+
export type InputProps = {
|
|
7
6
|
variant?: InputVariant;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type InputColor = Color;
|
|
11
|
-
export type InputColorProp = ColorProp;
|
|
12
|
-
export declare const INPUT_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
13
|
-
export type InputSize = Size;
|
|
14
|
-
export type InputSizeProp = SizeProp;
|
|
15
|
-
export declare const INPUT_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "full"];
|
|
16
|
-
export type InputRadius = Radius;
|
|
17
|
-
export type InputRadiusProp = RadiusProp;
|
|
18
|
-
export type InputProps = ElementRef & ClassName & InputVariantProp & InputSizeProp & InputRadiusProp & InputColorProp & Omit<HTMLInputAttributes, "size">;
|
|
7
|
+
el?: HTMLInputElement;
|
|
8
|
+
} & ClassName & ColorProp & SizeProp & ShapeProp & Omit<HTMLInputAttributes, "size" | "class">;
|
|
19
9
|
declare const Input: import("svelte").Component<InputProps, {}, "el" | "value">;
|
|
20
10
|
type Input = ReturnType<typeof Input>;
|
|
21
11
|
export default Input;
|
package/dist/link/link.svelte
CHANGED
|
@@ -1,61 +1,52 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
baseClasses,
|
|
4
|
+
type ColorProp,
|
|
5
|
+
type UnderlineProp,
|
|
6
|
+
} from "../base.js";
|
|
7
|
+
import { cn, type ClassName, type ElementRef } from "../utils.js";
|
|
4
8
|
import type { Snippet } from "svelte";
|
|
5
|
-
import type {
|
|
6
|
-
HTMLAnchorAttributes,
|
|
7
|
-
HTMLButtonAttributes,
|
|
8
|
-
} from "svelte/elements";
|
|
9
|
-
import { twMerge } from "tailwind-merge";
|
|
9
|
+
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
10
10
|
|
|
11
11
|
export type LinkProps = {
|
|
12
|
+
href: string;
|
|
12
13
|
children: Snippet;
|
|
13
14
|
} & ElementRef &
|
|
14
15
|
ClassName &
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
HTMLAnchorAttributes
|
|
16
|
+
ColorProp &
|
|
17
|
+
UnderlineProp &
|
|
18
|
+
Omit<HTMLAnchorAttributes, "href">;
|
|
18
19
|
</script>
|
|
19
20
|
|
|
20
21
|
<script lang="ts">
|
|
21
22
|
let {
|
|
23
|
+
href,
|
|
22
24
|
children,
|
|
23
25
|
el = $bindable(),
|
|
24
|
-
ref = noop,
|
|
25
26
|
class: className,
|
|
26
|
-
variant = "text",
|
|
27
27
|
color = "primary",
|
|
28
|
-
|
|
29
|
-
underline = "hover",
|
|
30
|
-
href,
|
|
28
|
+
underline = "always",
|
|
31
29
|
...props
|
|
32
30
|
}: LinkProps = $props();
|
|
33
|
-
|
|
34
|
-
const classes = $derived(
|
|
35
|
-
twMerge(
|
|
36
|
-
baseClasses({
|
|
37
|
-
variant,
|
|
38
|
-
color,
|
|
39
|
-
shape,
|
|
40
|
-
underline,
|
|
41
|
-
hover: true,
|
|
42
|
-
focus: true,
|
|
43
|
-
}),
|
|
44
|
-
variant !== "text" &&
|
|
45
|
-
"flex h-9 items-center justify-center gap-2 text-nowrap transition-all active:scale-95",
|
|
46
|
-
"cursor-pointer",
|
|
47
|
-
className,
|
|
48
|
-
),
|
|
49
|
-
);
|
|
50
31
|
</script>
|
|
51
32
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
<!-- eslint-disable svelte/no-navigation-without-resolve -->
|
|
34
|
+
<a
|
|
35
|
+
bind:this={el}
|
|
36
|
+
{href}
|
|
37
|
+
class={cn(
|
|
38
|
+
baseClasses({
|
|
39
|
+
variant: "text",
|
|
40
|
+
color,
|
|
41
|
+
shape: "xs",
|
|
42
|
+
underline,
|
|
43
|
+
hover: true,
|
|
44
|
+
focus: true,
|
|
45
|
+
}),
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{@render children()}
|
|
51
|
+
</a>
|
|
52
|
+
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ColorProp, type UnderlineProp } from "../base.js";
|
|
2
2
|
import { type ClassName, type ElementRef } from "../utils.js";
|
|
3
3
|
import type { Snippet } from "svelte";
|
|
4
|
-
import type { HTMLAnchorAttributes
|
|
4
|
+
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
5
5
|
export type LinkProps = {
|
|
6
|
+
href: string;
|
|
6
7
|
children: Snippet;
|
|
7
|
-
} & ElementRef & ClassName &
|
|
8
|
+
} & ElementRef & ClassName & ColorProp & UnderlineProp & Omit<HTMLAnchorAttributes, "href">;
|
|
8
9
|
declare const Link: import("svelte").Component<LinkProps, {}, "el">;
|
|
9
10
|
type Link = ReturnType<typeof Link>;
|
|
10
11
|
export default Link;
|
package/dist/markdown/index.d.ts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export {
|
|
3
|
-
export { default as MarkdownCode } from "./markdown-code.svelte";
|
|
4
|
-
export { default as MarkdownCodespan } from "./markdown-codespan.svelte";
|
|
5
|
-
export { getMarkdownContext, MarkdownContext, setMarkdownContext, type MarkdownComponentProps, } from "./markdown-context.svelte";
|
|
6
|
-
export { default as MarkdownDef } from "./markdown-def.svelte";
|
|
7
|
-
export { default as MarkdownDel } from "./markdown-del.svelte";
|
|
8
|
-
export { default as MarkdownEm } from "./markdown-em.svelte";
|
|
9
|
-
export { default as MarkdownEscape } from "./markdown-escape.svelte";
|
|
10
|
-
export { default as MarkdownHeading } from "./markdown-heading.svelte";
|
|
11
|
-
export { default as MarkdownHr } from "./markdown-hr.svelte";
|
|
12
|
-
export { default as MarkdownHtml } from "./markdown-html.svelte";
|
|
13
|
-
export { default as MarkdownImage } from "./markdown-image.svelte";
|
|
14
|
-
export { default as MarkdownLink } from "./markdown-link.svelte";
|
|
15
|
-
export { default as MarkdownListItem } from "./markdown-list-item.svelte";
|
|
16
|
-
export { default as MarkdownList } from "./markdown-list.svelte";
|
|
17
|
-
export { default as MarkdownParagraph } from "./markdown-paragraph.svelte";
|
|
18
|
-
export { default as MarkdownSpace } from "./markdown-space.svelte";
|
|
19
|
-
export { default as MarkdownStrong } from "./markdown-strong.svelte";
|
|
20
|
-
export { default as MarkdownTableCell } from "./markdown-table-cell.svelte";
|
|
21
|
-
export { default as MarkdownTable } from "./markdown-table.svelte";
|
|
22
|
-
export { default as MarkdownText } from "./markdown-text.svelte";
|
|
23
|
-
export { default as MarkdownToken } from "./markdown-token.svelte";
|
|
24
|
-
export { default as MarkdownTokens } from "./markdown-tokens.svelte";
|
|
25
|
-
export { default as Markdown } from "./markdown.svelte";
|
|
1
|
+
export { default as Markdown, type MarkdownProps } from "./markdown.svelte";
|
|
2
|
+
export type { MarkdownRenderers, MarkdownSnippetProps } from "./types.js";
|
package/dist/markdown/index.js
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
export { default as MarkdownBlockquote } from "./markdown-blockquote.svelte";
|
|
2
|
-
export { default as MarkdownBr } from "./markdown-br.svelte";
|
|
3
|
-
export { default as MarkdownCode } from "./markdown-code.svelte";
|
|
4
|
-
export { default as MarkdownCodespan } from "./markdown-codespan.svelte";
|
|
5
|
-
export { getMarkdownContext, MarkdownContext, setMarkdownContext, } from "./markdown-context.svelte";
|
|
6
|
-
export { default as MarkdownDef } from "./markdown-def.svelte";
|
|
7
|
-
export { default as MarkdownDel } from "./markdown-del.svelte";
|
|
8
|
-
export { default as MarkdownEm } from "./markdown-em.svelte";
|
|
9
|
-
export { default as MarkdownEscape } from "./markdown-escape.svelte";
|
|
10
|
-
export { default as MarkdownHeading } from "./markdown-heading.svelte";
|
|
11
|
-
export { default as MarkdownHr } from "./markdown-hr.svelte";
|
|
12
|
-
export { default as MarkdownHtml } from "./markdown-html.svelte";
|
|
13
|
-
export { default as MarkdownImage } from "./markdown-image.svelte";
|
|
14
|
-
export { default as MarkdownLink } from "./markdown-link.svelte";
|
|
15
|
-
export { default as MarkdownListItem } from "./markdown-list-item.svelte";
|
|
16
|
-
export { default as MarkdownList } from "./markdown-list.svelte";
|
|
17
|
-
export { default as MarkdownParagraph } from "./markdown-paragraph.svelte";
|
|
18
|
-
export { default as MarkdownSpace } from "./markdown-space.svelte";
|
|
19
|
-
export { default as MarkdownStrong } from "./markdown-strong.svelte";
|
|
20
|
-
export { default as MarkdownTableCell } from "./markdown-table-cell.svelte";
|
|
21
|
-
export { default as MarkdownTable } from "./markdown-table.svelte";
|
|
22
|
-
export { default as MarkdownText } from "./markdown-text.svelte";
|
|
23
|
-
export { default as MarkdownToken } from "./markdown-token.svelte";
|
|
24
|
-
export { default as MarkdownTokens } from "./markdown-tokens.svelte";
|
|
25
1
|
export { default as Markdown } from "./markdown.svelte";
|
|
@@ -1,13 +1,173 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Link } from "../link/index.js";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
import type { MarkedToken, Tokens } from "marked";
|
|
5
|
+
import type { Snippet } from "svelte";
|
|
6
|
+
import type { MarkdownRenderers, MarkdownSnippetProps } from "./types.js";
|
|
4
7
|
|
|
5
8
|
export type MarkdownTokensProps = {
|
|
6
9
|
tokens: MarkedToken[];
|
|
10
|
+
renderers: MarkdownRenderers;
|
|
7
11
|
};
|
|
8
|
-
|
|
12
|
+
|
|
13
|
+
type AnyRenderer = Snippet<[MarkdownSnippetProps<MarkedToken>]>;
|
|
14
|
+
|
|
15
|
+
const HEADINGS = ["text-2xl", "text-xl", "text-lg"];
|
|
16
|
+
|
|
17
|
+
function rendererFor(token: MarkedToken, renderers: MarkdownRenderers) {
|
|
18
|
+
const name = token.type === "list_item" ? "listItem" : token.type;
|
|
19
|
+
return (renderers as Record<string, AnyRenderer | undefined>)[name];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function language(info: string | undefined) {
|
|
23
|
+
const name = info?.split(/\s/)[0];
|
|
24
|
+
return name ? `language-${name}` : undefined;
|
|
25
|
+
}
|
|
9
26
|
</script>
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import Self from "./markdown-tokens.svelte";
|
|
30
|
+
|
|
31
|
+
let { tokens, renderers }: MarkdownTokensProps = $props();
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
{#snippet cell(token: Tokens.TableCell)}
|
|
35
|
+
{#snippet children()}
|
|
36
|
+
<Self tokens={token.tokens as MarkedToken[]} {renderers} />
|
|
37
|
+
{/snippet}
|
|
38
|
+
{#if renderers.tableCell}
|
|
39
|
+
{@render renderers.tableCell({ token, children })}
|
|
40
|
+
{:else}
|
|
41
|
+
<svelte:element
|
|
42
|
+
this={token.header ? "th" : "td"}
|
|
43
|
+
style:text-align={token.align}
|
|
44
|
+
class={cn(
|
|
45
|
+
"border border-m3-outline-variant px-3 py-1.5 text-start",
|
|
46
|
+
token.header && "bg-m3-surface-container font-medium",
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
{@render children()}
|
|
50
|
+
</svelte:element>
|
|
51
|
+
{/if}
|
|
52
|
+
{/snippet}
|
|
53
|
+
|
|
54
|
+
{#snippet defaultRenderer({
|
|
55
|
+
token,
|
|
56
|
+
children,
|
|
57
|
+
}: MarkdownSnippetProps<MarkedToken>)}
|
|
58
|
+
{#if token.type === "blockquote"}
|
|
59
|
+
<blockquote
|
|
60
|
+
class="flex flex-col gap-3 border-l-4 border-m3-outline-variant pl-4 text-m3-on-surface-variant"
|
|
61
|
+
>
|
|
62
|
+
{@render children()}
|
|
63
|
+
</blockquote>
|
|
64
|
+
{:else if token.type === "br"}
|
|
65
|
+
<br />
|
|
66
|
+
{:else if token.type === "checkbox"}
|
|
67
|
+
<input
|
|
68
|
+
type="checkbox"
|
|
69
|
+
checked={token.checked}
|
|
70
|
+
disabled
|
|
71
|
+
class="mr-2 size-4 align-[-0.125em] accent-m3-primary"
|
|
72
|
+
/>
|
|
73
|
+
{:else if token.type === "code"}
|
|
74
|
+
<pre
|
|
75
|
+
class="overflow-x-auto rounded-md bg-m3-surface-container p-3 text-sm"><code
|
|
76
|
+
class={language(token.lang)}>{token.text}</code
|
|
77
|
+
></pre>
|
|
78
|
+
{:else if token.type === "codespan"}
|
|
79
|
+
<code class="rounded-sm bg-m3-surface-container px-1 py-0.5 text-[0.875em]"
|
|
80
|
+
>{token.text}</code
|
|
81
|
+
>
|
|
82
|
+
{:else if token.type === "del"}
|
|
83
|
+
<del>{@render children()}</del>
|
|
84
|
+
{:else if token.type === "em"}
|
|
85
|
+
<em>{@render children()}</em>
|
|
86
|
+
{:else if token.type === "heading"}
|
|
87
|
+
<svelte:element
|
|
88
|
+
this={`h${token.depth}`}
|
|
89
|
+
class={cn("font-medium", HEADINGS[token.depth - 1] ?? "text-base")}
|
|
90
|
+
>
|
|
91
|
+
{@render children()}
|
|
92
|
+
</svelte:element>
|
|
93
|
+
{:else if token.type === "hr"}
|
|
94
|
+
<hr class="border-m3-outline-variant" />
|
|
95
|
+
{:else if token.type === "image"}
|
|
96
|
+
{#if token.href}
|
|
97
|
+
<img
|
|
98
|
+
src={token.href}
|
|
99
|
+
alt={token.text}
|
|
100
|
+
title={token.title}
|
|
101
|
+
loading="lazy"
|
|
102
|
+
class="inline max-w-full"
|
|
103
|
+
/>
|
|
104
|
+
{:else}
|
|
105
|
+
{token.text}
|
|
106
|
+
{/if}
|
|
107
|
+
{:else if token.type === "link"}
|
|
108
|
+
{#if token.href}
|
|
109
|
+
<Link href={token.href} title={token.title}>{@render children()}</Link>
|
|
110
|
+
{:else}
|
|
111
|
+
{@render children()}
|
|
112
|
+
{/if}
|
|
113
|
+
{:else if token.type === "list"}
|
|
114
|
+
<svelte:element
|
|
115
|
+
this={token.ordered ? "ol" : "ul"}
|
|
116
|
+
start={token.ordered && token.start !== 1
|
|
117
|
+
? token.start || undefined
|
|
118
|
+
: undefined}
|
|
119
|
+
class={cn("space-y-1 pl-6", token.ordered ? "list-decimal" : "list-disc")}
|
|
120
|
+
>
|
|
121
|
+
{@render children()}
|
|
122
|
+
</svelte:element>
|
|
123
|
+
{:else if token.type === "list_item"}
|
|
124
|
+
<li class={cn("space-y-2", token.task && "list-none")}>
|
|
125
|
+
{@render children()}
|
|
126
|
+
</li>
|
|
127
|
+
{:else if token.type === "paragraph"}
|
|
128
|
+
<p>{@render children()}</p>
|
|
129
|
+
{:else if token.type === "strong"}
|
|
130
|
+
<strong>{@render children()}</strong>
|
|
131
|
+
{:else if token.type === "table"}
|
|
132
|
+
<div class="overflow-x-auto">
|
|
133
|
+
<table class="border-collapse text-sm">
|
|
134
|
+
{@render children()}
|
|
135
|
+
</table>
|
|
136
|
+
</div>
|
|
137
|
+
{:else if token.type !== "def" && token.type !== "space"}
|
|
138
|
+
{@render children()}
|
|
139
|
+
{/if}
|
|
140
|
+
{/snippet}
|
|
141
|
+
|
|
142
|
+
{#each tokens as token, index (index)}
|
|
143
|
+
{#snippet children()}
|
|
144
|
+
{#if token.type === "list"}
|
|
145
|
+
<Self tokens={token.items as MarkedToken[]} {renderers} />
|
|
146
|
+
{:else if token.type === "table"}
|
|
147
|
+
<thead>
|
|
148
|
+
<tr>
|
|
149
|
+
{#each token.header as header, column (column)}
|
|
150
|
+
{@render cell(header)}
|
|
151
|
+
{/each}
|
|
152
|
+
</tr>
|
|
153
|
+
</thead>
|
|
154
|
+
<tbody>
|
|
155
|
+
{#each token.rows as row, rowIndex (rowIndex)}
|
|
156
|
+
<tr>
|
|
157
|
+
{#each row as data, column (column)}
|
|
158
|
+
{@render cell(data)}
|
|
159
|
+
{/each}
|
|
160
|
+
</tr>
|
|
161
|
+
{/each}
|
|
162
|
+
</tbody>
|
|
163
|
+
{:else if "tokens" in token && token.tokens}
|
|
164
|
+
<Self tokens={token.tokens as MarkedToken[]} {renderers} />
|
|
165
|
+
{:else if "text" in token}
|
|
166
|
+
{token.text}
|
|
167
|
+
{/if}
|
|
168
|
+
{/snippet}
|
|
169
|
+
{@render (rendererFor(token, renderers) ?? defaultRenderer)({
|
|
170
|
+
token,
|
|
171
|
+
children,
|
|
172
|
+
})}
|
|
13
173
|
{/each}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { MarkedToken } from "marked";
|
|
2
|
+
import type { MarkdownRenderers } from "./types.js";
|
|
2
3
|
export type MarkdownTokensProps = {
|
|
3
4
|
tokens: MarkedToken[];
|
|
5
|
+
renderers: MarkdownRenderers;
|
|
4
6
|
};
|
|
5
7
|
declare const MarkdownTokens: import("svelte").Component<MarkdownTokensProps, {}, "">;
|
|
6
8
|
type MarkdownTokens = ReturnType<typeof MarkdownTokens>;
|