@onsvisual/svelte-components 0.1.30 → 0.1.31

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.
@@ -53,6 +53,14 @@
53
53
  * @type {boolean}
54
54
  */
55
55
  export let compact = false;
56
+
57
+ function doChange(e) {
58
+ if (Array.isArray(group)) {
59
+ if (checked) group = [...group, value];
60
+ else group = group.filter((d) => d != value);
61
+ }
62
+ dispatch("change", e);
63
+ }
56
64
  </script>
57
65
 
58
66
  <span
@@ -61,31 +69,17 @@
61
69
  class:ons-checkboxes__item--no-border="{compact}"
62
70
  >
63
71
  <span class="ons-checkbox" class:ons-checkbox--no-border="{compact}">
64
- {#if Array.isArray(group)}
65
- <input
66
- type="checkbox"
67
- id="{id}"
68
- name="{name}"
69
- value="{value}"
70
- bind:group="{group}"
71
- class="ons-checkbox__input ons-js-checkbox"
72
- disabled="{disabled}"
73
- aria-disabled="{disabled}"
74
- on:change="{(e) => dispatch('change', e)}"
75
- />
76
- {:else}
77
- <input
78
- type="checkbox"
79
- id="{id}"
80
- name="{name}"
81
- value="{value}"
82
- bind:checked="{checked}"
83
- class="ons-checkbox__input ons-js-checkbox"
84
- disabled="{disabled}"
85
- aria-disabled="{disabled}"
86
- on:change="{(e) => dispatch('change', e)}"
87
- />
88
- {/if}
72
+ <input
73
+ type="checkbox"
74
+ id="{id}"
75
+ name="{name}"
76
+ value="{value}"
77
+ bind:checked="{checked}"
78
+ class="ons-checkbox__input ons-js-checkbox"
79
+ disabled="{disabled}"
80
+ aria-disabled="{disabled}"
81
+ on:change="{doChange}"
82
+ />
89
83
  <label
90
84
  class="ons-checkbox__label"
91
85
  class:ons-label--with-description="{description}"
@@ -27,7 +27,7 @@
27
27
  <slot />
28
28
  {#if items}
29
29
  {#each items as item, i}
30
- <Checkbox {...item} group="{value}" compact="{compact}" on:change />
30
+ <Checkbox {...item} bind:group="{value}" compact="{compact}" on:change />
31
31
  {/each}
32
32
  {/if}
33
33
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",