m3-svelte 5.0.0 → 5.1.1
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/package/buttons/Button.svelte +1 -0
- package/package/forms/Slider.svelte +207 -31
- package/package/forms/Slider.svelte.d.ts +7 -1
- package/package/forms/SliderTicks.svelte +8 -238
- package/package/forms/SliderTicks.svelte.d.ts +9 -5
- package/package/forms/_picker/Item.svelte +2 -2
- package/package/index.d.ts +0 -1
- package/package/index.js +0 -1
- package/package.json +2 -2
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
{:else}
|
|
62
62
|
{@const { variant = "filled", square = false, iconType = "none", children, ...extra } = props}
|
|
63
63
|
<button
|
|
64
|
+
type={"onclick" in extra ? "button" : undefined}
|
|
64
65
|
class="m3-container m3-font-label-large {variant} icon-{iconType}"
|
|
65
66
|
class:square
|
|
66
67
|
{...extra}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
import type { IconifyIcon } from "@iconify/types";
|
|
4
|
+
import Icon from "../misc/_icon.svelte";
|
|
3
5
|
import { Spring } from "svelte/motion";
|
|
4
6
|
|
|
5
7
|
let {
|
|
@@ -9,6 +11,11 @@
|
|
|
9
11
|
step = "any",
|
|
10
12
|
disabled = false,
|
|
11
13
|
showValue = true,
|
|
14
|
+
size = "xs",
|
|
15
|
+
leadingIcon,
|
|
16
|
+
trailingIcon,
|
|
17
|
+
ticks = false,
|
|
18
|
+
endStops = true,
|
|
12
19
|
format = (n: number) => {
|
|
13
20
|
return n.toFixed(0);
|
|
14
21
|
},
|
|
@@ -20,8 +27,14 @@
|
|
|
20
27
|
step?: number | "any";
|
|
21
28
|
disabled?: boolean;
|
|
22
29
|
showValue?: boolean;
|
|
30
|
+
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
31
|
+
leadingIcon?: IconifyIcon;
|
|
32
|
+
trailingIcon?: IconifyIcon;
|
|
33
|
+
ticks?: boolean;
|
|
34
|
+
endStops?: boolean;
|
|
23
35
|
format?: (n: number) => string;
|
|
24
|
-
} & HTMLInputAttributes = $props();
|
|
36
|
+
} & Omit<HTMLInputAttributes, "size"> = $props();
|
|
37
|
+
let containerWidth = $state(600);
|
|
25
38
|
|
|
26
39
|
const valueDisplayed = new Spring(value, { stiffness: 0.3, damping: 1 });
|
|
27
40
|
const updateValue = (e: Event & { currentTarget: EventTarget & HTMLInputElement }) => {
|
|
@@ -31,11 +44,24 @@
|
|
|
31
44
|
valueDisplayed.target = newValue;
|
|
32
45
|
};
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
const range = $derived(max - min);
|
|
48
|
+
const percent = $derived((valueDisplayed.current - min) / range);
|
|
49
|
+
const tickList = $derived.by(() => {
|
|
50
|
+
if (typeof step != "number") return [];
|
|
51
|
+
|
|
52
|
+
const ticksList = [];
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i <= range; i += step) ticksList.push(i / range);
|
|
55
|
+
|
|
56
|
+
return ticksList;
|
|
57
|
+
});
|
|
36
58
|
</script>
|
|
37
59
|
|
|
38
|
-
<div
|
|
60
|
+
<div
|
|
61
|
+
class="m3-container {size}"
|
|
62
|
+
style:--percent="{percent * 100}%"
|
|
63
|
+
bind:offsetWidth={containerWidth}
|
|
64
|
+
>
|
|
39
65
|
<input
|
|
40
66
|
type="range"
|
|
41
67
|
oninput={updateValue}
|
|
@@ -46,10 +72,36 @@
|
|
|
46
72
|
{disabled}
|
|
47
73
|
{...extra}
|
|
48
74
|
/>
|
|
75
|
+
|
|
49
76
|
<div class="track"></div>
|
|
50
|
-
|
|
77
|
+
{#if leadingIcon}
|
|
78
|
+
<Icon
|
|
79
|
+
icon={leadingIcon}
|
|
80
|
+
class={"leading" + (containerWidth * percent < (size == "xl" ? 48 : 40) ? " pop" : "")}
|
|
81
|
+
/>
|
|
82
|
+
{/if}
|
|
83
|
+
{#if trailingIcon}
|
|
84
|
+
<Icon
|
|
85
|
+
icon={trailingIcon}
|
|
86
|
+
class={"trailing" + (containerWidth * (1 - percent) < (size == "xl" ? 48 : 40) ? " pop" : "")}
|
|
87
|
+
/>
|
|
88
|
+
{/if}
|
|
89
|
+
{#if ticks}
|
|
90
|
+
{#each tickList as tick}
|
|
91
|
+
<div
|
|
92
|
+
class="tick"
|
|
93
|
+
class:hidden={Math.abs(tick - percent) < 0.01}
|
|
94
|
+
class:inactive={tick > percent}
|
|
95
|
+
style:--x={tick - 0.5}
|
|
96
|
+
></div>
|
|
97
|
+
{/each}
|
|
98
|
+
{/if}
|
|
99
|
+
{#if endStops && !ticks && !trailingIcon}
|
|
100
|
+
<div class="endstop" class:hidden={containerWidth * (1 - percent) < 14}></div>
|
|
101
|
+
{/if}
|
|
102
|
+
<div class="handle"></div>
|
|
51
103
|
{#if showValue}
|
|
52
|
-
<div class="value m3-font-label-large"
|
|
104
|
+
<div class="value m3-font-label-large">{format(value)}</div>
|
|
53
105
|
{/if}
|
|
54
106
|
</div>
|
|
55
107
|
|
|
@@ -57,13 +109,101 @@
|
|
|
57
109
|
:root {
|
|
58
110
|
--m3-slider-track-out-shape: 0.5rem;
|
|
59
111
|
--m3-slider-track-in-shape: 0.125rem;
|
|
60
|
-
--m3-slider-
|
|
112
|
+
--m3-slider-handle-shape: var(--m3-util-rounding-full);
|
|
61
113
|
}
|
|
114
|
+
|
|
62
115
|
.m3-container {
|
|
63
116
|
position: relative;
|
|
64
|
-
height:
|
|
117
|
+
height: var(--handle-height);
|
|
65
118
|
min-width: 10rem;
|
|
119
|
+
print-color-adjust: exact;
|
|
120
|
+
-webkit-print-color-adjust: exact;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.m3-container.xs {
|
|
124
|
+
--track-height: 1rem;
|
|
125
|
+
--handle-height: 2.75rem;
|
|
126
|
+
--track-radius: var(--m3-util-rounding-small);
|
|
127
|
+
--icon-size: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.m3-container.s {
|
|
131
|
+
--track-height: 1.5rem;
|
|
132
|
+
--handle-height: 2.75rem;
|
|
133
|
+
--track-radius: var(--m3-util-rounding-small);
|
|
134
|
+
--icon-size: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.m3-container.m {
|
|
138
|
+
--track-height: 2.5rem;
|
|
139
|
+
--handle-height: 3.25rem;
|
|
140
|
+
--track-radius: var(--m3-util-rounding-medium);
|
|
141
|
+
--icon-size: 1.5rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.m3-container.l {
|
|
145
|
+
--track-height: 3.5rem;
|
|
146
|
+
--handle-height: 4.25rem;
|
|
147
|
+
--track-radius: var(--m3-util-rounding-large);
|
|
148
|
+
--icon-size: 1.5rem;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.m3-container.xl {
|
|
152
|
+
--track-height: 6rem;
|
|
153
|
+
--handle-height: 6.75rem;
|
|
154
|
+
--track-radius: var(--m3-util-rounding-extra-large);
|
|
155
|
+
--icon-size: 2rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.m3-container :global(.leading) {
|
|
159
|
+
position: absolute;
|
|
160
|
+
width: var(--icon-size);
|
|
161
|
+
height: var(--icon-size);
|
|
162
|
+
top: 50%;
|
|
163
|
+
left: 0.25rem;
|
|
164
|
+
translate: 0 -50%;
|
|
165
|
+
pointer-events: none;
|
|
166
|
+
color: rgb(var(--m3-scheme-secondary-container));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.m3-container :global(.leading.pop) {
|
|
170
|
+
left: var(--percent);
|
|
171
|
+
margin-left: 0.625rem;
|
|
172
|
+
color: rgb(var(--m3-scheme-primary));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.m3-container :global(.trailing) {
|
|
176
|
+
position: absolute;
|
|
177
|
+
width: var(--icon-size);
|
|
178
|
+
height: var(--icon-size);
|
|
179
|
+
top: 50%;
|
|
180
|
+
right: 0.25rem;
|
|
181
|
+
translate: 0 -50%;
|
|
182
|
+
pointer-events: none;
|
|
183
|
+
color: rgb(var(--m3-scheme-primary));
|
|
66
184
|
}
|
|
185
|
+
|
|
186
|
+
.m3-container :global(.trailing.pop) {
|
|
187
|
+
right: abs(100% - var(--percent));
|
|
188
|
+
margin-right: 0.625rem;
|
|
189
|
+
color: rgb(var(--m3-scheme-secondary-container));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.endstop {
|
|
193
|
+
position: absolute;
|
|
194
|
+
width: 4px;
|
|
195
|
+
height: 4px;
|
|
196
|
+
border-radius: var(--m3-util-rounding-full);
|
|
197
|
+
top: 50%;
|
|
198
|
+
right: 2px;
|
|
199
|
+
translate: -50% -50%;
|
|
200
|
+
background-color: rgb(var(--m3-scheme-primary));
|
|
201
|
+
pointer-events: none;
|
|
202
|
+
&.hidden {
|
|
203
|
+
display: none;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
67
207
|
input {
|
|
68
208
|
position: absolute;
|
|
69
209
|
left: -0.5rem;
|
|
@@ -85,15 +225,16 @@
|
|
|
85
225
|
top: 50%;
|
|
86
226
|
translate: 0 -50%;
|
|
87
227
|
width: calc(var(--percent) - 0.375rem);
|
|
88
|
-
height:
|
|
228
|
+
height: var(--track-height);
|
|
89
229
|
pointer-events: none;
|
|
90
230
|
|
|
91
231
|
background-color: rgb(var(--m3-scheme-primary));
|
|
92
|
-
border-start-start-radius: var(--
|
|
93
|
-
border-end-start-radius: var(--
|
|
232
|
+
border-start-start-radius: var(--track-radius);
|
|
233
|
+
border-end-start-radius: var(--track-radius);
|
|
94
234
|
border-start-end-radius: var(--m3-slider-track-in-shape);
|
|
95
235
|
border-end-end-radius: var(--m3-slider-track-in-shape);
|
|
96
236
|
}
|
|
237
|
+
|
|
97
238
|
.track::after {
|
|
98
239
|
position: absolute;
|
|
99
240
|
content: " ";
|
|
@@ -101,22 +242,50 @@
|
|
|
101
242
|
top: 50%;
|
|
102
243
|
translate: 0 -50%;
|
|
103
244
|
width: calc(100% - var(--percent) - 0.375rem);
|
|
104
|
-
height:
|
|
245
|
+
height: var(--track-height);
|
|
105
246
|
pointer-events: none;
|
|
106
247
|
|
|
107
|
-
background-color: rgb(var(--m3-scheme-
|
|
248
|
+
background-color: rgb(var(--m3-scheme-secondary-container));
|
|
108
249
|
border-start-start-radius: var(--m3-slider-track-in-shape);
|
|
109
250
|
border-end-start-radius: var(--m3-slider-track-in-shape);
|
|
110
|
-
border-start-end-radius: var(--
|
|
111
|
-
border-end-end-radius: var(--
|
|
251
|
+
border-start-end-radius: var(--track-radius);
|
|
252
|
+
border-end-end-radius: var(--track-radius);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.tick {
|
|
256
|
+
position: absolute;
|
|
257
|
+
width: 4px;
|
|
258
|
+
height: 4px;
|
|
259
|
+
border-radius: var(--m3-util-rounding-full);
|
|
260
|
+
top: 50%;
|
|
261
|
+
left: calc(50% + (100% - 0.75rem) * var(--x));
|
|
262
|
+
translate: -50% -50%;
|
|
263
|
+
background-color: rgb(var(--m3-scheme-secondary-container));
|
|
264
|
+
pointer-events: none;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.tick.hidden {
|
|
268
|
+
display: none;
|
|
112
269
|
}
|
|
113
270
|
|
|
114
|
-
.
|
|
271
|
+
.tick.inactive {
|
|
272
|
+
background-color: rgb(var(--m3-scheme-primary));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
:global(.leading) ~ .tick:nth-child(1 of div.tick) {
|
|
276
|
+
display: none;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
:global(.trailing) ~ .tick:nth-last-child(1 of div.tick) {
|
|
280
|
+
display: none;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.handle {
|
|
115
284
|
position: absolute;
|
|
116
285
|
left: var(--percent);
|
|
117
286
|
translate: -50% 0;
|
|
118
287
|
width: 0.25rem;
|
|
119
|
-
height:
|
|
288
|
+
height: var(--handle-height);
|
|
120
289
|
border-radius: 1.25rem;
|
|
121
290
|
background-color: rgb(var(--m3-scheme-primary));
|
|
122
291
|
|
|
@@ -134,23 +303,27 @@
|
|
|
134
303
|
color: rgb(var(--m3-scheme-inverse-on-surface));
|
|
135
304
|
width: 3rem;
|
|
136
305
|
padding: 0.75rem 1rem;
|
|
137
|
-
border-radius: var(--m3-slider-
|
|
306
|
+
border-radius: var(--m3-slider-handle-shape);
|
|
138
307
|
|
|
139
308
|
left: var(--percent);
|
|
140
|
-
|
|
309
|
+
bottom: calc(var(--handle-height) + 4px);
|
|
141
310
|
translate: -50% 0;
|
|
142
311
|
|
|
143
312
|
opacity: 0;
|
|
144
313
|
pointer-events: none;
|
|
145
314
|
transition: opacity var(--m3-util-easing);
|
|
315
|
+
z-index: 1;
|
|
146
316
|
}
|
|
147
317
|
|
|
148
|
-
input:focus-visible ~ .
|
|
149
|
-
outline:
|
|
150
|
-
outline-
|
|
318
|
+
input:focus-visible ~ .handle {
|
|
319
|
+
outline: solid;
|
|
320
|
+
outline-color: rgb(var(--m3-scheme-on-secondary-container));
|
|
321
|
+
outline-width: 4px;
|
|
322
|
+
outline-offset: 5px;
|
|
323
|
+
z-index: 2;
|
|
151
324
|
}
|
|
152
|
-
input:focus-visible ~ .
|
|
153
|
-
input:enabled:active ~ .
|
|
325
|
+
input:focus-visible ~ .handle,
|
|
326
|
+
input:enabled:active ~ .handle {
|
|
154
327
|
width: 0.125rem;
|
|
155
328
|
}
|
|
156
329
|
input:enabled:hover ~ .value,
|
|
@@ -168,14 +341,17 @@
|
|
|
168
341
|
input:disabled ~ .track::after {
|
|
169
342
|
background-color: rgb(var(--m3-scheme-on-surface) / 0.12);
|
|
170
343
|
}
|
|
171
|
-
input:disabled ~ .
|
|
344
|
+
input:disabled ~ .handle {
|
|
172
345
|
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
173
346
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
347
|
+
input:disabled ~ .tick {
|
|
348
|
+
background-color: rgb(var(--m3-scheme-inverse-on-surface) / 0.66);
|
|
349
|
+
}
|
|
350
|
+
input:disabled ~ .tick.inactive,
|
|
351
|
+
input:disabled ~ .endstop {
|
|
352
|
+
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
178
353
|
}
|
|
354
|
+
|
|
179
355
|
@media screen and (forced-colors: active) {
|
|
180
356
|
.track::before {
|
|
181
357
|
background-color: selecteditem;
|
|
@@ -183,7 +359,7 @@
|
|
|
183
359
|
.track::after {
|
|
184
360
|
background-color: canvastext;
|
|
185
361
|
}
|
|
186
|
-
.
|
|
362
|
+
.handle {
|
|
187
363
|
background-color: selecteditem;
|
|
188
364
|
}
|
|
189
365
|
.value {
|
|
@@ -196,7 +372,7 @@
|
|
|
196
372
|
input:disabled + .track::after {
|
|
197
373
|
background-color: graytext;
|
|
198
374
|
}
|
|
199
|
-
input:disabled ~ .
|
|
375
|
+
input:disabled ~ .handle {
|
|
200
376
|
background-color: graytext;
|
|
201
377
|
}
|
|
202
378
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HTMLInputAttributes } from "svelte/elements";
|
|
2
|
+
import type { IconifyIcon } from "@iconify/types";
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
value: number;
|
|
4
5
|
min?: number;
|
|
@@ -6,8 +7,13 @@ type $$ComponentProps = {
|
|
|
6
7
|
step?: number | "any";
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
showValue?: boolean;
|
|
10
|
+
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
11
|
+
leadingIcon?: IconifyIcon;
|
|
12
|
+
trailingIcon?: IconifyIcon;
|
|
13
|
+
ticks?: boolean;
|
|
14
|
+
endStops?: boolean;
|
|
9
15
|
format?: (n: number) => string;
|
|
10
|
-
} & HTMLInputAttributes
|
|
16
|
+
} & Omit<HTMLInputAttributes, "size">;
|
|
11
17
|
declare const Slider: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
12
18
|
type Slider = ReturnType<typeof Slider>;
|
|
13
19
|
export default Slider;
|
|
@@ -1,242 +1,12 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@deprecated use Slider directly instead
|
|
4
|
+
-->
|
|
1
5
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
6
|
+
import type { ComponentProps } from "svelte";
|
|
7
|
+
import Slider from "./Slider.svelte";
|
|
4
8
|
|
|
5
|
-
let
|
|
6
|
-
value = $bindable(),
|
|
7
|
-
min = 0,
|
|
8
|
-
max = 100,
|
|
9
|
-
step,
|
|
10
|
-
disabled = false,
|
|
11
|
-
showValue = true,
|
|
12
|
-
format = (n: number) => {
|
|
13
|
-
return n.toFixed(0);
|
|
14
|
-
},
|
|
15
|
-
...extra
|
|
16
|
-
}: {
|
|
17
|
-
value: number;
|
|
18
|
-
min?: number;
|
|
19
|
-
max?: number;
|
|
20
|
-
step: number;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
showValue?: boolean;
|
|
23
|
-
format?: (n: number) => string;
|
|
24
|
-
} & HTMLInputAttributes = $props();
|
|
25
|
-
|
|
26
|
-
const valueDisplayed = new Spring(value, { stiffness: 0.3, damping: 1 });
|
|
27
|
-
const updateValue = (e: Event & { currentTarget: EventTarget & HTMLInputElement }) => {
|
|
28
|
-
const newValue = Number(e.currentTarget.value);
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
value = newValue;
|
|
31
|
-
valueDisplayed.target = newValue;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const range = $derived(max - min);
|
|
35
|
-
const percent = $derived((valueDisplayed.current - min) / range);
|
|
36
|
-
const ticks = $derived.by(() => {
|
|
37
|
-
const ticksList = [];
|
|
38
|
-
for (let i = 0; i <= range; i += step) {
|
|
39
|
-
ticksList.push((i / range) * 100);
|
|
40
|
-
}
|
|
41
|
-
return ticksList;
|
|
42
|
-
});
|
|
9
|
+
let props: Omit<ComponentProps<typeof Slider>, "ticks"> = $props();
|
|
43
10
|
</script>
|
|
44
11
|
|
|
45
|
-
<
|
|
46
|
-
<input
|
|
47
|
-
type="range"
|
|
48
|
-
oninput={updateValue}
|
|
49
|
-
value={valueDisplayed.current}
|
|
50
|
-
{min}
|
|
51
|
-
{max}
|
|
52
|
-
{step}
|
|
53
|
-
{disabled}
|
|
54
|
-
{...extra}
|
|
55
|
-
/>
|
|
56
|
-
<div class="track"></div>
|
|
57
|
-
{#each ticks as tick}
|
|
58
|
-
<div
|
|
59
|
-
class="tick"
|
|
60
|
-
class:hidden={Math.abs(tick / 100 - valueDisplayed.current / range) < 0.01}
|
|
61
|
-
class:inactive={tick / 100 > valueDisplayed.current / range}
|
|
62
|
-
style:--x={tick / 100 - 0.5}
|
|
63
|
-
></div>
|
|
64
|
-
{/each}
|
|
65
|
-
<div class="thumb"></div>
|
|
66
|
-
{#if showValue}
|
|
67
|
-
<div class="value m3-font-label-large"><span>{format(value)}</span></div>
|
|
68
|
-
{/if}
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<style>
|
|
72
|
-
:root {
|
|
73
|
-
--m3-slider-track-out-shape: 0.5rem;
|
|
74
|
-
--m3-slider-track-in-shape: 0.125rem;
|
|
75
|
-
--m3-slider-thumb-shape: var(--m3-util-rounding-full);
|
|
76
|
-
}
|
|
77
|
-
.m3-container {
|
|
78
|
-
position: relative;
|
|
79
|
-
height: 2.75rem;
|
|
80
|
-
min-width: 10rem;
|
|
81
|
-
}
|
|
82
|
-
input {
|
|
83
|
-
position: absolute;
|
|
84
|
-
left: -0.5rem;
|
|
85
|
-
right: -0.5rem;
|
|
86
|
-
width: calc(100% + 1rem);
|
|
87
|
-
height: 100%;
|
|
88
|
-
|
|
89
|
-
opacity: 0;
|
|
90
|
-
appearance: none;
|
|
91
|
-
margin: 0;
|
|
92
|
-
-webkit-tap-highlight-color: transparent;
|
|
93
|
-
cursor: pointer;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.track::before {
|
|
97
|
-
position: absolute;
|
|
98
|
-
content: " ";
|
|
99
|
-
left: 0;
|
|
100
|
-
top: 50%;
|
|
101
|
-
translate: 0 -50%;
|
|
102
|
-
width: calc(var(--percent) - 0.375rem);
|
|
103
|
-
height: 1rem;
|
|
104
|
-
pointer-events: none;
|
|
105
|
-
|
|
106
|
-
background-color: rgb(var(--m3-scheme-primary));
|
|
107
|
-
border-start-start-radius: var(--m3-slider-track-out-shape);
|
|
108
|
-
border-end-start-radius: var(--m3-slider-track-out-shape);
|
|
109
|
-
border-start-end-radius: var(--m3-slider-track-in-shape);
|
|
110
|
-
border-end-end-radius: var(--m3-slider-track-in-shape);
|
|
111
|
-
}
|
|
112
|
-
.track::after {
|
|
113
|
-
position: absolute;
|
|
114
|
-
content: " ";
|
|
115
|
-
right: 0;
|
|
116
|
-
top: 50%;
|
|
117
|
-
translate: 0 -50%;
|
|
118
|
-
width: calc(100% - var(--percent) - 0.375rem);
|
|
119
|
-
height: 1rem;
|
|
120
|
-
pointer-events: none;
|
|
121
|
-
|
|
122
|
-
background-color: rgb(var(--m3-scheme-primary-container));
|
|
123
|
-
border-start-start-radius: var(--m3-slider-track-in-shape);
|
|
124
|
-
border-end-start-radius: var(--m3-slider-track-in-shape);
|
|
125
|
-
border-start-end-radius: var(--m3-slider-track-out-shape);
|
|
126
|
-
border-end-end-radius: var(--m3-slider-track-out-shape);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.tick {
|
|
130
|
-
position: absolute;
|
|
131
|
-
width: 4px;
|
|
132
|
-
height: 4px;
|
|
133
|
-
border-radius: var(--m3-util-rounding-full);
|
|
134
|
-
top: 50%;
|
|
135
|
-
left: calc(50% + (100% - 0.75rem) * var(--x));
|
|
136
|
-
translate: -50% -50%;
|
|
137
|
-
background-color: rgb(var(--m3-scheme-primary-container));
|
|
138
|
-
pointer-events: none;
|
|
139
|
-
}
|
|
140
|
-
.tick.hidden {
|
|
141
|
-
display: none;
|
|
142
|
-
}
|
|
143
|
-
.tick.inactive {
|
|
144
|
-
background-color: rgb(var(--m3-scheme-primary));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.thumb {
|
|
148
|
-
position: absolute;
|
|
149
|
-
left: var(--percent);
|
|
150
|
-
translate: -50% 0;
|
|
151
|
-
width: 0.25rem;
|
|
152
|
-
height: 2.75rem;
|
|
153
|
-
border-radius: 1.25rem;
|
|
154
|
-
background-color: rgb(var(--m3-scheme-primary));
|
|
155
|
-
|
|
156
|
-
pointer-events: none;
|
|
157
|
-
transition: width var(--m3-util-easing);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.value {
|
|
161
|
-
display: flex;
|
|
162
|
-
align-items: center;
|
|
163
|
-
justify-content: center;
|
|
164
|
-
position: absolute;
|
|
165
|
-
|
|
166
|
-
background-color: rgb(var(--m3-scheme-inverse-surface));
|
|
167
|
-
color: rgb(var(--m3-scheme-inverse-on-surface));
|
|
168
|
-
width: 3rem;
|
|
169
|
-
padding: 0.75rem 1rem;
|
|
170
|
-
border-radius: var(--m3-slider-thumb-shape);
|
|
171
|
-
|
|
172
|
-
left: var(--percent);
|
|
173
|
-
top: -3rem;
|
|
174
|
-
translate: -50% 0;
|
|
175
|
-
|
|
176
|
-
opacity: 0;
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
transition: opacity var(--m3-util-easing);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
input:focus-visible ~ .thumb {
|
|
182
|
-
outline: auto;
|
|
183
|
-
outline-offset: 0.5rem;
|
|
184
|
-
}
|
|
185
|
-
input:focus-visible ~ .thumb,
|
|
186
|
-
input:enabled:active ~ .thumb {
|
|
187
|
-
width: 0.125rem;
|
|
188
|
-
}
|
|
189
|
-
input:enabled:hover ~ .value,
|
|
190
|
-
input:enabled:focus-visible ~ .value,
|
|
191
|
-
input:enabled:active ~ .value {
|
|
192
|
-
opacity: 1;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
input:disabled {
|
|
196
|
-
cursor: auto;
|
|
197
|
-
}
|
|
198
|
-
input:disabled ~ .track::before {
|
|
199
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
200
|
-
}
|
|
201
|
-
input:disabled ~ .track::after {
|
|
202
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.12);
|
|
203
|
-
}
|
|
204
|
-
input:disabled ~ .tick {
|
|
205
|
-
background-color: rgb(var(--m3-scheme-inverse-on-surface) / 0.66);
|
|
206
|
-
}
|
|
207
|
-
input:disabled ~ .tick.inactive {
|
|
208
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
209
|
-
}
|
|
210
|
-
input:disabled ~ .thumb {
|
|
211
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.m3-container {
|
|
215
|
-
print-color-adjust: exact;
|
|
216
|
-
-webkit-print-color-adjust: exact;
|
|
217
|
-
}
|
|
218
|
-
@media screen and (forced-colors: active) {
|
|
219
|
-
.track::before {
|
|
220
|
-
background-color: selecteditem;
|
|
221
|
-
}
|
|
222
|
-
.track::after {
|
|
223
|
-
background-color: canvastext;
|
|
224
|
-
}
|
|
225
|
-
.thumb {
|
|
226
|
-
background-color: selecteditem;
|
|
227
|
-
}
|
|
228
|
-
.value {
|
|
229
|
-
border: 2px solid selecteditem;
|
|
230
|
-
overflow: hidden;
|
|
231
|
-
}
|
|
232
|
-
input:disabled + .track::before {
|
|
233
|
-
background-color: canvastext;
|
|
234
|
-
}
|
|
235
|
-
input:disabled + .track::after {
|
|
236
|
-
background-color: graytext;
|
|
237
|
-
}
|
|
238
|
-
input:disabled ~ .thumb {
|
|
239
|
-
background-color: graytext;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
</style>
|
|
12
|
+
<Slider {...props} ticks={true}></Slider>
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** @deprecated use Slider directly instead */
|
|
2
|
+
declare const SliderTicks: import("svelte").Component<Omit<{
|
|
3
3
|
value: number;
|
|
4
4
|
min?: number;
|
|
5
5
|
max?: number;
|
|
6
|
-
step
|
|
6
|
+
step?: number | "any";
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
showValue?: boolean;
|
|
9
|
+
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
10
|
+
leadingIcon?: import("@iconify/types").IconifyIcon;
|
|
11
|
+
trailingIcon?: import("@iconify/types").IconifyIcon;
|
|
12
|
+
ticks?: boolean;
|
|
13
|
+
endStops?: boolean;
|
|
9
14
|
format?: (n: number) => string;
|
|
10
|
-
} & HTMLInputAttributes
|
|
11
|
-
declare const SliderTicks: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
15
|
+
} & Omit<import("svelte/elements").HTMLInputAttributes, "size">, "ticks">, {}, "">;
|
|
12
16
|
type SliderTicks = ReturnType<typeof SliderTicks>;
|
|
13
17
|
export default SliderTicks;
|
package/package/index.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ export { default as RadioAnim3 } from "./forms/RadioAnim3.svelte";
|
|
|
35
35
|
export { default as Checkbox } from "./forms/Checkbox.svelte";
|
|
36
36
|
export { default as Switch } from "./forms/Switch.svelte";
|
|
37
37
|
export { default as Slider } from "./forms/Slider.svelte";
|
|
38
|
-
export { default as SliderTicks } from "./forms/SliderTicks.svelte";
|
|
39
38
|
export { default as TextField } from "./forms/TextField.svelte";
|
|
40
39
|
export { default as TextFieldMultiline } from "./forms/TextFieldMultiline.svelte";
|
|
41
40
|
export { default as TextFieldOutlined } from "./forms/TextFieldOutlined.svelte";
|
package/package/index.js
CHANGED
|
@@ -34,7 +34,6 @@ export { default as RadioAnim3 } from "./forms/RadioAnim3.svelte";
|
|
|
34
34
|
export { default as Checkbox } from "./forms/Checkbox.svelte";
|
|
35
35
|
export { default as Switch } from "./forms/Switch.svelte";
|
|
36
36
|
export { default as Slider } from "./forms/Slider.svelte";
|
|
37
|
-
export { default as SliderTicks } from "./forms/SliderTicks.svelte";
|
|
38
37
|
export { default as TextField } from "./forms/TextField.svelte";
|
|
39
38
|
export { default as TextFieldMultiline } from "./forms/TextFieldMultiline.svelte";
|
|
40
39
|
export { default as TextFieldOutlined } from "./forms/TextFieldOutlined.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "m3-svelte",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"license": "Apache-2.0 OR GPL-3.0-only",
|
|
5
5
|
"repository": "KTibow/m3-svelte",
|
|
6
6
|
"author": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@iconify/types": "^2.0.0",
|
|
33
33
|
"@ktibow/iconset-material-symbols": "^0.0.1752989765",
|
|
34
34
|
"@ktibow/material-color-utilities-nightly": "^0.3.11753062248503",
|
|
35
|
-
"svelte": "^5.
|
|
35
|
+
"svelte": "^5.37.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/compat": "^1.3.1",
|