@geoffcox/sterling-svelte 2.0.13 → 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 CHANGED
@@ -9,7 +9,7 @@
9
9
  let {
10
10
  id,
11
11
  children,
12
- checked = $bindable(false),
12
+ checked,
13
13
  class: _class,
14
14
  disabled = false,
15
15
  group = $bindable(),
@@ -25,11 +25,6 @@
25
25
  }
26
26
  });
27
27
 
28
- $effect(() => {
29
- // checked isn't set by input type="radio"
30
- checked = group === value;
31
- });
32
-
33
28
  // ----- Methods ----- //
34
29
 
35
30
  export const blur = () => {
@@ -51,7 +46,7 @@
51
46
  -->
52
47
  <div
53
48
  class={['sterling-radio', _class]}
54
- class:checked
49
+ class:checked={group === value}
55
50
  class:disabled
56
51
  class:using-keyboard={$usingKeyboard}
57
52
  >
@@ -4,6 +4,6 @@ declare const Radio: import("svelte").Component<RadioProps, {
4
4
  blur: () => void;
5
5
  click: () => void;
6
6
  focus: (options?: FocusOptions) => void;
7
- }, "group" | "checked">;
7
+ }, "group">;
8
8
  type Radio = ReturnType<typeof Radio>;
9
9
  export default Radio;
@@ -15,16 +15,18 @@
15
15
  precision = 0,
16
16
  reverse,
17
17
  step = 1,
18
- value = $bindable(0),
18
+ value = $bindable(),
19
19
  vertical,
20
20
  ...rest
21
21
  }: SliderProps = $props();
22
22
 
23
23
  const ensureValueValid = () => {
24
- const clamped = Math.max(min, Math.min(max, value));
25
- const newValue = precision !== undefined ? round(clamped, precision) : clamped;
26
- if (value !== newValue) {
27
- value = newValue;
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.13",
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.7",
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",