@onsvisual/svelte-components 1.0.27 → 1.0.29

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.
@@ -77,13 +77,22 @@
77
77
  }
78
78
 
79
79
  function doChange(e) {
80
- checked = item.checked;
80
+ checked = _checked = item.checked;
81
81
  if (Array.isArray(group) && Array.isArray($checkboxes)) {
82
82
  updateGroup();
83
83
  }
84
84
  dispatch("change", { item, e });
85
85
  }
86
86
 
87
+ // Track changes to checked from bind:checked outside component
88
+ let _checked = item.checked;
89
+ function trackChecked(checked) {
90
+ if (_checked !== checked) {
91
+ item.checked = _checked = checked;
92
+ }
93
+ }
94
+ $: trackChecked(checked);
95
+
87
96
  onMount(() => {
88
97
  if (Array.isArray(group) && Array.isArray($checkboxes)) {
89
98
  const root = findAncestor(el, "ons-checkboxes__items");
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { createEventDispatcher } from "svelte";
2
+ import { onMount, createEventDispatcher } from "svelte";
3
3
 
4
4
  const dispatch = createEventDispatcher();
5
5
 
@@ -38,6 +38,12 @@
38
38
  * @type {boolean}
39
39
  */
40
40
  export let compact = false;
41
+
42
+ let el;
43
+
44
+ onMount(() => {
45
+ if (value?.id === item.id) el.checked = true;
46
+ });
41
47
  </script>
42
48
 
43
49
  <span class="ons-radios__item" class:ons-radios__item--no-border={compact}>
@@ -54,6 +60,7 @@
54
60
  dispatch("change", { value, e });
55
61
  }
56
62
  }}
63
+ bind:this={el}
57
64
  />
58
65
  <label
59
66
  class="ons-radio__label"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run build:package && npm run build:docs",