kosui 0.0.28 → 0.0.29
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/alert/alert.svelte +174 -19
- package/dist/alert/alert.svelte.d.ts +26 -3
- package/dist/alert/index.d.ts +1 -1
- package/dist/alert/index.js +1 -1
- package/dist/base.d.ts +3 -3
- package/dist/base.js +3 -2
- package/dist/input/input.svelte.d.ts +3 -3
- package/dist/slider/slider-context.svelte.d.ts +5 -3
- package/dist/slider/slider-context.svelte.js +15 -9
- package/dist/slider/slider-handle-label.svelte +5 -1
- package/dist/slider/slider-handle.svelte +7 -4
- package/dist/slider/slider.svelte +62 -40
- package/dist/slider/slider.svelte.d.ts +3 -3
- package/dist/switch/switch.svelte.d.ts +3 -3
- package/dist/textarea/textarea.svelte.d.ts +3 -3
- package/package.json +1 -1
package/dist/alert/alert.svelte
CHANGED
|
@@ -1,28 +1,183 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
COLORS,
|
|
4
|
+
RADII,
|
|
5
|
+
type Color,
|
|
6
|
+
type ColorProp,
|
|
7
|
+
type Radius,
|
|
8
|
+
type RadiusProp,
|
|
9
|
+
} from "../base.js";
|
|
10
|
+
import { mergeProps } from "../merge-props.js";
|
|
11
|
+
import type { Snippet } from "svelte";
|
|
12
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
13
|
|
|
5
|
-
export
|
|
14
|
+
export const ALERT_VARIANT = ["filled", "tonal", "plain"] as const;
|
|
15
|
+
export type AlertVariant = (typeof ALERT_VARIANT)[number];
|
|
16
|
+
export type AlertVariantProp = { variant?: AlertVariant };
|
|
17
|
+
|
|
18
|
+
export const ALERT_COLORS = COLORS;
|
|
19
|
+
export type AlertColor = Color;
|
|
20
|
+
export type AlertColorProp = ColorProp;
|
|
21
|
+
|
|
22
|
+
export type AlertOutlined = boolean;
|
|
23
|
+
export type AlertOutlinedProp = { outlined?: AlertOutlined };
|
|
24
|
+
|
|
25
|
+
export type AlertElevated = boolean;
|
|
26
|
+
export type AlertElevatedProp = { elevated?: AlertElevated };
|
|
27
|
+
|
|
28
|
+
export const ALERT_RADII = RADII;
|
|
29
|
+
export type AlertRadius = Radius;
|
|
30
|
+
export type AlertRadiusProp = RadiusProp;
|
|
31
|
+
|
|
32
|
+
export type AlertProps = {
|
|
33
|
+
children: Snippet<[]>;
|
|
34
|
+
} & AlertVariantProp &
|
|
35
|
+
AlertColorProp &
|
|
36
|
+
AlertRadiusProp &
|
|
37
|
+
AlertOutlinedProp &
|
|
38
|
+
AlertElevatedProp &
|
|
39
|
+
HTMLAttributes<HTMLDivElement>;
|
|
6
40
|
</script>
|
|
7
41
|
|
|
8
42
|
<script lang="ts">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class: className,
|
|
12
|
-
variant = "elevated",
|
|
43
|
+
const {
|
|
44
|
+
variant = "tonal",
|
|
13
45
|
color = "primary",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
46
|
+
radius = "sm",
|
|
47
|
+
outlined = false,
|
|
48
|
+
elevated = false,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
17
51
|
}: AlertProps = $props();
|
|
18
52
|
</script>
|
|
19
53
|
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
<div
|
|
55
|
+
{...mergeProps(props, {
|
|
56
|
+
class: [
|
|
57
|
+
"base",
|
|
58
|
+
`radius-${radius}`,
|
|
59
|
+
`variant-${variant}`,
|
|
60
|
+
`color-${color}`,
|
|
61
|
+
outlined && "outlined",
|
|
62
|
+
elevated && "elevated",
|
|
63
|
+
],
|
|
64
|
+
})}
|
|
65
|
+
>
|
|
66
|
+
{@render children()}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.base {
|
|
71
|
+
padding: calc(var(--spacing) * 4);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.elevated {
|
|
75
|
+
box-shadow:
|
|
76
|
+
0 1px 3px 0 rgb(from var(--md-sys-color-shadow, rgb(0 0 0)) r g b / 0.2),
|
|
77
|
+
0 1px 2px -1px
|
|
78
|
+
rgb(from var(--md-sys-color-shadow, rgb(0 0 0)) r g b / 0.2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.variant-filled.color-primary {
|
|
82
|
+
background-color: var(--md-sys-color-primary);
|
|
83
|
+
color: var(--md-sys-color-on-primary);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.variant-filled.color-secondary {
|
|
87
|
+
background-color: var(--md-sys-color-secondary);
|
|
88
|
+
color: var(--md-sys-color-on-secondary);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.variant-filled.color-tertiary {
|
|
92
|
+
background-color: var(--md-sys-color-tertiary);
|
|
93
|
+
color: var(--md-sys-color-on-tertiary);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.variant-filled.color-error {
|
|
97
|
+
background-color: var(--md-sys-color-error);
|
|
98
|
+
color: var(--md-sys-color-on-error);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.variant-filled.color-plain {
|
|
102
|
+
background-color: var(--md-sys-color-inverse-surface);
|
|
103
|
+
color: var(--md-sys-color-inverse-on-surface);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.variant-tonal.color-primary {
|
|
107
|
+
background-color: var(--md-sys-color-primary-container);
|
|
108
|
+
color: var(--md-sys-color-on-primary-container);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.variant-tonal.color-secondary {
|
|
112
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
113
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.variant-tonal.color-tertiary {
|
|
117
|
+
background-color: var(--md-sys-color-tertiary-container);
|
|
118
|
+
color: var(--md-sys-color-on-tertiary-container);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.variant-tonal.color-error {
|
|
122
|
+
background-color: var(--md-sys-color-error-container);
|
|
123
|
+
color: var(--md-sys-color-on-error-container);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.variant-tonal.color-plain {
|
|
127
|
+
background-color: var(--md-sys-color-surface-variant);
|
|
128
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.outlined {
|
|
132
|
+
border-width: 1px;
|
|
133
|
+
border-style: solid;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.outlined.color-primary {
|
|
137
|
+
border-color: var(--md-sys-color-primary);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.outlined.color-secondary {
|
|
141
|
+
border-color: var(--md-sys-color-secondary);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.outlined.color-tertiary {
|
|
145
|
+
border-color: var(--md-sys-color-tertiary);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.outlined.color-error {
|
|
149
|
+
border-color: var(--md-sys-color-error);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.outlined.color-plain {
|
|
153
|
+
border-color: var(--md-sys-color-outline);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.radius-none {
|
|
157
|
+
border-radius: 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.radius-xs {
|
|
161
|
+
border-radius: var(--radius-xs);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.radius-sm {
|
|
165
|
+
border-radius: var(--radius-sm);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.radius-md {
|
|
169
|
+
border-radius: var(--radius-lg);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.radius-lg {
|
|
173
|
+
border-radius: var(--radius-2xl);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.radius-xl {
|
|
177
|
+
border-radius: var(--radius-4xl);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.radius-full {
|
|
181
|
+
border-radius: calc(infinity * 1px);
|
|
182
|
+
}
|
|
183
|
+
</style>
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type Color, type ColorProp, type Radius, type RadiusProp } from "../base.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
export declare const ALERT_VARIANT: readonly ["filled", "tonal", "plain"];
|
|
5
|
+
export type AlertVariant = (typeof ALERT_VARIANT)[number];
|
|
6
|
+
export type AlertVariantProp = {
|
|
7
|
+
variant?: AlertVariant;
|
|
8
|
+
};
|
|
9
|
+
export declare const ALERT_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
10
|
+
export type AlertColor = Color;
|
|
11
|
+
export type AlertColorProp = ColorProp;
|
|
12
|
+
export type AlertOutlined = boolean;
|
|
13
|
+
export type AlertOutlinedProp = {
|
|
14
|
+
outlined?: AlertOutlined;
|
|
15
|
+
};
|
|
16
|
+
export type AlertElevated = boolean;
|
|
17
|
+
export type AlertElevatedProp = {
|
|
18
|
+
elevated?: AlertElevated;
|
|
19
|
+
};
|
|
20
|
+
export declare const ALERT_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
21
|
+
export type AlertRadius = Radius;
|
|
22
|
+
export type AlertRadiusProp = RadiusProp;
|
|
23
|
+
export type AlertProps = {
|
|
24
|
+
children: Snippet<[]>;
|
|
25
|
+
} & AlertVariantProp & AlertColorProp & AlertRadiusProp & AlertOutlinedProp & AlertElevatedProp & HTMLAttributes<HTMLDivElement>;
|
|
26
|
+
declare const Alert: import("svelte").Component<AlertProps, {}, "">;
|
|
4
27
|
type Alert = ReturnType<typeof Alert>;
|
|
5
28
|
export default Alert;
|
package/dist/alert/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Alert, type AlertProps } from "./alert.svelte";
|
|
1
|
+
export { default as Alert, ALERT_COLORS, ALERT_RADII, ALERT_VARIANT, type AlertColor, type AlertColorProp, type AlertElevated, type AlertElevatedProp, type AlertOutlined, type AlertOutlinedProp, type AlertProps, type AlertRadius, type AlertRadiusProp, type AlertVariant, type AlertVariantProp, } from "./alert.svelte";
|
package/dist/alert/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Alert } from "./alert.svelte";
|
|
1
|
+
export { default as Alert, ALERT_COLORS, ALERT_RADII, ALERT_VARIANT, } from "./alert.svelte";
|
package/dist/base.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type Variant = (typeof VARIANTS)[number];
|
|
|
3
3
|
export type VariantProp = {
|
|
4
4
|
variant?: Variant;
|
|
5
5
|
};
|
|
6
|
-
export declare const COLORS: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
6
|
+
export declare const COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
7
7
|
export type Color = (typeof COLORS)[number];
|
|
8
8
|
export type ColorProp = {
|
|
9
9
|
color?: Color;
|
|
@@ -13,12 +13,12 @@ export type Shape = (typeof SHAPES)[number];
|
|
|
13
13
|
export type ShapeProp = {
|
|
14
14
|
shape?: Shape;
|
|
15
15
|
};
|
|
16
|
-
export declare const SIZES: readonly ["xs", "sm", "md", "lg", "xl"
|
|
16
|
+
export declare const SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
17
17
|
export type Size = (typeof SIZES)[number];
|
|
18
18
|
export type SizeProp = {
|
|
19
19
|
size?: Size;
|
|
20
20
|
};
|
|
21
|
-
export declare const RADII: readonly ["xs", "sm", "md", "lg", "xl", "
|
|
21
|
+
export declare const RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
22
22
|
export type Radius = (typeof RADII)[number];
|
|
23
23
|
export type RadiusProp = {
|
|
24
24
|
radius?: Radius;
|
package/dist/base.js
CHANGED
|
@@ -12,11 +12,12 @@ export const COLORS = [
|
|
|
12
12
|
"secondary",
|
|
13
13
|
"tertiary",
|
|
14
14
|
"error",
|
|
15
|
+
"plain",
|
|
15
16
|
"inherit",
|
|
16
17
|
];
|
|
17
18
|
export const SHAPES = ["square", "rounded", "circle"];
|
|
18
|
-
export const SIZES = ["xs", "sm", "md", "lg", "xl"
|
|
19
|
-
export const RADII = ["xs", "sm", "md", "lg", "xl", "
|
|
19
|
+
export const SIZES = ["xs", "sm", "md", "lg", "xl"];
|
|
20
|
+
export const RADII = ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
20
21
|
export const UNDERLINES = ["always", "hover", "none"];
|
|
21
22
|
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" &&
|
|
22
23
|
color === "primary" &&
|
|
@@ -6,13 +6,13 @@ export type InputVariant = (typeof INPUT_VARIANTS)[number];
|
|
|
6
6
|
export type InputVariantProp = {
|
|
7
7
|
variant?: InputVariant;
|
|
8
8
|
};
|
|
9
|
-
export declare const INPUT_COLORS: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
9
|
+
export declare const INPUT_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
10
10
|
export type InputColor = Color;
|
|
11
11
|
export type InputColorProp = ColorProp;
|
|
12
|
-
export declare const INPUT_SIZES: readonly ["xs", "sm", "md", "lg", "xl"
|
|
12
|
+
export declare const INPUT_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
13
13
|
export type InputSize = Size;
|
|
14
14
|
export type InputSizeProp = SizeProp;
|
|
15
|
-
export declare const INPUT_RADII: readonly ["xs", "sm", "md", "lg", "xl", "
|
|
15
|
+
export declare const INPUT_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
16
16
|
export type InputRadius = Radius;
|
|
17
17
|
export type InputRadiusProp = RadiusProp;
|
|
18
18
|
export type InputProps = ElementRef & ClassName & InputVariantProp & InputSizeProp & InputRadiusProp & InputColorProp & Omit<HTMLInputAttributes, "size">;
|
|
@@ -15,9 +15,10 @@ export declare class SliderContext {
|
|
|
15
15
|
markDotRenderer: Snippet<[SliderMarkDotProps]>;
|
|
16
16
|
markLabelRenderer: Snippet<[SliderMarkLabelProps]>;
|
|
17
17
|
sliderEl: HTMLDivElement;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
hovered: boolean;
|
|
19
|
+
clicked: boolean;
|
|
20
|
+
dragging: boolean;
|
|
21
|
+
focused: boolean;
|
|
21
22
|
constructor(getValue: () => number, setValue: (val: number) => void, min: () => number, max: () => number, step: () => number, marks: () => Mark[], disabled: () => boolean, label: (value: number) => string, labelAlwaysOn: () => boolean, inverted: () => boolean, restrictToMarks: () => boolean, color: () => SliderColor, size: () => SliderSize, radius: () => SliderRadius, onChange: ((value: number) => void) | undefined, onChangeEnd: ((value: number) => void) | undefined, handleRenderer: Snippet<[SliderHandleProps]>, handleLabelRenderer: Snippet<[SliderHandleLabelProps]>, handleLabelArrowRenderer: Snippet<[SliderHandleLabelArrowProps]>, markRenderer: Snippet<[SliderMarkProps]>, markDotRenderer: Snippet<[SliderMarkDotProps]>, markLabelRenderer: Snippet<[SliderMarkLabelProps]>);
|
|
22
23
|
get value(): number;
|
|
23
24
|
set value(value: number);
|
|
@@ -34,6 +35,7 @@ export declare class SliderContext {
|
|
|
34
35
|
get size(): SliderSize;
|
|
35
36
|
get radius(): SliderRadius;
|
|
36
37
|
get position(): number;
|
|
38
|
+
get animated(): boolean;
|
|
37
39
|
clamp: (val: number, minVal: number, maxVal: number) => number;
|
|
38
40
|
getValueFromPosition: (position: number) => number;
|
|
39
41
|
getPositionFromValue: (val: number) => number;
|
|
@@ -24,9 +24,10 @@ export class SliderContext {
|
|
|
24
24
|
markDotRenderer;
|
|
25
25
|
markLabelRenderer;
|
|
26
26
|
sliderEl;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
hovered = $state(false);
|
|
28
|
+
clicked = $state(false);
|
|
29
|
+
dragging = $state(false);
|
|
30
|
+
focused = $state(false);
|
|
30
31
|
constructor(getValue, setValue, min, max, step, marks, disabled, label, labelAlwaysOn, inverted, restrictToMarks, color, size, radius, onChange, onChangeEnd, handleRenderer, handleLabelRenderer, handleLabelArrowRenderer, markRenderer, markDotRenderer, markLabelRenderer) {
|
|
31
32
|
this.#value = new Bindable(getValue());
|
|
32
33
|
this.#value.bind(getValue, setValue);
|
|
@@ -97,6 +98,9 @@ export class SliderContext {
|
|
|
97
98
|
get position() {
|
|
98
99
|
return this.getPositionFromValue(this.value);
|
|
99
100
|
}
|
|
101
|
+
get animated() {
|
|
102
|
+
return !this.dragging || this.restrictToMarks;
|
|
103
|
+
}
|
|
100
104
|
clamp = (val, minVal, maxVal) => {
|
|
101
105
|
return Math.min(Math.max(val, minVal), maxVal);
|
|
102
106
|
};
|
|
@@ -125,23 +129,25 @@ export class SliderContext {
|
|
|
125
129
|
pointerDown = (event) => {
|
|
126
130
|
if (this.disabled)
|
|
127
131
|
return;
|
|
128
|
-
this.
|
|
132
|
+
this.clicked = true;
|
|
129
133
|
this.sliderEl.setPointerCapture(event.pointerId);
|
|
130
134
|
this.value = this.getValueFromPosition(event.clientX);
|
|
131
135
|
event.preventDefault();
|
|
132
136
|
event.stopImmediatePropagation();
|
|
133
137
|
};
|
|
134
138
|
pointerMove = (event) => {
|
|
135
|
-
if (this.disabled || !this.
|
|
139
|
+
if (this.disabled || !this.clicked)
|
|
136
140
|
return;
|
|
141
|
+
this.dragging = true;
|
|
137
142
|
this.value = this.getValueFromPosition(event.clientX);
|
|
138
143
|
event.preventDefault();
|
|
139
144
|
event.stopImmediatePropagation();
|
|
140
145
|
};
|
|
141
146
|
pointerUp = (event) => {
|
|
142
|
-
if (this.disabled || !this.
|
|
147
|
+
if (this.disabled || !this.clicked)
|
|
143
148
|
return;
|
|
144
|
-
this.
|
|
149
|
+
this.dragging = false;
|
|
150
|
+
this.clicked = false;
|
|
145
151
|
this.sliderEl.releasePointerCapture(event.pointerId);
|
|
146
152
|
this.onChangeEnd?.(this.value);
|
|
147
153
|
event.preventDefault();
|
|
@@ -175,10 +181,10 @@ export class SliderContext {
|
|
|
175
181
|
this.onChangeEnd?.(this.value);
|
|
176
182
|
};
|
|
177
183
|
focus = () => {
|
|
178
|
-
this.
|
|
184
|
+
this.focused = true;
|
|
179
185
|
};
|
|
180
186
|
blur = () => {
|
|
181
|
-
this.
|
|
187
|
+
this.focused = false;
|
|
182
188
|
};
|
|
183
189
|
}
|
|
184
190
|
export function setSliderContext(state) {
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
<div class="relative">
|
|
19
19
|
<div
|
|
20
20
|
class={twMerge(
|
|
21
|
-
"border-2 border-m3-surface shadow-md
|
|
21
|
+
"border-2 border-m3-surface shadow-md",
|
|
22
22
|
|
|
23
|
+
ctx.animated && "transition-all",
|
|
23
24
|
!ctx.disabled && "hover:scale-110 focus:scale-110 active:scale-110",
|
|
24
25
|
|
|
25
26
|
ctx.color === "primary" && "bg-m3-primary",
|
|
@@ -33,17 +34,19 @@
|
|
|
33
34
|
ctx.size === "lg" && "size-6",
|
|
34
35
|
ctx.size === "xl" && "size-7",
|
|
35
36
|
|
|
37
|
+
ctx.radius === "none" && "rounded-none",
|
|
36
38
|
ctx.radius === "xs" && "rounded-xs",
|
|
37
39
|
ctx.radius === "sm" && "rounded-sm",
|
|
38
40
|
ctx.radius === "md" && "rounded-lg",
|
|
39
41
|
ctx.radius === "lg" && "rounded-2xl",
|
|
40
|
-
ctx.radius === "xl" && "rounded-
|
|
42
|
+
ctx.radius === "xl" && "rounded-4xl",
|
|
43
|
+
ctx.radius === "full" && "rounded-full",
|
|
41
44
|
|
|
42
45
|
className,
|
|
43
46
|
)}
|
|
44
47
|
{...mergeProps(restProps, {
|
|
45
|
-
onpointerenter: () => (ctx.
|
|
46
|
-
onpointerleave: () => (ctx.
|
|
48
|
+
onpointerenter: () => (ctx.hovered = true),
|
|
49
|
+
onpointerleave: () => (ctx.hovered = false),
|
|
47
50
|
})}
|
|
48
51
|
></div>
|
|
49
52
|
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
class: className,
|
|
99
99
|
color = "primary",
|
|
100
100
|
size = "md",
|
|
101
|
-
radius = "
|
|
101
|
+
radius = "full",
|
|
102
102
|
...restProps
|
|
103
103
|
}: SliderProps = $props();
|
|
104
104
|
|
|
@@ -128,6 +128,16 @@
|
|
|
128
128
|
sliderMarkLabel,
|
|
129
129
|
),
|
|
130
130
|
);
|
|
131
|
+
|
|
132
|
+
const SIZE_RATIO: Record<Size, number> = {
|
|
133
|
+
xs: 1.5,
|
|
134
|
+
sm: 2,
|
|
135
|
+
md: 2.5,
|
|
136
|
+
lg: 3,
|
|
137
|
+
xl: 3.5,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
let ratio = $derived(SIZE_RATIO[ctx.size]);
|
|
131
141
|
</script>
|
|
132
142
|
|
|
133
143
|
{#snippet defaultSliderHandle(props: SliderHandleProps)}
|
|
@@ -156,23 +166,26 @@
|
|
|
156
166
|
|
|
157
167
|
<!-- Track -->
|
|
158
168
|
<div
|
|
159
|
-
bind:this={ctx.sliderEl}
|
|
160
169
|
class={twMerge(
|
|
161
|
-
"
|
|
170
|
+
"cursor-pointer bg-m3-surface-container-highest px-2 select-none",
|
|
162
171
|
|
|
163
172
|
ctx.disabled && "cursor-not-allowed opacity-50",
|
|
164
173
|
|
|
174
|
+
ctx.radius === "none" && "rounded-none",
|
|
165
175
|
ctx.radius === "xs" && "rounded-xs",
|
|
166
176
|
ctx.radius === "sm" && "rounded-sm",
|
|
167
177
|
ctx.radius === "md" && "rounded-lg",
|
|
168
178
|
ctx.radius === "lg" && "rounded-2xl",
|
|
169
179
|
ctx.radius === "xl" && "rounded-4xl",
|
|
180
|
+
ctx.radius === "full" && "rounded-full",
|
|
181
|
+
|
|
182
|
+
ctx.size === "xs" && "my-1 h-0.5 px-1.5",
|
|
183
|
+
ctx.size === "sm" && "my-1 h-1 px-2",
|
|
184
|
+
ctx.size === "md" && "my-1 h-2 px-2.5",
|
|
185
|
+
ctx.size === "lg" && "my-1 h-3 px-3",
|
|
186
|
+
ctx.size === "xl" && "my-1 h-4 px-3.5",
|
|
170
187
|
|
|
171
|
-
|
|
172
|
-
ctx.size === "sm" && "my-3 h-1",
|
|
173
|
-
ctx.size === "md" && "my-3.5 h-2",
|
|
174
|
-
ctx.size === "lg" && "my-4 h-3",
|
|
175
|
-
ctx.size === "xl" && "my-4.5 h-4",
|
|
188
|
+
marks.length > 0 && "mb-6",
|
|
176
189
|
|
|
177
190
|
className,
|
|
178
191
|
)}
|
|
@@ -191,37 +204,46 @@
|
|
|
191
204
|
onblur: ctx.blur,
|
|
192
205
|
})}
|
|
193
206
|
>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
207
|
+
<div bind:this={ctx.sliderEl} class="relative h-full">
|
|
208
|
+
<!-- Filled track -->
|
|
209
|
+
<div
|
|
210
|
+
class={twMerge(
|
|
211
|
+
"absolute h-full",
|
|
212
|
+
|
|
213
|
+
ctx.animated && "transition-all",
|
|
214
|
+
|
|
215
|
+
ctx.color === "primary" && "bg-m3-primary",
|
|
216
|
+
ctx.color === "secondary" && "bg-m3-secondary",
|
|
217
|
+
ctx.color === "tertiary" && "bg-m3-tertiary",
|
|
218
|
+
ctx.color === "error" && "bg-m3-error",
|
|
219
|
+
|
|
220
|
+
ctx.radius === "none" && "rounded-none",
|
|
221
|
+
ctx.radius === "xs" && "rounded-xs",
|
|
222
|
+
ctx.radius === "sm" && "rounded-sm",
|
|
223
|
+
ctx.radius === "md" && "rounded-lg",
|
|
224
|
+
ctx.radius === "lg" && "rounded-2xl",
|
|
225
|
+
ctx.radius === "xl" && "rounded-4xl",
|
|
226
|
+
ctx.radius === "full" && "rounded-full",
|
|
227
|
+
)}
|
|
228
|
+
style={ctx.inverted
|
|
229
|
+
? `right: 0; margin-right: calc(var(--spacing) * -${ratio}); width: calc(${100 - ctx.position}% + var(--spacing) * ${ratio})`
|
|
230
|
+
: `left: 0; margin-left: calc(var(--spacing) * -${ratio}); width: calc(${ctx.position}% + var(--spacing) * ${ratio})`}
|
|
231
|
+
></div>
|
|
232
|
+
|
|
233
|
+
<!-- Marks -->
|
|
234
|
+
{#each marks as { value, label } (value)}
|
|
235
|
+
{@render ctx.markRenderer({ value, label })}
|
|
236
|
+
{/each}
|
|
237
|
+
|
|
238
|
+
<!-- Handle -->
|
|
239
|
+
<div
|
|
240
|
+
class={twMerge(
|
|
241
|
+
"absolute top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
242
|
+
ctx.animated && "transition-all",
|
|
243
|
+
)}
|
|
244
|
+
style={`left: ${ctx.position}%`}
|
|
245
|
+
>
|
|
246
|
+
{@render ctx.handleRenderer({})}
|
|
247
|
+
</div>
|
|
226
248
|
</div>
|
|
227
249
|
</div>
|
|
@@ -3,13 +3,13 @@ import { type SliderHandleLabelArrowProps, type SliderHandleLabelProps, type Sli
|
|
|
3
3
|
import type { ClassName } from "../utils.js";
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
5
|
import type { HTMLAttributes } from "svelte/elements";
|
|
6
|
-
export declare const SLIDER_COLORS: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
6
|
+
export declare const SLIDER_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
7
7
|
export type SliderColor = Color;
|
|
8
8
|
export type SliderColorProp = ColorProp;
|
|
9
|
-
export declare const SLIDER_SIZES: readonly ["xs", "sm", "md", "lg", "xl"
|
|
9
|
+
export declare const SLIDER_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
10
10
|
export type SliderSize = Size;
|
|
11
11
|
export type SliderSizeProp = SizeProp;
|
|
12
|
-
export declare const SLIDER_RADII: readonly ["xs", "sm", "md", "lg", "xl", "
|
|
12
|
+
export declare const SLIDER_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
13
13
|
export type SliderRadius = Radius;
|
|
14
14
|
export type SliderRadiusProp = RadiusProp;
|
|
15
15
|
export type Mark = {
|
|
@@ -3,13 +3,13 @@ import { type SwitchThumbProps } from "./index.js";
|
|
|
3
3
|
import type { ClassName } from "../utils.js";
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
5
|
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
6
|
-
export declare const SWITCH_COLORS: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
6
|
+
export declare const SWITCH_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
7
7
|
export type SwitchColor = Color;
|
|
8
8
|
export type SwitchColorProp = ColorProp;
|
|
9
|
-
export declare const SWITCH_SIZES: readonly ["xs", "sm", "md", "lg", "xl"
|
|
9
|
+
export declare const SWITCH_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
10
10
|
export type SwitchSize = Size;
|
|
11
11
|
export type SwitchSizeProp = SizeProp;
|
|
12
|
-
export declare const SWITCH_RADII: readonly ["xs", "sm", "md", "lg", "xl", "
|
|
12
|
+
export declare const SWITCH_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
13
13
|
export type SwitchRadius = Radius;
|
|
14
14
|
export type SwitchRadiusProp = RadiusProp;
|
|
15
15
|
export type SwitchProps = {
|
|
@@ -6,13 +6,13 @@ export type TextareaVariant = (typeof TEXTAREA_VARIANTS)[number];
|
|
|
6
6
|
export type TextareaVariantProp = {
|
|
7
7
|
variant?: TextareaVariant;
|
|
8
8
|
};
|
|
9
|
-
export declare const TEXTAREA_COLORS: readonly ["primary", "secondary", "tertiary", "error", "inherit"];
|
|
9
|
+
export declare const TEXTAREA_COLORS: readonly ["primary", "secondary", "tertiary", "error", "plain", "inherit"];
|
|
10
10
|
export type TextareaColor = Color;
|
|
11
11
|
export type TextareaColorProp = ColorProp;
|
|
12
|
-
export declare const TEXTAREA_SIZES: readonly ["xs", "sm", "md", "lg", "xl"
|
|
12
|
+
export declare const TEXTAREA_SIZES: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
13
13
|
export type TextareaSize = Size;
|
|
14
14
|
export type TextareaSizeProp = SizeProp;
|
|
15
|
-
export declare const TEXTAREA_RADII: readonly ["xs", "sm", "md", "lg", "xl", "
|
|
15
|
+
export declare const TEXTAREA_RADII: readonly ["none", "xs", "sm", "md", "lg", "xl", "full"];
|
|
16
16
|
export type TextareaRadius = Radius;
|
|
17
17
|
export type TextareaRadiusProp = RadiusProp;
|
|
18
18
|
export type TextareaProps = ClassName & TextareaVariantProp & TextareaSizeProp & TextareaRadiusProp & TextareaColorProp & Omit<HTMLTextareaAttributes, "size">;
|