@classic-homes/theme-svelte 0.1.39 → 0.1.41

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.
@@ -26,9 +26,25 @@
26
26
  ...restProps
27
27
  }: Props = $props();
28
28
 
29
+ // Track if change was from user interaction (click)
30
+ let isUserInteraction = false;
31
+
32
+ function handleClick() {
33
+ isUserInteraction = true;
34
+ }
35
+
29
36
  function handleCheckedChange(newChecked: boolean) {
37
+ // Guard against no-op mutations AND non-user-initiated changes
38
+ // This prevents prop -> onCheckedChange -> checked = -> ... loops
39
+ if (!isUserInteraction || newChecked === checked) {
40
+ isUserInteraction = false;
41
+ return;
42
+ }
43
+
44
+ // Only update state and notify if genuine user-initiated change
30
45
  checked = newChecked;
31
46
  onchange?.(newChecked);
47
+ isUserInteraction = false;
32
48
  }
33
49
  </script>
34
50
 
@@ -39,6 +55,7 @@
39
55
  {name}
40
56
  {value}
41
57
  {id}
58
+ onclick={handleClick}
42
59
  onCheckedChange={handleCheckedChange}
43
60
  class={cn(
44
61
  'peer relative inline-flex h-7 w-12 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",