kosui 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -3
- package/dist/alert/alert.svelte +16 -157
- package/dist/alert/alert.svelte.d.ts +3 -26
- package/dist/alert/index.d.ts +1 -1
- package/dist/alert/index.js +1 -1
- package/dist/autocomplete/autocomplete.svelte +126 -12
- package/dist/autocomplete/autocomplete.svelte.d.ts +30 -6
- package/dist/autocomplete/index.d.ts +1 -5
- package/dist/autocomplete/index.js +1 -5
- package/dist/avatar/avatar.svelte +16 -10
- package/dist/badge/badge.svelte +31 -20
- package/dist/badge/badge.svelte.d.ts +8 -4
- package/dist/badge/index.d.ts +1 -1
- package/dist/base.d.ts +4 -8
- package/dist/base.js +14 -28
- package/dist/box/box.svelte +2 -14
- package/dist/box/box.svelte.d.ts +0 -2
- package/dist/breadcrumbs/breadcrumbs.svelte +38 -19
- package/dist/breadcrumbs/breadcrumbs.svelte.d.ts +6 -4
- package/dist/breadcrumbs/index.d.ts +1 -1
- package/dist/breadcrumbs/index.js +1 -1
- package/dist/button/button.svelte +96 -31
- package/dist/button/button.svelte.d.ts +11 -5
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.js +1 -1
- package/dist/chip/chip.svelte +62 -14
- package/dist/chip/chip.svelte.d.ts +2 -1
- package/dist/command/action.svelte.js +13 -18
- package/dist/command/command-palette.svelte +163 -0
- package/dist/command/command-palette.svelte.d.ts +11 -0
- package/dist/command/index.d.ts +1 -8
- package/dist/command/index.js +1 -8
- package/dist/common/divider.svelte +10 -5
- package/dist/common/divider.svelte.d.ts +3 -3
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.js +0 -2
- package/dist/dialog/dialog-provider.svelte +70 -0
- package/dist/dialog/dialog-provider.svelte.d.ts +7 -0
- package/dist/dialog/dialog.svelte +33 -35
- package/dist/dialog/dialog.svelte.d.ts +4 -8
- package/dist/dialog/dialogs.svelte.d.ts +49 -0
- package/dist/dialog/dialogs.svelte.js +73 -0
- package/dist/dialog/index.d.ts +2 -3
- package/dist/dialog/index.js +2 -3
- package/dist/drawer/drawer.svelte +51 -0
- package/dist/drawer/drawer.svelte.d.ts +8 -0
- package/dist/drawer/index.d.ts +1 -0
- package/dist/drawer/index.js +1 -0
- package/dist/fab/fab.svelte +30 -10
- package/dist/fab/fab.svelte.d.ts +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/input/field.d.ts +8 -0
- package/dist/input/field.js +7 -0
- package/dist/input/index.d.ts +2 -1
- package/dist/input/index.js +2 -1
- package/dist/input/input.svelte +21 -66
- package/dist/input/input.svelte.d.ts +6 -16
- package/dist/link/link.svelte +33 -42
- package/dist/link/link.svelte.d.ts +4 -3
- package/dist/markdown/index.d.ts +2 -25
- package/dist/markdown/index.js +0 -24
- package/dist/markdown/markdown-tokens.svelte +166 -6
- package/dist/markdown/markdown-tokens.svelte.d.ts +2 -0
- package/dist/markdown/markdown.svelte +62 -173
- package/dist/markdown/markdown.svelte.d.ts +7 -27
- package/dist/markdown/parse.d.ts +5 -0
- package/dist/markdown/parse.js +30 -0
- package/dist/markdown/types.d.ts +28 -0
- package/dist/markdown/types.js +1 -0
- package/dist/menu/index.d.ts +3 -6
- package/dist/menu/index.js +3 -6
- package/dist/menu/menu-actions.svelte +44 -38
- package/dist/menu/menu-context.d.ts +4 -0
- package/dist/menu/menu-context.js +2 -0
- package/dist/menu/menu-group.svelte +40 -0
- package/dist/menu/menu-group.svelte.d.ts +11 -0
- package/dist/menu/menu-item.svelte +31 -54
- package/dist/menu/menu-item.svelte.d.ts +7 -5
- package/dist/menu/menu.svelte +160 -15
- package/dist/menu/menu.svelte.d.ts +15 -4
- package/dist/merge-props.d.ts +1 -1
- package/dist/merge-props.js +10 -5
- package/dist/modal/modal.svelte +67 -84
- package/dist/modal/modal.svelte.d.ts +7 -4
- package/dist/nav/index.d.ts +2 -0
- package/dist/nav/index.js +2 -0
- package/dist/nav/nav-group.svelte +40 -0
- package/dist/nav/nav-group.svelte.d.ts +10 -0
- package/dist/nav/nav-item.svelte +65 -0
- package/dist/nav/nav-item.svelte.d.ts +14 -0
- package/dist/popover/index.d.ts +1 -1
- package/dist/popover/index.js +1 -1
- package/dist/popover/popover.svelte +58 -111
- package/dist/popover/popover.svelte.d.ts +6 -8
- package/dist/progress/circular-progress.svelte +64 -30
- package/dist/progress/circular-progress.svelte.d.ts +7 -8
- package/dist/shortcut/index.d.ts +2 -2
- package/dist/shortcut/index.js +1 -1
- package/dist/shortcut/shortcut-hint.svelte +36 -0
- package/dist/shortcut/shortcut-hint.svelte.d.ts +9 -0
- package/dist/shortcut/shortcut.d.ts +19 -14
- package/dist/shortcut/shortcut.js +105 -52
- package/dist/skeleton/skeleton.svelte +13 -8
- package/dist/skeleton/skeleton.svelte.d.ts +2 -5
- package/dist/slider/index.d.ts +1 -8
- package/dist/slider/index.js +1 -8
- package/dist/slider/slider.svelte +180 -211
- package/dist/slider/slider.svelte.d.ts +11 -32
- package/dist/switch/index.d.ts +1 -2
- package/dist/switch/index.js +1 -2
- package/dist/switch/switch.svelte +36 -60
- package/dist/switch/switch.svelte.d.ts +6 -17
- package/dist/textarea/index.d.ts +1 -1
- package/dist/textarea/index.js +1 -1
- package/dist/textarea/textarea.svelte +23 -63
- package/dist/textarea/textarea.svelte.d.ts +8 -18
- package/dist/theme.css +191 -0
- package/dist/toggle/index.d.ts +0 -1
- package/dist/toggle/index.js +0 -1
- package/dist/toggle/toggle-button.svelte +72 -38
- package/dist/toggle/toggle-button.svelte.d.ts +4 -4
- package/dist/toggle/toggle-context.d.ts +10 -0
- package/dist/toggle/toggle-context.js +2 -0
- package/dist/toggle/toggle-group.svelte +41 -22
- package/dist/toggle/toggle-group.svelte.d.ts +7 -4
- package/dist/tooltip/tooltip.svelte +67 -26
- package/dist/tooltip/tooltip.svelte.d.ts +10 -4
- package/dist/utils.d.ts +9 -3
- package/dist/utils.js +10 -0
- package/package.json +6 -5
- package/dist/autocomplete/autocomplete-content.svelte +0 -47
- package/dist/autocomplete/autocomplete-content.svelte.d.ts +0 -10
- package/dist/autocomplete/autocomplete-context.svelte.d.ts +0 -12
- package/dist/autocomplete/autocomplete-context.svelte.js +0 -34
- package/dist/autocomplete/autocomplete-input.svelte +0 -36
- package/dist/autocomplete/autocomplete-input.svelte.d.ts +0 -5
- package/dist/autocomplete/autocomplete-item.svelte +0 -68
- package/dist/autocomplete/autocomplete-item.svelte.d.ts +0 -11
- package/dist/base.css +0 -71
- package/dist/bindable.svelte.d.ts +0 -7
- package/dist/bindable.svelte.js +0 -25
- package/dist/command/command-content.svelte +0 -15
- package/dist/command/command-content.svelte.d.ts +0 -8
- package/dist/command/command-context.svelte.d.ts +0 -5
- package/dist/command/command-context.svelte.js +0 -13
- package/dist/command/command-input.svelte +0 -44
- package/dist/command/command-input.svelte.d.ts +0 -7
- package/dist/command/command-item.svelte +0 -66
- package/dist/command/command-item.svelte.d.ts +0 -11
- package/dist/command/command-search.svelte +0 -28
- package/dist/command/command-search.svelte.d.ts +0 -5
- package/dist/command/command.svelte +0 -19
- package/dist/command/command.svelte.d.ts +0 -8
- package/dist/command/commander.svelte +0 -107
- package/dist/command/commander.svelte.d.ts +0 -9
- package/dist/common/header.svelte +0 -35
- package/dist/common/header.svelte.d.ts +0 -10
- package/dist/common/item-context.svelte.d.ts +0 -12
- package/dist/common/item-context.svelte.js +0 -77
- package/dist/dialog/dialog-button.svelte +0 -25
- package/dist/dialog/dialog-button.svelte.d.ts +0 -32
- package/dist/dialog/dialoguer-context.svelte.d.ts +0 -53
- package/dist/dialog/dialoguer-context.svelte.js +0 -85
- package/dist/dialog/dialoguer.svelte +0 -65
- package/dist/dialog/dialoguer.svelte.d.ts +0 -7
- package/dist/markdown/markdown-blockquote.svelte +0 -14
- package/dist/markdown/markdown-blockquote.svelte.d.ts +0 -7
- package/dist/markdown/markdown-br.svelte +0 -12
- package/dist/markdown/markdown-br.svelte.d.ts +0 -7
- package/dist/markdown/markdown-code.svelte +0 -14
- package/dist/markdown/markdown-code.svelte.d.ts +0 -7
- package/dist/markdown/markdown-codespan.svelte +0 -15
- package/dist/markdown/markdown-codespan.svelte.d.ts +0 -7
- package/dist/markdown/markdown-context.svelte.d.ts +0 -26
- package/dist/markdown/markdown-context.svelte.js +0 -31
- package/dist/markdown/markdown-def.svelte +0 -15
- package/dist/markdown/markdown-def.svelte.d.ts +0 -7
- package/dist/markdown/markdown-del.svelte +0 -14
- package/dist/markdown/markdown-del.svelte.d.ts +0 -7
- package/dist/markdown/markdown-em.svelte +0 -14
- package/dist/markdown/markdown-em.svelte.d.ts +0 -7
- package/dist/markdown/markdown-escape.svelte +0 -8
- package/dist/markdown/markdown-escape.svelte.d.ts +0 -5
- package/dist/markdown/markdown-heading.svelte +0 -16
- package/dist/markdown/markdown-heading.svelte.d.ts +0 -7
- package/dist/markdown/markdown-hr.svelte +0 -12
- package/dist/markdown/markdown-hr.svelte.d.ts +0 -7
- package/dist/markdown/markdown-html.svelte +0 -9
- package/dist/markdown/markdown-html.svelte.d.ts +0 -5
- package/dist/markdown/markdown-image.svelte +0 -12
- package/dist/markdown/markdown-image.svelte.d.ts +0 -7
- package/dist/markdown/markdown-link.svelte +0 -17
- package/dist/markdown/markdown-link.svelte.d.ts +0 -7
- package/dist/markdown/markdown-list-item.svelte +0 -14
- package/dist/markdown/markdown-list-item.svelte.d.ts +0 -7
- package/dist/markdown/markdown-list.svelte +0 -19
- package/dist/markdown/markdown-list.svelte.d.ts +0 -7
- package/dist/markdown/markdown-paragraph.svelte +0 -16
- package/dist/markdown/markdown-paragraph.svelte.d.ts +0 -7
- package/dist/markdown/markdown-space.svelte +0 -8
- package/dist/markdown/markdown-space.svelte.d.ts +0 -5
- package/dist/markdown/markdown-strong.svelte +0 -15
- package/dist/markdown/markdown-strong.svelte.d.ts +0 -7
- package/dist/markdown/markdown-table-cell.svelte +0 -16
- package/dist/markdown/markdown-table-cell.svelte.d.ts +0 -7
- package/dist/markdown/markdown-table.svelte +0 -36
- package/dist/markdown/markdown-table.svelte.d.ts +0 -7
- package/dist/markdown/markdown-text.svelte +0 -8
- package/dist/markdown/markdown-text.svelte.d.ts +0 -5
- package/dist/markdown/markdown-token.svelte +0 -25
- package/dist/markdown/markdown-token.svelte.d.ts +0 -7
- package/dist/menu/menu-content.svelte +0 -47
- package/dist/menu/menu-content.svelte.d.ts +0 -10
- package/dist/menu/menu-context.svelte.d.ts +0 -18
- package/dist/menu/menu-context.svelte.js +0 -118
- package/dist/menu/menu-trigger-button.svelte +0 -31
- package/dist/menu/menu-trigger-button.svelte.d.ts +0 -5
- package/dist/menu/menu-trigger.svelte +0 -42
- package/dist/menu/menu-trigger.svelte.d.ts +0 -10
- package/dist/ordered-html-elements.d.ts +0 -7
- package/dist/ordered-html-elements.js +0 -29
- package/dist/portal/index.d.ts +0 -2
- package/dist/portal/index.js +0 -2
- package/dist/portal/portal.svelte +0 -15
- package/dist/portal/portal.svelte.d.ts +0 -8
- package/dist/portal/proxy.svelte +0 -13
- package/dist/portal/proxy.svelte.d.ts +0 -7
- package/dist/shortcut/shortcut-badge.svelte +0 -41
- package/dist/shortcut/shortcut-badge.svelte.d.ts +0 -11
- package/dist/slider/slider-context.svelte.d.ts +0 -50
- package/dist/slider/slider-context.svelte.js +0 -216
- package/dist/slider/slider-handle-label-arrow.svelte +0 -18
- package/dist/slider/slider-handle-label-arrow.svelte.d.ts +0 -6
- package/dist/slider/slider-handle-label.svelte +0 -35
- package/dist/slider/slider-handle-label.svelte.d.ts +0 -6
- package/dist/slider/slider-handle.svelte +0 -54
- package/dist/slider/slider-handle.svelte.d.ts +0 -6
- package/dist/slider/slider-mark-dot.svelte +0 -25
- package/dist/slider/slider-mark-dot.svelte.d.ts +0 -6
- package/dist/slider/slider-mark-label.svelte +0 -37
- package/dist/slider/slider-mark-label.svelte.d.ts +0 -9
- package/dist/slider/slider-mark.svelte +0 -33
- package/dist/slider/slider-mark.svelte.d.ts +0 -9
- package/dist/switch/switch-thumb.svelte +0 -52
- package/dist/switch/switch-thumb.svelte.d.ts +0 -7
- package/dist/toggle/toggle-context.svelte.d.ts +0 -9
- package/dist/toggle/toggle-context.svelte.js +0 -32
|
@@ -1,82 +1,42 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
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 type { ClassName } from "../utils.js";
|
|
2
|
+
import type { ColorProp, ShapeProp, Size, SizeProp } from "../base.js";
|
|
3
|
+
import { fieldClasses, type InputVariant } from "../input/field.js";
|
|
4
|
+
import { cn, type ClassName } from "../utils.js";
|
|
14
5
|
import type { HTMLTextareaAttributes } 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 TextareaProps = ClassName &
|
|
34
|
-
TextareaVariantProp &
|
|
35
|
-
TextareaSizeProp &
|
|
36
|
-
TextareaRadiusProp &
|
|
37
|
-
TextareaColorProp &
|
|
38
|
-
Omit<HTMLTextareaAttributes, "size">;
|
|
7
|
+
export type TextareaProps = {
|
|
8
|
+
variant?: InputVariant;
|
|
9
|
+
el?: HTMLTextAreaElement;
|
|
10
|
+
} & ClassName &
|
|
11
|
+
ColorProp &
|
|
12
|
+
SizeProp &
|
|
13
|
+
ShapeProp &
|
|
14
|
+
Omit<HTMLTextareaAttributes, "class">;
|
|
15
|
+
|
|
16
|
+
const SIZES: Record<Size, string> = {
|
|
17
|
+
xs: "px-2.5 py-1.5 text-xs",
|
|
18
|
+
sm: "px-3 py-2 text-sm",
|
|
19
|
+
md: "px-3.5 py-2.5 text-base",
|
|
20
|
+
lg: "px-4 py-3 text-lg",
|
|
21
|
+
xl: "px-5 py-4 text-xl",
|
|
22
|
+
};
|
|
39
23
|
</script>
|
|
40
24
|
|
|
41
25
|
<script lang="ts">
|
|
42
26
|
let {
|
|
43
27
|
value = $bindable(),
|
|
28
|
+
el = $bindable(),
|
|
44
29
|
class: className,
|
|
45
30
|
variant = "outlined",
|
|
46
31
|
color = "primary",
|
|
47
32
|
size = "sm",
|
|
48
|
-
|
|
33
|
+
shape = "xs",
|
|
49
34
|
...restProps
|
|
50
35
|
}: TextareaProps = $props();
|
|
51
36
|
</script>
|
|
52
37
|
|
|
53
38
|
<textarea
|
|
54
39
|
bind:value
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
variant === "outlined" &&
|
|
59
|
-
"bg-m3-surface-container-lowest outline-1 outline-m3-outline-variant hover:outline-m3-outline/80 disabled:hover:outline-m3-outline-variant",
|
|
60
|
-
variant === "filled" &&
|
|
61
|
-
"bg-m3-surface-container hover:bg-m3-surface-container-high focus:outline-1",
|
|
62
|
-
|
|
63
|
-
color === "primary" && "focus-visible:outline-m3-primary",
|
|
64
|
-
color === "secondary" && "focus-visible:outline-m3-secondary",
|
|
65
|
-
color === "tertiary" && "focus-visible:outline-m3-tertiary",
|
|
66
|
-
color === "error" && "focus-visible:outline-m3-error",
|
|
67
|
-
|
|
68
|
-
size === "xs" && "px-2.5 py-1.5 text-xs",
|
|
69
|
-
size === "sm" && "px-3 py-1.5 text-sm",
|
|
70
|
-
size === "md" && "px-3.5 py-2 text-base",
|
|
71
|
-
size === "lg" && "px-4 py-2.5 text-lg",
|
|
72
|
-
size === "xl" && "px-5 py-4 text-xl",
|
|
73
|
-
|
|
74
|
-
radius == "xs" && "rounded-xs",
|
|
75
|
-
radius == "sm" && "rounded-sm",
|
|
76
|
-
radius == "md" && "rounded-lg",
|
|
77
|
-
radius == "lg" && "rounded-2xl",
|
|
78
|
-
radius == "xl" && "rounded-4xl",
|
|
79
|
-
|
|
80
|
-
className,
|
|
81
|
-
)}
|
|
40
|
+
bind:this={el}
|
|
41
|
+
class={cn(fieldClasses({ variant, color, shape }), SIZES[size], className)}
|
|
82
42
|
{...restProps}></textarea>
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
1
|
+
import type { ColorProp, ShapeProp, SizeProp } from "../base.js";
|
|
2
|
+
import { type InputVariant } from "../input/field.js";
|
|
3
|
+
import { type ClassName } from "../utils.js";
|
|
3
4
|
import type { HTMLTextareaAttributes } from "svelte/elements";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export declare const TEXTAREA_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
10
|
-
export type TextareaColor = Color;
|
|
11
|
-
export type TextareaColorProp = ColorProp;
|
|
12
|
-
export declare const TEXTAREA_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
13
|
-
export type TextareaSize = Size;
|
|
14
|
-
export type TextareaSizeProp = SizeProp;
|
|
15
|
-
export declare const TEXTAREA_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "full"];
|
|
16
|
-
export type TextareaRadius = Radius;
|
|
17
|
-
export type TextareaRadiusProp = RadiusProp;
|
|
18
|
-
export type TextareaProps = ClassName & TextareaVariantProp & TextareaSizeProp & TextareaRadiusProp & TextareaColorProp & Omit<HTMLTextareaAttributes, "size">;
|
|
19
|
-
declare const Textarea: import("svelte").Component<TextareaProps, {}, "value">;
|
|
5
|
+
export type TextareaProps = {
|
|
6
|
+
variant?: InputVariant;
|
|
7
|
+
el?: HTMLTextAreaElement;
|
|
8
|
+
} & ClassName & ColorProp & SizeProp & ShapeProp & Omit<HTMLTextareaAttributes, "class">;
|
|
9
|
+
declare const Textarea: import("svelte").Component<TextareaProps, {}, "el" | "value">;
|
|
20
10
|
type Textarea = ReturnType<typeof Textarea>;
|
|
21
11
|
export default Textarea;
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
@source "./";
|
|
2
|
+
|
|
3
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
4
|
+
|
|
5
|
+
@theme inline {
|
|
6
|
+
--color-m3-primary: var(--md-sys-color-primary);
|
|
7
|
+
--color-m3-surface-tint: var(--md-sys-color-surface-tint);
|
|
8
|
+
--color-m3-on-primary: var(--md-sys-color-on-primary);
|
|
9
|
+
--color-m3-primary-container: var(--md-sys-color-primary-container);
|
|
10
|
+
--color-m3-on-primary-container: var(--md-sys-color-on-primary-container);
|
|
11
|
+
--color-m3-secondary: var(--md-sys-color-secondary);
|
|
12
|
+
--color-m3-on-secondary: var(--md-sys-color-on-secondary);
|
|
13
|
+
--color-m3-secondary-container: var(--md-sys-color-secondary-container);
|
|
14
|
+
--color-m3-on-secondary-container: var(--md-sys-color-on-secondary-container);
|
|
15
|
+
--color-m3-tertiary: var(--md-sys-color-tertiary);
|
|
16
|
+
--color-m3-on-tertiary: var(--md-sys-color-on-tertiary);
|
|
17
|
+
--color-m3-tertiary-container: var(--md-sys-color-tertiary-container);
|
|
18
|
+
--color-m3-on-tertiary-container: var(--md-sys-color-on-tertiary-container);
|
|
19
|
+
--color-m3-error: var(--md-sys-color-error);
|
|
20
|
+
--color-m3-on-error: var(--md-sys-color-on-error);
|
|
21
|
+
--color-m3-error-container: var(--md-sys-color-error-container);
|
|
22
|
+
--color-m3-on-error-container: var(--md-sys-color-on-error-container);
|
|
23
|
+
--color-m3-background: var(--md-sys-color-background);
|
|
24
|
+
--color-m3-on-background: var(--md-sys-color-on-background);
|
|
25
|
+
--color-m3-surface: var(--md-sys-color-surface);
|
|
26
|
+
--color-m3-on-surface: var(--md-sys-color-on-surface);
|
|
27
|
+
--color-m3-surface-variant: var(--md-sys-color-surface-variant);
|
|
28
|
+
--color-m3-on-surface-variant: var(--md-sys-color-on-surface-variant);
|
|
29
|
+
--color-m3-outline: var(--md-sys-color-outline);
|
|
30
|
+
--color-m3-outline-variant: var(--md-sys-color-outline-variant);
|
|
31
|
+
--color-m3-shadow: var(--md-sys-color-shadow);
|
|
32
|
+
--color-m3-scrim: var(--md-sys-color-scrim);
|
|
33
|
+
--color-m3-inverse-surface: var(--md-sys-color-inverse-surface);
|
|
34
|
+
--color-m3-inverse-on-surface: var(--md-sys-color-inverse-on-surface);
|
|
35
|
+
--color-m3-inverse-primary: var(--md-sys-color-inverse-primary);
|
|
36
|
+
--color-m3-primary-fixed: var(--md-sys-color-primary-fixed);
|
|
37
|
+
--color-m3-on-primary-fixed: var(--md-sys-color-on-primary-fixed);
|
|
38
|
+
--color-m3-primary-fixed-dim: var(--md-sys-color-primary-fixed-dim);
|
|
39
|
+
--color-m3-on-primary-fixed-variant: var(
|
|
40
|
+
--md-sys-color-on-primary-fixed-variant
|
|
41
|
+
);
|
|
42
|
+
--color-m3-secondary-fixed: var(--md-sys-color-secondary-fixed);
|
|
43
|
+
--color-m3-on-secondary-fixed: var(--md-sys-color-on-secondary-fixed);
|
|
44
|
+
--color-m3-secondary-fixed-dim: var(--md-sys-color-secondary-fixed-dim);
|
|
45
|
+
--color-m3-on-secondary-fixed-variant: var(
|
|
46
|
+
--md-sys-color-on-secondary-fixed-variant
|
|
47
|
+
);
|
|
48
|
+
--color-m3-tertiary-fixed: var(--md-sys-color-tertiary-fixed);
|
|
49
|
+
--color-m3-on-tertiary-fixed: var(--md-sys-color-on-tertiary-fixed);
|
|
50
|
+
--color-m3-tertiary-fixed-dim: var(--md-sys-color-tertiary-fixed-dim);
|
|
51
|
+
--color-m3-on-tertiary-fixed-variant: var(
|
|
52
|
+
--md-sys-color-on-tertiary-fixed-variant
|
|
53
|
+
);
|
|
54
|
+
--color-m3-surface-dim: var(--md-sys-color-surface-dim);
|
|
55
|
+
--color-m3-surface-bright: var(--md-sys-color-surface-bright);
|
|
56
|
+
--color-m3-surface-container-lowest: var(
|
|
57
|
+
--md-sys-color-surface-container-lowest
|
|
58
|
+
);
|
|
59
|
+
--color-m3-surface-container-low: var(--md-sys-color-surface-container-low);
|
|
60
|
+
--color-m3-surface-container: var(--md-sys-color-surface-container);
|
|
61
|
+
--color-m3-surface-container-high: var(--md-sys-color-surface-container-high);
|
|
62
|
+
--color-m3-surface-container-highest: var(
|
|
63
|
+
--md-sys-color-surface-container-highest
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@layer base {
|
|
68
|
+
:root {
|
|
69
|
+
color-scheme: light;
|
|
70
|
+
--md-sys-color-primary: rgb(17 102 130);
|
|
71
|
+
--md-sys-color-surface-tint: rgb(17 102 130);
|
|
72
|
+
--md-sys-color-on-primary: rgb(255 255 255);
|
|
73
|
+
--md-sys-color-primary-container: rgb(189 233 255);
|
|
74
|
+
--md-sys-color-on-primary-container: rgb(0 31 42);
|
|
75
|
+
--md-sys-color-secondary: rgb(77 97 108);
|
|
76
|
+
--md-sys-color-on-secondary: rgb(255 255 255);
|
|
77
|
+
--md-sys-color-secondary-container: rgb(208 230 242);
|
|
78
|
+
--md-sys-color-on-secondary-container: rgb(8 30 39);
|
|
79
|
+
--md-sys-color-tertiary: rgb(93 91 125);
|
|
80
|
+
--md-sys-color-on-tertiary: rgb(255 255 255);
|
|
81
|
+
--md-sys-color-tertiary-container: rgb(227 223 255);
|
|
82
|
+
--md-sys-color-on-tertiary-container: rgb(25 24 54);
|
|
83
|
+
--md-sys-color-error: rgb(186 26 26);
|
|
84
|
+
--md-sys-color-on-error: rgb(255 255 255);
|
|
85
|
+
--md-sys-color-error-container: rgb(255 218 214);
|
|
86
|
+
--md-sys-color-on-error-container: rgb(65 0 2);
|
|
87
|
+
--md-sys-color-background: rgb(246 250 253);
|
|
88
|
+
--md-sys-color-on-background: rgb(23 28 31);
|
|
89
|
+
--md-sys-color-surface: rgb(246 250 253);
|
|
90
|
+
--md-sys-color-on-surface: rgb(23 28 31);
|
|
91
|
+
--md-sys-color-surface-variant: rgb(220 228 233);
|
|
92
|
+
--md-sys-color-on-surface-variant: rgb(64 72 76);
|
|
93
|
+
--md-sys-color-outline: rgb(112 120 125);
|
|
94
|
+
--md-sys-color-outline-variant: rgb(192 200 205);
|
|
95
|
+
--md-sys-color-shadow: rgb(0 0 0);
|
|
96
|
+
--md-sys-color-scrim: rgb(0 0 0);
|
|
97
|
+
--md-sys-color-inverse-surface: rgb(44 49 52);
|
|
98
|
+
--md-sys-color-inverse-on-surface: rgb(237 241 245);
|
|
99
|
+
--md-sys-color-inverse-primary: rgb(139 208 239);
|
|
100
|
+
--md-sys-color-primary-fixed: rgb(189 233 255);
|
|
101
|
+
--md-sys-color-on-primary-fixed: rgb(0 31 42);
|
|
102
|
+
--md-sys-color-primary-fixed-dim: rgb(139 208 239);
|
|
103
|
+
--md-sys-color-on-primary-fixed-variant: rgb(0 77 100);
|
|
104
|
+
--md-sys-color-secondary-fixed: rgb(208 230 242);
|
|
105
|
+
--md-sys-color-on-secondary-fixed: rgb(8 30 39);
|
|
106
|
+
--md-sys-color-secondary-fixed-dim: rgb(180 202 214);
|
|
107
|
+
--md-sys-color-on-secondary-fixed-variant: rgb(53 74 83);
|
|
108
|
+
--md-sys-color-tertiary-fixed: rgb(227 223 255);
|
|
109
|
+
--md-sys-color-on-tertiary-fixed: rgb(25 24 54);
|
|
110
|
+
--md-sys-color-tertiary-fixed-dim: rgb(198 194 234);
|
|
111
|
+
--md-sys-color-on-tertiary-fixed-variant: rgb(69 67 100);
|
|
112
|
+
--md-sys-color-surface-dim: rgb(214 219 222);
|
|
113
|
+
--md-sys-color-surface-bright: rgb(246 250 253);
|
|
114
|
+
--md-sys-color-surface-container-lowest: rgb(255 255 255);
|
|
115
|
+
--md-sys-color-surface-container-low: rgb(240 244 248);
|
|
116
|
+
--md-sys-color-surface-container: rgb(234 238 242);
|
|
117
|
+
--md-sys-color-surface-container-high: rgb(228 233 236);
|
|
118
|
+
--md-sys-color-surface-container-highest: rgb(223 227 231);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dark {
|
|
122
|
+
color-scheme: dark;
|
|
123
|
+
--md-sys-color-primary: rgb(139 208 239);
|
|
124
|
+
--md-sys-color-surface-tint: rgb(139 208 239);
|
|
125
|
+
--md-sys-color-on-primary: rgb(0 53 70);
|
|
126
|
+
--md-sys-color-primary-container: rgb(0 77 100);
|
|
127
|
+
--md-sys-color-on-primary-container: rgb(189 233 255);
|
|
128
|
+
--md-sys-color-secondary: rgb(180 202 214);
|
|
129
|
+
--md-sys-color-on-secondary: rgb(31 51 60);
|
|
130
|
+
--md-sys-color-secondary-container: rgb(53 74 83);
|
|
131
|
+
--md-sys-color-on-secondary-container: rgb(208 230 242);
|
|
132
|
+
--md-sys-color-tertiary: rgb(198 194 234);
|
|
133
|
+
--md-sys-color-on-tertiary: rgb(46 45 77);
|
|
134
|
+
--md-sys-color-tertiary-container: rgb(69 67 100);
|
|
135
|
+
--md-sys-color-on-tertiary-container: rgb(227 223 255);
|
|
136
|
+
--md-sys-color-error: rgb(255 180 171);
|
|
137
|
+
--md-sys-color-on-error: rgb(105 0 5);
|
|
138
|
+
--md-sys-color-error-container: rgb(147 0 10);
|
|
139
|
+
--md-sys-color-on-error-container: rgb(255 218 214);
|
|
140
|
+
--md-sys-color-background: rgb(15 20 23);
|
|
141
|
+
--md-sys-color-on-background: rgb(223 227 231);
|
|
142
|
+
--md-sys-color-surface: rgb(15 20 23);
|
|
143
|
+
--md-sys-color-on-surface: rgb(223 227 231);
|
|
144
|
+
--md-sys-color-surface-variant: rgb(64 72 76);
|
|
145
|
+
--md-sys-color-on-surface-variant: rgb(192 200 205);
|
|
146
|
+
--md-sys-color-outline: rgb(138 146 151);
|
|
147
|
+
--md-sys-color-outline-variant: rgb(64 72 76);
|
|
148
|
+
--md-sys-color-shadow: rgb(0 0 0);
|
|
149
|
+
--md-sys-color-scrim: rgb(0 0 0);
|
|
150
|
+
--md-sys-color-inverse-surface: rgb(223 227 231);
|
|
151
|
+
--md-sys-color-inverse-on-surface: rgb(44 49 52);
|
|
152
|
+
--md-sys-color-inverse-primary: rgb(17 102 130);
|
|
153
|
+
--md-sys-color-primary-fixed: rgb(189 233 255);
|
|
154
|
+
--md-sys-color-on-primary-fixed: rgb(0 31 42);
|
|
155
|
+
--md-sys-color-primary-fixed-dim: rgb(139 208 239);
|
|
156
|
+
--md-sys-color-on-primary-fixed-variant: rgb(0 77 100);
|
|
157
|
+
--md-sys-color-secondary-fixed: rgb(208 230 242);
|
|
158
|
+
--md-sys-color-on-secondary-fixed: rgb(8 30 39);
|
|
159
|
+
--md-sys-color-secondary-fixed-dim: rgb(180 202 214);
|
|
160
|
+
--md-sys-color-on-secondary-fixed-variant: rgb(53 74 83);
|
|
161
|
+
--md-sys-color-tertiary-fixed: rgb(227 223 255);
|
|
162
|
+
--md-sys-color-on-tertiary-fixed: rgb(25 24 54);
|
|
163
|
+
--md-sys-color-tertiary-fixed-dim: rgb(198 194 234);
|
|
164
|
+
--md-sys-color-on-tertiary-fixed-variant: rgb(69 67 100);
|
|
165
|
+
--md-sys-color-surface-dim: rgb(15 20 23);
|
|
166
|
+
--md-sys-color-surface-bright: rgb(53 58 61);
|
|
167
|
+
--md-sys-color-surface-container-lowest: rgb(10 15 17);
|
|
168
|
+
--md-sys-color-surface-container-low: rgb(23 28 31);
|
|
169
|
+
--md-sys-color-surface-container: rgb(27 32 35);
|
|
170
|
+
--md-sys-color-surface-container-high: rgb(38 43 45);
|
|
171
|
+
--md-sys-color-surface-container-highest: rgb(48 53 56);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
*,
|
|
175
|
+
::after,
|
|
176
|
+
::before,
|
|
177
|
+
::backdrop,
|
|
178
|
+
::file-selector-button {
|
|
179
|
+
border-color: var(--color-m3-outline-variant);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
body {
|
|
183
|
+
background-color: var(--color-m3-surface);
|
|
184
|
+
color: var(--color-m3-on-surface);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
button:not(:disabled),
|
|
188
|
+
[role="button"]:not(:disabled) {
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
}
|
|
191
|
+
}
|
package/dist/toggle/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { default as ToggleButton, type ToggleButtonProps, } from "./toggle-button.svelte";
|
|
2
|
-
export { getToggleContext, setToggleContext, ToggleContext, } from "./toggle-context.svelte.js";
|
|
3
2
|
export { default as ToggleGroup, type ToggleGroupProps, } from "./toggle-group.svelte";
|
package/dist/toggle/index.js
CHANGED
|
@@ -1,19 +1,62 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Color, Shape, Size } from "../base.js";
|
|
3
3
|
import { mergeProps } from "../merge-props.js";
|
|
4
|
-
import { getToggleContext } from "./
|
|
5
|
-
import {
|
|
4
|
+
import { getToggleContext } from "./toggle-context.js";
|
|
5
|
+
import { cn, type ClassName } from "../utils.js";
|
|
6
6
|
import type { Snippet } from "svelte";
|
|
7
|
-
import type {
|
|
8
|
-
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
9
8
|
|
|
10
9
|
export type ToggleButtonProps<T> = {
|
|
11
10
|
value: T;
|
|
12
11
|
children: Snippet;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Omit<
|
|
16
|
-
|
|
12
|
+
el?: HTMLInputElement;
|
|
13
|
+
} & ClassName &
|
|
14
|
+
Omit<
|
|
15
|
+
HTMLInputAttributes,
|
|
16
|
+
"value" | "type" | "name" | "checked" | "children" | "class"
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
const SIZES: Record<Size, string> = {
|
|
20
|
+
xs: "h-7 gap-1.5 px-3 text-xs",
|
|
21
|
+
sm: "h-9 gap-2 px-4 text-sm",
|
|
22
|
+
md: "h-11 gap-2 px-5 text-base",
|
|
23
|
+
lg: "h-13 gap-2.5 px-6 text-lg",
|
|
24
|
+
xl: "h-15 gap-3 px-7 text-xl",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const SHAPES: Record<Shape, string> = {
|
|
28
|
+
none: "",
|
|
29
|
+
xs: "first:rounded-l-sm last:rounded-r-sm",
|
|
30
|
+
sm: "first:rounded-l-lg last:rounded-r-lg",
|
|
31
|
+
md: "first:rounded-l-xl last:rounded-r-xl",
|
|
32
|
+
lg: "first:rounded-l-2xl last:rounded-r-2xl",
|
|
33
|
+
xl: "first:rounded-l-[1.75rem] last:rounded-r-[1.75rem]",
|
|
34
|
+
full: "first:rounded-l-full last:rounded-r-full",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const COLORS: Record<Color, string> = {
|
|
38
|
+
primary:
|
|
39
|
+
"border-m3-primary text-m3-primary has-checked:bg-m3-primary has-checked:text-m3-on-primary",
|
|
40
|
+
secondary:
|
|
41
|
+
"border-m3-secondary text-m3-secondary has-checked:bg-m3-secondary has-checked:text-m3-on-secondary",
|
|
42
|
+
tertiary:
|
|
43
|
+
"border-m3-tertiary text-m3-tertiary has-checked:bg-m3-tertiary has-checked:text-m3-on-tertiary",
|
|
44
|
+
error:
|
|
45
|
+
"border-m3-error text-m3-error has-checked:bg-m3-error has-checked:text-m3-on-error",
|
|
46
|
+
plain:
|
|
47
|
+
"border-current has-checked:bg-current/10 has-checked:shadow-[inset_0_0_0_2px_currentColor]",
|
|
48
|
+
inherit:
|
|
49
|
+
"border-current has-checked:bg-current/10 has-checked:shadow-[inset_0_0_0_2px_currentColor]",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const FOCUS: Record<Color, string> = {
|
|
53
|
+
primary: "focus-visible:outline-m3-primary",
|
|
54
|
+
secondary: "focus-visible:outline-m3-secondary",
|
|
55
|
+
tertiary: "focus-visible:outline-m3-tertiary",
|
|
56
|
+
error: "focus-visible:outline-m3-error",
|
|
57
|
+
plain: "focus-visible:outline-current",
|
|
58
|
+
inherit: "focus-visible:outline-current",
|
|
59
|
+
};
|
|
17
60
|
</script>
|
|
18
61
|
|
|
19
62
|
<script lang="ts" generics="T">
|
|
@@ -21,42 +64,33 @@
|
|
|
21
64
|
value,
|
|
22
65
|
children,
|
|
23
66
|
el = $bindable(),
|
|
24
|
-
ref = noop,
|
|
25
67
|
class: className,
|
|
26
|
-
color = "primary",
|
|
27
|
-
shape = "rounded",
|
|
28
|
-
type = "button",
|
|
29
68
|
...restProps
|
|
30
69
|
}: ToggleButtonProps<T> = $props();
|
|
31
70
|
|
|
32
|
-
const ctx = getToggleContext
|
|
71
|
+
const ctx = getToggleContext();
|
|
33
72
|
</script>
|
|
34
73
|
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"bg-md-background text-md-on-surface flex items-center gap-1 border-y border-l px-4 py-2 text-sm last:border-r",
|
|
42
|
-
|
|
43
|
-
shape === "square" && "",
|
|
44
|
-
shape === "rounded" && "first:rounded-l-md last:rounded-r-md",
|
|
45
|
-
shape === "circle" && "first:rounded-l-full last:rounded-r-full",
|
|
46
|
-
|
|
47
|
-
color === "primary" &&
|
|
48
|
-
"border-m3-primary text-m3-primary aria-selected:bg-m3-primary aria-selected:text-m3-on-primary",
|
|
49
|
-
color === "secondary" &&
|
|
50
|
-
"border-m3-secondary text-m3-secondary aria-selected:bg-m3-secondary aria-selected:text-m3-on-secondary",
|
|
51
|
-
color === "tertiary" &&
|
|
52
|
-
"border-m3-tertiary text-m3-tertiary aria-selected:bg-m3-tertiary aria-selected:text-m3-on-tertiary",
|
|
53
|
-
color === "error" &&
|
|
54
|
-
"border-m3-error text-m3-error aria-selected:bg-m3-error aria-selected:text-m3-on-error",
|
|
55
|
-
|
|
74
|
+
<label
|
|
75
|
+
class={cn(
|
|
76
|
+
"relative inline-flex cursor-pointer items-center justify-center border-y border-l select-none last:border-r has-disabled:cursor-not-allowed has-disabled:opacity-38",
|
|
77
|
+
SIZES[ctx.size],
|
|
78
|
+
SHAPES[ctx.shape],
|
|
79
|
+
COLORS[ctx.color],
|
|
56
80
|
className,
|
|
57
81
|
)}
|
|
58
|
-
{type}
|
|
59
|
-
{...mergeProps(restProps, { onclick: () => (ctx.value = value) })}
|
|
60
82
|
>
|
|
83
|
+
<input
|
|
84
|
+
bind:this={el}
|
|
85
|
+
type="radio"
|
|
86
|
+
name={ctx.name}
|
|
87
|
+
value={String(value)}
|
|
88
|
+
checked={ctx.value === value}
|
|
89
|
+
class={cn(
|
|
90
|
+
"absolute -inset-px cursor-[inherit] appearance-none rounded-[inherit] focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
91
|
+
FOCUS[ctx.color],
|
|
92
|
+
)}
|
|
93
|
+
{...mergeProps(restProps, { onchange: () => ctx.select(value) })}
|
|
94
|
+
/>
|
|
61
95
|
{@render children()}
|
|
62
|
-
</
|
|
96
|
+
</label>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type ClassName, type ElementRef } from "../utils.js";
|
|
1
|
+
import { type ClassName } from "../utils.js";
|
|
3
2
|
import type { Snippet } from "svelte";
|
|
4
|
-
import type {
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
5
4
|
export type ToggleButtonProps<T> = {
|
|
6
5
|
value: T;
|
|
7
6
|
children: Snippet;
|
|
8
|
-
|
|
7
|
+
el?: HTMLInputElement;
|
|
8
|
+
} & ClassName & Omit<HTMLInputAttributes, "value" | "type" | "name" | "checked" | "children" | "class">;
|
|
9
9
|
declare function $$render<T>(): {
|
|
10
10
|
props: ToggleButtonProps<T>;
|
|
11
11
|
exports: {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Color, Shape, Size } from "../base.js";
|
|
2
|
+
export type ToggleContext<T = unknown> = {
|
|
3
|
+
readonly value: T | undefined;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly color: Color;
|
|
6
|
+
readonly size: Size;
|
|
7
|
+
readonly shape: Shape;
|
|
8
|
+
select(value: T): void;
|
|
9
|
+
};
|
|
10
|
+
export declare const getToggleContext: () => ToggleContext<unknown>, setToggleContext: (context: ToggleContext<unknown>) => ToggleContext<unknown>;
|
|
@@ -1,47 +1,66 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { ColorProp, ShapeProp, SizeProp } from "../base.js";
|
|
3
|
+
import { setToggleContext } from "./toggle-context.js";
|
|
4
|
+
import { cn, type ClassName } from "../utils.js";
|
|
4
5
|
import type { Snippet } from "svelte";
|
|
5
6
|
import type { HTMLAttributes } from "svelte/elements";
|
|
6
|
-
import { twMerge } from "tailwind-merge";
|
|
7
7
|
|
|
8
8
|
export type ToggleGroupProps<T> = {
|
|
9
9
|
value?: T;
|
|
10
|
-
onChange?: (value
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
onChange?: (value: T) => void;
|
|
11
|
+
name?: string;
|
|
12
|
+
children: Snippet;
|
|
13
|
+
el?: HTMLDivElement;
|
|
14
|
+
} & ClassName &
|
|
15
|
+
ColorProp &
|
|
16
|
+
SizeProp &
|
|
17
|
+
ShapeProp &
|
|
18
|
+
Omit<HTMLAttributes<HTMLDivElement>, "children" | "class">;
|
|
15
19
|
</script>
|
|
16
20
|
|
|
17
21
|
<script lang="ts" generics="T">
|
|
18
22
|
let {
|
|
19
23
|
value = $bindable(),
|
|
20
24
|
onChange,
|
|
25
|
+
name,
|
|
21
26
|
children,
|
|
22
27
|
el = $bindable(),
|
|
23
|
-
ref = noop,
|
|
24
28
|
class: className,
|
|
29
|
+
color = "primary",
|
|
30
|
+
size = "sm",
|
|
31
|
+
shape = "full",
|
|
25
32
|
...restProps
|
|
26
33
|
}: ToggleGroupProps<T> = $props();
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const id = $props.id();
|
|
36
|
+
|
|
37
|
+
setToggleContext({
|
|
38
|
+
get value() {
|
|
39
|
+
return value;
|
|
40
|
+
},
|
|
41
|
+
get name() {
|
|
42
|
+
return name ?? id;
|
|
43
|
+
},
|
|
44
|
+
get color() {
|
|
45
|
+
return color;
|
|
46
|
+
},
|
|
47
|
+
get size() {
|
|
48
|
+
return size;
|
|
49
|
+
},
|
|
50
|
+
get shape() {
|
|
51
|
+
return shape;
|
|
52
|
+
},
|
|
53
|
+
select(selected) {
|
|
54
|
+
value = selected as T;
|
|
55
|
+
onChange?.(selected as T);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
37
58
|
</script>
|
|
38
59
|
|
|
39
60
|
<div
|
|
40
61
|
bind:this={el}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
aria-orientation="horizontal"
|
|
44
|
-
class={twMerge("flex", className)}
|
|
62
|
+
role="radiogroup"
|
|
63
|
+
class={cn("flex", className)}
|
|
45
64
|
{...restProps}
|
|
46
65
|
>
|
|
47
66
|
{@render children()}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ColorProp, ShapeProp, SizeProp } from "../base.js";
|
|
2
|
+
import { type ClassName } from "../utils.js";
|
|
2
3
|
import type { Snippet } from "svelte";
|
|
3
4
|
import type { HTMLAttributes } from "svelte/elements";
|
|
4
5
|
export type ToggleGroupProps<T> = {
|
|
5
6
|
value?: T;
|
|
6
|
-
onChange?: (value
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
onChange?: (value: T) => void;
|
|
8
|
+
name?: string;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
el?: HTMLDivElement;
|
|
11
|
+
} & ClassName & ColorProp & SizeProp & ShapeProp & Omit<HTMLAttributes<HTMLDivElement>, "children" | "class">;
|
|
9
12
|
declare function $$render<T>(): {
|
|
10
13
|
props: ToggleGroupProps<T>;
|
|
11
14
|
exports: {};
|