m3-svelte 5.3.6 → 5.6.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/package/buttons/Button.svelte +4 -11
- package/package/buttons/Button.svelte.d.ts +3 -6
- package/package/buttons/FAB.svelte +0 -3
- package/package/containers/Card.svelte +0 -1
- package/package/containers/Dialog.svelte +35 -37
- package/package/containers/Dialog.svelte.d.ts +4 -0
- package/package/containers/ListItem.svelte +0 -1
- package/package/containers/MenuItem.svelte +0 -1
- package/package/containers/Snackbar.svelte +0 -1
- package/package/forms/Checkbox.svelte +1 -1
- package/package/forms/Chip.svelte +20 -14
- package/package/forms/Chip.svelte.d.ts +3 -3
- package/package/forms/DateField.svelte +0 -1
- package/package/forms/DateFieldOutlined.svelte +0 -1
- package/package/forms/RadioAnim1.svelte +1 -2
- package/package/forms/RadioAnim2.svelte +1 -2
- package/package/forms/RadioAnim3.svelte +1 -2
- package/package/forms/Select.svelte +228 -0
- package/package/forms/Select.svelte.d.ts +16 -0
- package/package/forms/SelectOutlined.svelte +226 -0
- package/package/forms/SelectOutlined.svelte.d.ts +16 -0
- package/package/forms/Slider.svelte +127 -148
- package/package/forms/Slider.svelte.d.ts +1 -1
- package/package/forms/SliderTicks.svelte +2 -2
- package/package/forms/SliderTicks.svelte.d.ts +2 -2
- package/package/forms/Switch.svelte +30 -6
- package/package/forms/Switch.svelte.d.ts +4 -0
- package/package/forms/TextField.svelte +4 -4
- package/package/forms/TextFieldMultiline.svelte +4 -3
- package/package/forms/TextFieldOutlined.svelte +7 -4
- package/package/forms/TextFieldOutlinedMultiline.svelte +7 -3
- package/package/forms/_picker/FocusPicker.svelte +0 -1
- package/package/forms/_picker/Header.svelte +0 -1
- package/package/forms/_picker/Item.svelte +0 -1
- package/package/index.d.ts +13 -10
- package/package/index.js +13 -10
- package/package/misc/_icon.svelte +14 -1
- package/package/misc/styles.css +2 -1
- package/package/misc/typing-utils.d.ts +3 -1
- package/package/nav/NavCMLX.svelte +1 -1
- package/package/nav/NavCMLXItem.svelte +7 -7
- package/package/nav/Tabs.svelte +0 -1
- package/package/nav/TabsLink.svelte +0 -1
- package/package/nav/VariableTabs.svelte +0 -1
- package/package/nav/VariableTabsLink.svelte +0 -1
- package/package/utils/badge.d.ts +11 -0
- package/package/utils/badge.js +30 -0
- package/package.json +10 -10
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconifyIcon } from "@iconify/types";
|
|
3
|
+
import type { HTMLOptionAttributes, HTMLSelectAttributes } from "svelte/elements";
|
|
4
|
+
import Layer from "../misc/Layer.svelte";
|
|
5
|
+
import Icon from "../misc/_icon.svelte";
|
|
6
|
+
|
|
7
|
+
type Option = { icon?: IconifyIcon; text: string; value: string } & HTMLOptionAttributes;
|
|
8
|
+
let {
|
|
9
|
+
label,
|
|
10
|
+
options,
|
|
11
|
+
width = "auto",
|
|
12
|
+
value = $bindable(),
|
|
13
|
+
...extra
|
|
14
|
+
}: {
|
|
15
|
+
label: string;
|
|
16
|
+
options: Option[];
|
|
17
|
+
width?: string;
|
|
18
|
+
value: string;
|
|
19
|
+
} & HTMLSelectAttributes = $props();
|
|
20
|
+
const id = $props.id();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#snippet render(text: string)}
|
|
24
|
+
<span>{text}</span>
|
|
25
|
+
{/snippet}
|
|
26
|
+
<div
|
|
27
|
+
class="m3-container"
|
|
28
|
+
class:enabled={!extra.disabled}
|
|
29
|
+
style:align-self={width == "auto" ? "start" : undefined}
|
|
30
|
+
>
|
|
31
|
+
<select class="m3-font-body-large" style:--width={width} bind:value {id} {...extra}>
|
|
32
|
+
{#each options as { icon, text, ...extra }, i (i)}
|
|
33
|
+
<option class="focus-inset" {...extra}>
|
|
34
|
+
<Layer />
|
|
35
|
+
{#if icon}
|
|
36
|
+
<Icon {icon} width="1.5rem" height="1.5rem" />
|
|
37
|
+
{/if}
|
|
38
|
+
{@render render(text)}
|
|
39
|
+
</option>
|
|
40
|
+
{/each}
|
|
41
|
+
</select>
|
|
42
|
+
<div class="layer"></div>
|
|
43
|
+
<label for={id} class="m3-font-body-small">
|
|
44
|
+
{label}
|
|
45
|
+
</label>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
/*
|
|
50
|
+
want to customize the label's background?
|
|
51
|
+
do this: <SelectOutlined --m3-util-background="rgb(var(--m3-scheme-surface-container))" />
|
|
52
|
+
*/
|
|
53
|
+
:root {
|
|
54
|
+
--m3-menu-shape: var(--m3-util-rounding-extra-small);
|
|
55
|
+
--m3-field-outlined-shape: var(--m3-util-rounding-extra-small);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.m3-container {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
position: relative;
|
|
62
|
+
--secondary-color: rgb(var(--m3-scheme-on-surface-variant));
|
|
63
|
+
--outline-color: rgb(var(--m3-scheme-outline));
|
|
64
|
+
&.enabled {
|
|
65
|
+
&:hover {
|
|
66
|
+
--secondary-color: rgb(var(--m3-scheme-on-surface));
|
|
67
|
+
--outline-color: rgb(var(--m3-scheme-on-surface));
|
|
68
|
+
}
|
|
69
|
+
&:focus-within {
|
|
70
|
+
--secondary-color: rgb(var(--m3-scheme-primary));
|
|
71
|
+
--outline-color: rgb(var(--m3-scheme-primary));
|
|
72
|
+
.layer {
|
|
73
|
+
border-width: 0.125rem;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.layer {
|
|
79
|
+
position: absolute;
|
|
80
|
+
inset: 0;
|
|
81
|
+
border: 1px solid var(--outline-color);
|
|
82
|
+
border-radius: var(--m3-field-outlined-shape);
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
transition: all 100ms;
|
|
85
|
+
}
|
|
86
|
+
label {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 0;
|
|
89
|
+
inset-inline-start: 0.75rem;
|
|
90
|
+
translate: 0 -50%;
|
|
91
|
+
color: var(--secondary-color);
|
|
92
|
+
background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
|
|
93
|
+
padding: 0 0.25rem;
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
transition: color var(--m3-util-easing-fast);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
select {
|
|
99
|
+
appearance: none;
|
|
100
|
+
}
|
|
101
|
+
select,
|
|
102
|
+
::picker(select) {
|
|
103
|
+
appearance: base-select;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
select {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
height: calc(3.5rem + var(--m3-util-density-term));
|
|
110
|
+
padding-inline: 1rem;
|
|
111
|
+
|
|
112
|
+
border-radius: var(--m3-field-outlined-shape);
|
|
113
|
+
background-color: transparent;
|
|
114
|
+
color: rgb(var(--m3-scheme-on-surface));
|
|
115
|
+
|
|
116
|
+
border: none;
|
|
117
|
+
outline: none;
|
|
118
|
+
position: relative;
|
|
119
|
+
|
|
120
|
+
&:enabled {
|
|
121
|
+
cursor: pointer;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
select::picker-icon {
|
|
126
|
+
scale: 1 0.6;
|
|
127
|
+
color: var(--secondary-color);
|
|
128
|
+
transition:
|
|
129
|
+
color var(--m3-util-easing-fast),
|
|
130
|
+
rotate var(--m3-util-easing-fast);
|
|
131
|
+
}
|
|
132
|
+
select:open::picker-icon {
|
|
133
|
+
rotate: 180deg;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
::picker(select) {
|
|
137
|
+
background-color: rgb(var(--m3-scheme-surface-container));
|
|
138
|
+
box-shadow: var(--m3-util-elevation-2);
|
|
139
|
+
border-radius: var(--m3-menu-shape);
|
|
140
|
+
|
|
141
|
+
box-sizing: border-box;
|
|
142
|
+
height: 0;
|
|
143
|
+
min-height: 0;
|
|
144
|
+
interpolate-size: allow-keywords;
|
|
145
|
+
overflow: hidden;
|
|
146
|
+
transition:
|
|
147
|
+
width var(--m3-util-easing-fast),
|
|
148
|
+
height var(--m3-util-easing-fast),
|
|
149
|
+
display var(--m3-util-duration-fast) allow-discrete,
|
|
150
|
+
overlay var(--m3-util-duration-fast) allow-discrete;
|
|
151
|
+
|
|
152
|
+
border: none;
|
|
153
|
+
cursor: auto;
|
|
154
|
+
}
|
|
155
|
+
select:open::picker(select) {
|
|
156
|
+
width: var(--width);
|
|
157
|
+
height: auto;
|
|
158
|
+
transition:
|
|
159
|
+
width 500ms linear,
|
|
160
|
+
height 500ms var(--m3-util-timing-function-emphasized-decel),
|
|
161
|
+
display 500ms allow-discrete,
|
|
162
|
+
overlay 500ms allow-discrete;
|
|
163
|
+
}
|
|
164
|
+
@starting-style {
|
|
165
|
+
select:open::picker(select) {
|
|
166
|
+
width: calc-size(var(--width), size - 0.001px);
|
|
167
|
+
height: 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
option {
|
|
172
|
+
display: grid;
|
|
173
|
+
grid-template-columns: auto 1fr;
|
|
174
|
+
padding-inline: 1rem;
|
|
175
|
+
padding-block: calc(
|
|
176
|
+
(
|
|
177
|
+
3rem + var(--m3-util-density-term) -
|
|
178
|
+
(var(--m3-font-body-large-size, 1rem) * var(--m3-font-body-large-height, 1.5))
|
|
179
|
+
) /
|
|
180
|
+
2
|
|
181
|
+
);
|
|
182
|
+
&:first-child {
|
|
183
|
+
margin-top: 0.5rem;
|
|
184
|
+
}
|
|
185
|
+
&:last-child {
|
|
186
|
+
margin-bottom: 0.5rem;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
background-color: transparent;
|
|
190
|
+
&:checked {
|
|
191
|
+
background-color: rgb(var(--m3-scheme-primary-container));
|
|
192
|
+
color: rgb(var(--m3-scheme-on-primary-container));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
> *,
|
|
196
|
+
> :global(svg) {
|
|
197
|
+
grid-row: 1;
|
|
198
|
+
}
|
|
199
|
+
&::checkmark {
|
|
200
|
+
opacity: 0;
|
|
201
|
+
grid-column: 2;
|
|
202
|
+
}
|
|
203
|
+
&:has(> :global(svg)) {
|
|
204
|
+
grid-template-columns: auto auto 1fr;
|
|
205
|
+
> :global(svg) {
|
|
206
|
+
margin-right: 0.5rem;
|
|
207
|
+
}
|
|
208
|
+
&:not(:checked) > :global(svg) {
|
|
209
|
+
color: rgb(var(--m3-scheme-on-surface-variant));
|
|
210
|
+
}
|
|
211
|
+
&:checked > :global(svg) {
|
|
212
|
+
opacity: 0.8;
|
|
213
|
+
}
|
|
214
|
+
&::checkmark {
|
|
215
|
+
grid-column: 3;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
transition:
|
|
220
|
+
background-color var(--m3-util-easing-fast),
|
|
221
|
+
color var(--m3-util-easing-fast);
|
|
222
|
+
|
|
223
|
+
position: relative;
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IconifyIcon } from "@iconify/types";
|
|
2
|
+
import type { HTMLOptionAttributes, HTMLSelectAttributes } from "svelte/elements";
|
|
3
|
+
type Option = {
|
|
4
|
+
icon?: IconifyIcon;
|
|
5
|
+
text: string;
|
|
6
|
+
value: string;
|
|
7
|
+
} & HTMLOptionAttributes;
|
|
8
|
+
type $$ComponentProps = {
|
|
9
|
+
label: string;
|
|
10
|
+
options: Option[];
|
|
11
|
+
width?: string;
|
|
12
|
+
value: string;
|
|
13
|
+
} & HTMLSelectAttributes;
|
|
14
|
+
declare const SelectOutlined: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
15
|
+
type SelectOutlined = ReturnType<typeof SelectOutlined>;
|
|
16
|
+
export default SelectOutlined;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
size = "xs",
|
|
15
15
|
leadingIcon,
|
|
16
16
|
trailingIcon,
|
|
17
|
-
|
|
17
|
+
stops: _stops = false,
|
|
18
18
|
endStops = true,
|
|
19
19
|
format = (n: number) => {
|
|
20
20
|
return n.toFixed(0);
|
|
@@ -30,10 +30,12 @@
|
|
|
30
30
|
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
31
31
|
leadingIcon?: IconifyIcon;
|
|
32
32
|
trailingIcon?: IconifyIcon;
|
|
33
|
-
|
|
33
|
+
stops?: boolean;
|
|
34
34
|
endStops?: boolean;
|
|
35
35
|
format?: (n: number) => string;
|
|
36
36
|
} & Omit<HTMLInputAttributes, "size"> = $props();
|
|
37
|
+
// @ts-expect-error deprecated backwards compatibility with ticks
|
|
38
|
+
let stops = $derived(extra.ticks ? true : _stops);
|
|
37
39
|
let containerWidth = $state(600);
|
|
38
40
|
|
|
39
41
|
const valueDisplayed = new Spring(value, { stiffness: 0.3, damping: 1 });
|
|
@@ -45,23 +47,27 @@
|
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
const range = $derived(max - min);
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const handle = $derived((valueDisplayed.current - min) / range);
|
|
51
|
+
const stopList = $derived.by(() => {
|
|
52
|
+
const output: number[] = [];
|
|
53
|
+
const add = (stop: number) => {
|
|
54
|
+
if (leadingIcon && stop == 0) return;
|
|
55
|
+
if (trailingIcon && stop == 1) return;
|
|
56
|
+
output.push(stop);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (stops && typeof step == "number") {
|
|
60
|
+
for (let i = 0; i <= range; i += step) add(i / range);
|
|
61
|
+
}
|
|
62
|
+
if (endStops && !output.includes(1)) {
|
|
63
|
+
add(1);
|
|
64
|
+
}
|
|
55
65
|
|
|
56
|
-
return
|
|
66
|
+
return output;
|
|
57
67
|
});
|
|
58
68
|
</script>
|
|
59
69
|
|
|
60
|
-
<div
|
|
61
|
-
class="m3-container {size}"
|
|
62
|
-
style:--percent="{percent * 100}%"
|
|
63
|
-
bind:offsetWidth={containerWidth}
|
|
64
|
-
>
|
|
70
|
+
<div class="m3-container {size}" style:--handle={handle - 0.5} bind:offsetWidth={containerWidth}>
|
|
65
71
|
<input
|
|
66
72
|
type="range"
|
|
67
73
|
oninput={updateValue}
|
|
@@ -72,33 +78,28 @@
|
|
|
72
78
|
{disabled}
|
|
73
79
|
{...extra}
|
|
74
80
|
/>
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
<div class="track-1">
|
|
82
|
+
{#each stopList as stop}
|
|
83
|
+
<div class="stop" style:--x={stop - 0.5}></div>
|
|
84
|
+
{/each}
|
|
85
|
+
</div>
|
|
86
|
+
<div class="track-2">
|
|
87
|
+
{#each stopList as stop}
|
|
88
|
+
<div class="stop" style:--x={stop - 0.5}></div>
|
|
89
|
+
{/each}
|
|
90
|
+
</div>
|
|
77
91
|
{#if leadingIcon}
|
|
78
92
|
<Icon
|
|
79
93
|
icon={leadingIcon}
|
|
80
|
-
class={"leading" + (containerWidth *
|
|
94
|
+
class={"leading" + (containerWidth * handle < (size == "xl" ? 48 : 40) ? " pop" : "")}
|
|
81
95
|
/>
|
|
82
96
|
{/if}
|
|
83
97
|
{#if trailingIcon}
|
|
84
98
|
<Icon
|
|
85
99
|
icon={trailingIcon}
|
|
86
|
-
class={"trailing" + (containerWidth * (1 -
|
|
100
|
+
class={"trailing" + (containerWidth * (1 - handle) < (size == "xl" ? 48 : 40) ? " pop" : "")}
|
|
87
101
|
/>
|
|
88
102
|
{/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
103
|
<div class="handle"></div>
|
|
103
104
|
{#if showValue}
|
|
104
105
|
<div class="value m3-font-label-large">{format(value)}</div>
|
|
@@ -118,6 +119,11 @@
|
|
|
118
119
|
min-width: 10rem;
|
|
119
120
|
print-color-adjust: exact;
|
|
120
121
|
-webkit-print-color-adjust: exact;
|
|
122
|
+
|
|
123
|
+
--functional-width: calc(100% - 2 * (0.25rem + 0.125rem));
|
|
124
|
+
--handle-left: calc(50% + var(--functional-width) * var(--handle) - 0.125rem - 0.375rem);
|
|
125
|
+
--handle-center: calc(50% + var(--functional-width) * var(--handle));
|
|
126
|
+
--handle-right: calc(50% + var(--functional-width) * var(--handle) + 0.125rem + 0.375rem);
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
.m3-container.xs {
|
|
@@ -160,15 +166,15 @@
|
|
|
160
166
|
width: var(--icon-size);
|
|
161
167
|
height: var(--icon-size);
|
|
162
168
|
top: 50%;
|
|
163
|
-
inset-inline-start: 0
|
|
169
|
+
inset-inline-start: 0;
|
|
170
|
+
margin-inline-start: 0.25rem;
|
|
164
171
|
translate: 0 -50%;
|
|
165
172
|
pointer-events: none;
|
|
166
173
|
color: rgb(var(--m3-scheme-secondary-container));
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
.m3-container :global(.leading.pop) {
|
|
170
|
-
inset-inline-start: var(--
|
|
171
|
-
margin-inline-start: 0.625rem;
|
|
177
|
+
inset-inline-start: var(--handle-right);
|
|
172
178
|
color: rgb(var(--m3-scheme-primary));
|
|
173
179
|
}
|
|
174
180
|
|
|
@@ -177,114 +183,118 @@
|
|
|
177
183
|
width: var(--icon-size);
|
|
178
184
|
height: var(--icon-size);
|
|
179
185
|
top: 50%;
|
|
180
|
-
inset-inline-end: 0
|
|
186
|
+
inset-inline-end: 0;
|
|
187
|
+
margin-inline-end: 0.25rem;
|
|
181
188
|
translate: 0 -50%;
|
|
182
189
|
pointer-events: none;
|
|
183
190
|
color: rgb(var(--m3-scheme-primary));
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
.m3-container :global(.trailing.pop) {
|
|
187
|
-
inset-inline-end:
|
|
188
|
-
margin-inline-end: 0.625rem;
|
|
194
|
+
inset-inline-end: calc(100% - var(--handle-left));
|
|
189
195
|
color: rgb(var(--m3-scheme-secondary-container));
|
|
190
196
|
}
|
|
191
197
|
|
|
192
|
-
.endstop {
|
|
193
|
-
position: absolute;
|
|
194
|
-
width: 4px;
|
|
195
|
-
height: 4px;
|
|
196
|
-
border-radius: var(--m3-util-rounding-full);
|
|
197
|
-
top: 50%;
|
|
198
|
-
inset-inline-end: 4px;
|
|
199
|
-
translate: 0 -50%;
|
|
200
|
-
background-color: rgb(var(--m3-scheme-primary));
|
|
201
|
-
pointer-events: none;
|
|
202
|
-
&.hidden {
|
|
203
|
-
display: none;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
198
|
input {
|
|
208
199
|
position: absolute;
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
width: calc(var(--functional-width) + 1rem);
|
|
201
|
+
left: 50%;
|
|
202
|
+
translate: -50% 0;
|
|
211
203
|
height: 100%;
|
|
212
204
|
|
|
213
205
|
opacity: 0;
|
|
214
206
|
appearance: none;
|
|
215
207
|
margin: 0;
|
|
216
|
-
-webkit-tap-highlight-color: transparent;
|
|
217
|
-
cursor: pointer;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.track::before {
|
|
221
|
-
position: absolute;
|
|
222
|
-
content: " ";
|
|
223
|
-
inset-inline-start: 0;
|
|
224
|
-
top: 50%;
|
|
225
|
-
translate: 0 -50%;
|
|
226
|
-
width: calc(var(--percent) - 0.375rem);
|
|
227
|
-
height: var(--track-height);
|
|
228
|
-
pointer-events: none;
|
|
229
208
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
border-start-end-radius: var(--m3-slider-track-in-shape);
|
|
234
|
-
border-end-end-radius: var(--m3-slider-track-in-shape);
|
|
209
|
+
&:enabled {
|
|
210
|
+
cursor: pointer;
|
|
211
|
+
}
|
|
235
212
|
}
|
|
236
213
|
|
|
237
|
-
.track
|
|
214
|
+
.track-1,
|
|
215
|
+
.track-2 {
|
|
238
216
|
position: absolute;
|
|
239
|
-
|
|
240
|
-
inset-inline-end: 0;
|
|
217
|
+
inset-inline: 0;
|
|
241
218
|
top: 50%;
|
|
242
219
|
translate: 0 -50%;
|
|
243
|
-
width: calc(100% - var(--percent) - 0.375rem);
|
|
244
220
|
height: var(--track-height);
|
|
245
221
|
pointer-events: none;
|
|
222
|
+
}
|
|
223
|
+
.track-1 {
|
|
224
|
+
background-color: rgb(var(--m3-scheme-primary));
|
|
225
|
+
clip-path: inset(
|
|
226
|
+
0 calc(100% - var(--handle-left)) 0 0 round var(--track-radius)
|
|
227
|
+
var(--m3-slider-track-in-shape) var(--m3-slider-track-in-shape) var(--track-radius)
|
|
228
|
+
);
|
|
229
|
+
&:dir(rtl) {
|
|
230
|
+
clip-path: inset(
|
|
231
|
+
0 0 0 calc(100% - var(--handle-left)) round var(--m3-slider-track-in-shape)
|
|
232
|
+
var(--track-radius) var(--track-radius) var(--m3-slider-track-in-shape)
|
|
233
|
+
);
|
|
234
|
+
}
|
|
246
235
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
236
|
+
@media screen and (forced-colors: active) {
|
|
237
|
+
background-color: selecteditem;
|
|
238
|
+
}
|
|
239
|
+
&:is(input:disabled ~ .track-1) {
|
|
240
|
+
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
241
|
+
@media screen and (forced-colors: active) {
|
|
242
|
+
background-color: canvastext;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
252
245
|
}
|
|
246
|
+
.track-2 {
|
|
247
|
+
background-color: rgb(var(--m3-scheme-secondary-container));
|
|
248
|
+
clip-path: inset(
|
|
249
|
+
0 0 0 var(--handle-right) round var(--m3-slider-track-in-shape) var(--track-radius)
|
|
250
|
+
var(--track-radius) var(--m3-slider-track-in-shape)
|
|
251
|
+
);
|
|
252
|
+
&:dir(rtl) {
|
|
253
|
+
clip-path: inset(
|
|
254
|
+
0 var(--handle-right) 0 0 round var(--track-radius) var(--m3-slider-track-in-shape)
|
|
255
|
+
var(--m3-slider-track-in-shape) var(--track-radius)
|
|
256
|
+
);
|
|
257
|
+
}
|
|
253
258
|
|
|
254
|
-
|
|
259
|
+
@media screen and (forced-colors: active) {
|
|
260
|
+
background-color: canvastext;
|
|
261
|
+
}
|
|
262
|
+
&:is(input:disabled ~ .track-2) {
|
|
263
|
+
background-color: rgb(var(--m3-scheme-on-surface) / 0.12);
|
|
264
|
+
@media screen and (forced-colors: active) {
|
|
265
|
+
background-color: graytext;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
.stop {
|
|
255
270
|
position: absolute;
|
|
256
271
|
width: 4px;
|
|
257
272
|
height: 4px;
|
|
258
273
|
border-radius: var(--m3-util-rounding-full);
|
|
259
274
|
top: 50%;
|
|
260
|
-
inset-inline-start: calc(50% + (100% - 0.
|
|
275
|
+
inset-inline-start: calc(50% + (100% - 0.5rem - 0.25rem) * var(--x));
|
|
261
276
|
translate: -50% -50%;
|
|
262
277
|
&:dir(rtl) {
|
|
263
278
|
translate: 50% -50%;
|
|
264
279
|
}
|
|
265
|
-
|
|
280
|
+
&:is(.track-1 > .stop) {
|
|
281
|
+
background-color: rgb(var(--m3-scheme-on-primary));
|
|
282
|
+
&:is(input:disabled ~ .track-1 > .stop) {
|
|
283
|
+
background-color: rgb(var(--m3-scheme-inverse-on-surface));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
&:is(.track-2 > .stop) {
|
|
287
|
+
background-color: rgb(var(--m3-scheme-primary));
|
|
288
|
+
&:is(input:disabled ~ .track-2 > .stop) {
|
|
289
|
+
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
266
292
|
pointer-events: none;
|
|
267
293
|
}
|
|
268
294
|
|
|
269
|
-
.tick.hidden {
|
|
270
|
-
display: none;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.tick.inactive {
|
|
274
|
-
background-color: rgb(var(--m3-scheme-primary));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
:global(.leading) ~ .tick:nth-child(1 of div.tick) {
|
|
278
|
-
display: none;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
:global(.trailing) ~ .tick:nth-last-child(1 of div.tick) {
|
|
282
|
-
display: none;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
295
|
.handle {
|
|
286
296
|
position: absolute;
|
|
287
|
-
inset-inline-start: var(--
|
|
297
|
+
inset-inline-start: var(--handle-center);
|
|
288
298
|
translate: -50% 0;
|
|
289
299
|
&:dir(rtl) {
|
|
290
300
|
translate: 50% 0;
|
|
@@ -296,6 +306,16 @@
|
|
|
296
306
|
|
|
297
307
|
pointer-events: none;
|
|
298
308
|
transition: width var(--m3-util-easing);
|
|
309
|
+
|
|
310
|
+
@media screen and (forced-colors: active) {
|
|
311
|
+
background-color: selecteditem;
|
|
312
|
+
}
|
|
313
|
+
&:is(input:disabled ~ .handle) {
|
|
314
|
+
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
315
|
+
@media screen and (forced-colors: active) {
|
|
316
|
+
background-color: graytext;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
299
319
|
}
|
|
300
320
|
|
|
301
321
|
.value {
|
|
@@ -310,7 +330,7 @@
|
|
|
310
330
|
padding: 0.75rem 1rem;
|
|
311
331
|
border-radius: var(--m3-slider-handle-shape);
|
|
312
332
|
|
|
313
|
-
inset-inline-start: var(--
|
|
333
|
+
inset-inline-start: var(--handle-center);
|
|
314
334
|
bottom: calc(var(--handle-height) + 4px);
|
|
315
335
|
translate: -50% 0;
|
|
316
336
|
&:dir(rtl) {
|
|
@@ -321,6 +341,10 @@
|
|
|
321
341
|
pointer-events: none;
|
|
322
342
|
transition: opacity var(--m3-util-easing);
|
|
323
343
|
z-index: 1;
|
|
344
|
+
@media screen and (forced-colors: active) {
|
|
345
|
+
border: 2px solid selecteditem;
|
|
346
|
+
overflow: hidden;
|
|
347
|
+
}
|
|
324
348
|
}
|
|
325
349
|
|
|
326
350
|
input:focus-visible ~ .handle {
|
|
@@ -339,49 +363,4 @@
|
|
|
339
363
|
input:enabled:active ~ .value {
|
|
340
364
|
opacity: 1;
|
|
341
365
|
}
|
|
342
|
-
|
|
343
|
-
input:disabled {
|
|
344
|
-
cursor: auto;
|
|
345
|
-
}
|
|
346
|
-
input:disabled ~ .track::before {
|
|
347
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
348
|
-
}
|
|
349
|
-
input:disabled ~ .track::after {
|
|
350
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.12);
|
|
351
|
-
}
|
|
352
|
-
input:disabled ~ .handle {
|
|
353
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
354
|
-
}
|
|
355
|
-
input:disabled ~ .tick {
|
|
356
|
-
background-color: rgb(var(--m3-scheme-inverse-on-surface) / 0.66);
|
|
357
|
-
}
|
|
358
|
-
input:disabled ~ .tick.inactive,
|
|
359
|
-
input:disabled ~ .endstop {
|
|
360
|
-
background-color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
@media screen and (forced-colors: active) {
|
|
364
|
-
.track::before {
|
|
365
|
-
background-color: selecteditem;
|
|
366
|
-
}
|
|
367
|
-
.track::after {
|
|
368
|
-
background-color: canvastext;
|
|
369
|
-
}
|
|
370
|
-
.handle {
|
|
371
|
-
background-color: selecteditem;
|
|
372
|
-
}
|
|
373
|
-
.value {
|
|
374
|
-
border: 2px solid selecteditem;
|
|
375
|
-
overflow: hidden;
|
|
376
|
-
}
|
|
377
|
-
input:disabled + .track::before {
|
|
378
|
-
background-color: canvastext;
|
|
379
|
-
}
|
|
380
|
-
input:disabled + .track::after {
|
|
381
|
-
background-color: graytext;
|
|
382
|
-
}
|
|
383
|
-
input:disabled ~ .handle {
|
|
384
|
-
background-color: graytext;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
366
|
</style>
|
|
@@ -10,7 +10,7 @@ type $$ComponentProps = {
|
|
|
10
10
|
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
11
11
|
leadingIcon?: IconifyIcon;
|
|
12
12
|
trailingIcon?: IconifyIcon;
|
|
13
|
-
|
|
13
|
+
stops?: boolean;
|
|
14
14
|
endStops?: boolean;
|
|
15
15
|
format?: (n: number) => string;
|
|
16
16
|
} & Omit<HTMLInputAttributes, "size">;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { ComponentProps } from "svelte";
|
|
7
7
|
import Slider from "./Slider.svelte";
|
|
8
8
|
|
|
9
|
-
let props: Omit<ComponentProps<typeof Slider>, "
|
|
9
|
+
let props: Omit<ComponentProps<typeof Slider>, "stops"> = $props();
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
|
-
<Slider {...props}
|
|
12
|
+
<Slider {...props} stops={true}></Slider>
|
|
@@ -9,9 +9,9 @@ declare const SliderTicks: import("svelte").Component<Omit<{
|
|
|
9
9
|
size?: "xs" | "s" | "m" | "l" | "xl";
|
|
10
10
|
leadingIcon?: import("@iconify/types").IconifyIcon;
|
|
11
11
|
trailingIcon?: import("@iconify/types").IconifyIcon;
|
|
12
|
-
|
|
12
|
+
stops?: boolean;
|
|
13
13
|
endStops?: boolean;
|
|
14
14
|
format?: (n: number) => string;
|
|
15
|
-
} & Omit<import("svelte/elements").HTMLInputAttributes, "size">, "
|
|
15
|
+
} & Omit<import("svelte/elements").HTMLInputAttributes, "size">, "stops">, {}, "">;
|
|
16
16
|
type SliderTicks = ReturnType<typeof SliderTicks>;
|
|
17
17
|
export default SliderTicks;
|