@geoffcox/sterling-svelte 2.0.12 → 2.0.14
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/Radio.svelte +13 -3
- package/dist/Radio.svelte.d.ts +1 -1
- package/dist/Slider.svelte +11 -8
- package/package.json +2 -2
package/dist/Radio.svelte
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
let {
|
|
10
10
|
id,
|
|
11
11
|
children,
|
|
12
|
-
checked
|
|
12
|
+
checked,
|
|
13
13
|
class: _class,
|
|
14
14
|
disabled = false,
|
|
15
15
|
group = $bindable(),
|
|
16
|
+
value,
|
|
16
17
|
...rest
|
|
17
18
|
}: RadioProps = $props();
|
|
18
19
|
|
|
@@ -45,12 +46,21 @@
|
|
|
45
46
|
-->
|
|
46
47
|
<div
|
|
47
48
|
class={['sterling-radio', _class]}
|
|
48
|
-
class:checked
|
|
49
|
+
class:checked={group === value}
|
|
49
50
|
class:disabled
|
|
50
51
|
class:using-keyboard={$usingKeyboard}
|
|
51
52
|
>
|
|
52
53
|
<div class="container">
|
|
53
|
-
<input
|
|
54
|
+
<input
|
|
55
|
+
bind:this={inputRef}
|
|
56
|
+
{checked}
|
|
57
|
+
{disabled}
|
|
58
|
+
bind:group
|
|
59
|
+
{id}
|
|
60
|
+
type="radio"
|
|
61
|
+
{value}
|
|
62
|
+
{...rest}
|
|
63
|
+
/>
|
|
54
64
|
<div class="indicator"></div>
|
|
55
65
|
</div>
|
|
56
66
|
{#if children}
|
package/dist/Radio.svelte.d.ts
CHANGED
package/dist/Slider.svelte
CHANGED
|
@@ -15,16 +15,18 @@
|
|
|
15
15
|
precision = 0,
|
|
16
16
|
reverse,
|
|
17
17
|
step = 1,
|
|
18
|
-
value = $bindable(
|
|
18
|
+
value = $bindable(),
|
|
19
19
|
vertical,
|
|
20
20
|
...rest
|
|
21
21
|
}: SliderProps = $props();
|
|
22
22
|
|
|
23
23
|
const ensureValueValid = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value
|
|
24
|
+
if (value !== undefined) {
|
|
25
|
+
const clamped = Math.max(min, Math.min(max, value));
|
|
26
|
+
const newValue = precision !== undefined ? round(clamped, precision) : clamped;
|
|
27
|
+
if (value !== newValue) {
|
|
28
|
+
value = newValue;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
sliderRef?.parentElement?.focus(options);
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
let ratio = $derived(max - min > 0 ? (value - min) / (max - min) : 0);
|
|
54
|
+
let ratio = $derived(value !== undefined && max - min > 0 ? (value - min) / (max - min) : 0);
|
|
53
55
|
|
|
54
56
|
// when value changes, ensure it is valid right away
|
|
55
57
|
const setValue = (newValue: number) => {
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
|
|
72
74
|
// Raise change event when value changes
|
|
73
75
|
$effect(() => {
|
|
74
|
-
onChange?.(value);
|
|
76
|
+
value && onChange?.(value);
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
// ----- Size tracking ----- //
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
};
|
|
140
142
|
|
|
141
143
|
const onKeyDown: KeyboardEventHandler<HTMLDivElement> = (event) => {
|
|
142
|
-
if (!disabled && !event.ctrlKey && !event.shiftKey && !event.altKey) {
|
|
144
|
+
if (!disabled && value !== undefined && !event.ctrlKey && !event.shiftKey && !event.altKey) {
|
|
143
145
|
let change = 0;
|
|
144
146
|
|
|
145
147
|
if (vertical) {
|
|
@@ -180,6 +182,7 @@
|
|
|
180
182
|
class={['sterling-slider', _class]}
|
|
181
183
|
class:disabled
|
|
182
184
|
class:horizontal={!vertical}
|
|
185
|
+
class:no-value={value === undefined}
|
|
183
186
|
class:reverse
|
|
184
187
|
class:using-keyboard={$usingKeyboard}
|
|
185
188
|
class:vertical
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"author": "Geoff Cox",
|
|
5
5
|
"description": "A modern, accessible, and lightweight component library for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@eslint/js": "^9.18.0",
|
|
75
75
|
"@fontsource/atkinson-hyperlegible": "^5.1.1",
|
|
76
76
|
"@fontsource/source-code-pro": "^4.5.14",
|
|
77
|
-
"@geoffcox/sterling-svelte-themes": "^2.0.
|
|
77
|
+
"@geoffcox/sterling-svelte-themes": "^2.0.12",
|
|
78
78
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
79
79
|
"@sveltejs/kit": "^2.16.0",
|
|
80
80
|
"@sveltejs/package": "^2.0.0",
|