@geoffcox/sterling-svelte 2.0.14 → 2.0.16

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
@@ -1,15 +1,16 @@
1
1
  <svelte:options runes={true} />
2
2
 
3
3
  <script lang="ts">
4
+ import type { ChangeEventHandler } from 'svelte/elements';
4
5
  import { usingKeyboard } from './mediaQueries/usingKeyboard';
5
6
  import type { RadioProps } from './Radio.types';
7
+ import { onMount } from 'svelte';
6
8
 
7
9
  const uuid = $props.id();
8
10
 
9
11
  let {
10
12
  id,
11
13
  children,
12
- checked,
13
14
  class: _class,
14
15
  disabled = false,
15
16
  group = $bindable(),
@@ -25,8 +26,6 @@
25
26
  }
26
27
  });
27
28
 
28
- // ----- Methods ----- //
29
-
30
29
  export const blur = () => {
31
30
  inputRef?.blur();
32
31
  };
@@ -38,6 +37,12 @@
38
37
  export const focus = (options?: FocusOptions) => {
39
38
  inputRef?.focus(options);
40
39
  };
40
+
41
+ const onChange: ChangeEventHandler<HTMLInputElement> = (e) => {
42
+ if (e.currentTarget.checked) {
43
+ group = value;
44
+ }
45
+ };
41
46
  </script>
42
47
 
43
48
  <!--
@@ -53,13 +58,14 @@
53
58
  <div class="container">
54
59
  <input
55
60
  bind:this={inputRef}
56
- {checked}
61
+ checked={group === value}
57
62
  {disabled}
58
- bind:group
63
+ {group}
59
64
  {id}
60
65
  type="radio"
61
66
  {value}
62
67
  {...rest}
68
+ onchange={onChange}
63
69
  />
64
70
  <div class="indicator"></div>
65
71
  </div>
@@ -1,6 +1,5 @@
1
- import type { RadioProps } from './Radio.types';
2
1
  /** A styled HTML input type=radio element with optional label. */
3
- declare const Radio: import("svelte").Component<RadioProps, {
2
+ declare const Radio: import("svelte").Component<import("svelte/elements").HTMLInputAttributes, {
4
3
  blur: () => void;
5
4
  click: () => void;
6
5
  focus: (options?: FocusOptions) => void;
@@ -1,4 +1,2 @@
1
1
  import type { HTMLInputAttributes } from 'svelte/elements';
2
- export type RadioProps = HTMLInputAttributes & {
3
- group?: any | null;
4
- };
2
+ export type RadioProps = HTMLInputAttributes;
@@ -73,7 +73,7 @@
73
73
 
74
74
  // Raise change event when value changes
75
75
  $effect(() => {
76
- value && onChange?.(value);
76
+ onChange?.(value);
77
77
  });
78
78
 
79
79
  // ----- Size tracking ----- //
@@ -165,7 +165,7 @@
165
165
  }
166
166
 
167
167
  if (change !== 0) {
168
- setValue(value + change);
168
+ setValue((value || 0) + change);
169
169
  event.preventDefault();
170
170
  event.stopPropagation();
171
171
  }
@@ -8,5 +8,5 @@ export type SliderProps = HTMLAttributes<HTMLDivElement> & {
8
8
  step?: number;
9
9
  value?: number;
10
10
  vertical?: boolean | null;
11
- onChange?: (value: number) => void;
11
+ onChange?: (value?: number) => void;
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoffcox/sterling-svelte",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "author": "Geoff Cox",
5
5
  "description": "A modern, accessible, and lightweight component library for Svelte.",
6
6
  "license": "MIT",