noph-ui 0.9.15 → 0.9.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.
@@ -44,26 +44,42 @@
44
44
  {#if !option.disabled}
45
45
  <Ripple forceHover={i === hoverState} />
46
46
  {/if}
47
- {#if multiSelect}
48
- <input
49
- type="checkbox"
50
- onclick={option.onclick}
51
- bind:group
52
- onfocus={(event) => {
53
- if (event) hoverState = i
54
- }}
55
- onblur={() => (hoverState = -1)}
56
- {name}
57
- aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
58
- value={option.label}
59
- disabled={option.disabled}
60
- checked={option.selected}
61
- />
47
+ {#if group}
48
+ {#if multiSelect}
49
+ <input
50
+ type="checkbox"
51
+ onclick={option.onclick}
52
+ bind:group
53
+ onfocus={(event) => {
54
+ if (event) hoverState = i
55
+ }}
56
+ onblur={() => (hoverState = -1)}
57
+ {name}
58
+ aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
59
+ value={option.label}
60
+ disabled={option.disabled}
61
+ checked={option.selected}
62
+ />
63
+ {:else}
64
+ <input
65
+ type="radio"
66
+ onclick={option.onclick}
67
+ bind:group
68
+ onfocus={(event) => {
69
+ if (event) hoverState = i
70
+ }}
71
+ onblur={() => (hoverState = -1)}
72
+ {name}
73
+ aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
74
+ value={option.label}
75
+ disabled={option.disabled}
76
+ checked={option.selected}
77
+ />
78
+ {/if}
62
79
  {:else}
63
80
  <input
64
- type="radio"
81
+ type={multiSelect ? 'checkbox' : 'radio'}
65
82
  onclick={option.onclick}
66
- bind:group
67
83
  onfocus={(event) => {
68
84
  if (event) hoverState = i
69
85
  }}
@@ -45,7 +45,7 @@ export interface SegmentedButtonProps extends HTMLAttributes<HTMLDivElement> {
45
45
  icon?: Snippet;
46
46
  onclick?: (event: Event) => void;
47
47
  }[];
48
- group?: string | number;
48
+ group?: string | number | null;
49
49
  element?: HTMLElement;
50
50
  }
51
51
  export {};
@@ -15,15 +15,26 @@
15
15
  <div {style} class={['np-host', attributes.class]} bind:this={element}>
16
16
  <div class="np-container">
17
17
  <label class="np-input-wrapper">
18
- <input
19
- {...attributes}
20
- class="np-input"
21
- type="checkbox"
22
- bind:indeterminate
23
- bind:checked
24
- bind:group
25
- aria-checked={indeterminate ? 'mixed' : undefined}
26
- />
18
+ {#if group}
19
+ <input
20
+ {...attributes}
21
+ class="np-input"
22
+ type="checkbox"
23
+ bind:indeterminate
24
+ bind:checked
25
+ bind:group
26
+ aria-checked={indeterminate ? 'mixed' : undefined}
27
+ />
28
+ {:else}
29
+ <input
30
+ {...attributes}
31
+ class="np-input"
32
+ type="checkbox"
33
+ bind:indeterminate
34
+ bind:checked
35
+ aria-checked={indeterminate ? 'mixed' : undefined}
36
+ />
37
+ {/if}
27
38
  {#if !attributes.disabled}
28
39
  <Ripple />
29
40
  {/if}
@@ -1,5 +1,5 @@
1
1
  import type { HTMLInputAttributes } from 'svelte/elements';
2
2
  export interface CheckboxProps extends Omit<HTMLInputAttributes, 'type'> {
3
3
  element?: HTMLElement;
4
- group?: string | number;
4
+ group?: string | number | null;
5
5
  }
@@ -15,6 +15,11 @@
15
15
  </script>
16
16
 
17
17
  <label {style} class={['np-host', attributes.class]} bind:this={element}>
18
+ {#if group}
19
+ <input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} bind:group />
20
+ {:else}
21
+ <input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} />
22
+ {/if}
18
23
  <input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} bind:group />
19
24
  <div class="np-container" aria-hidden="true">
20
25
  {#if !attributes.disabled}
@@ -1,5 +1,5 @@
1
1
  import type { HTMLInputAttributes } from 'svelte/elements';
2
2
  export interface RadioProps extends Omit<HTMLInputAttributes, 'type'> {
3
3
  element?: HTMLElement;
4
- group?: string | number;
4
+ group?: string | number | null;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.9.15",
3
+ "version": "0.9.16",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {