noph-ui 0.9.14 → 0.9.15

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.
@@ -8,6 +8,7 @@
8
8
  options,
9
9
  multiSelect = false,
10
10
  element = $bindable(),
11
+ group = $bindable(),
11
12
  ...attributes
12
13
  }: SegmentedButtonProps = $props()
13
14
  let hoverState = $state(-1)
@@ -43,19 +44,37 @@
43
44
  {#if !option.disabled}
44
45
  <Ripple forceHover={i === hoverState} />
45
46
  {/if}
46
- <input
47
- type={multiSelect ? 'checkbox' : 'radio'}
48
- onclick={option.onclick}
49
- onfocus={(event) => {
50
- if (event) hoverState = i
51
- }}
52
- onblur={() => (hoverState = -1)}
53
- {name}
54
- aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
55
- value={option.label}
56
- disabled={option.disabled}
57
- checked={option.selected}
58
- />
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
+ />
62
+ {:else}
63
+ <input
64
+ type="radio"
65
+ onclick={option.onclick}
66
+ bind:group
67
+ onfocus={(event) => {
68
+ if (event) hoverState = i
69
+ }}
70
+ onblur={() => (hoverState = -1)}
71
+ {name}
72
+ aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
73
+ value={option.label}
74
+ disabled={option.disabled}
75
+ checked={option.selected}
76
+ />
77
+ {/if}
59
78
  </label>
60
79
  {/each}
61
80
  </div>
@@ -1,4 +1,4 @@
1
1
  import type { SegmentedButtonProps } from './types.ts';
2
- declare const SegmentedButton: import("svelte").Component<SegmentedButtonProps, {}, "element">;
2
+ declare const SegmentedButton: import("svelte").Component<SegmentedButtonProps, {}, "element" | "group">;
3
3
  type SegmentedButton = ReturnType<typeof SegmentedButton>;
4
4
  export default SegmentedButton;
@@ -45,6 +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
49
  element?: HTMLElement;
49
50
  }
50
51
  export {};
@@ -6,6 +6,7 @@
6
6
  indeterminate = $bindable(),
7
7
  checked = $bindable(),
8
8
  element = $bindable(),
9
+ group = $bindable(),
9
10
  style,
10
11
  ...attributes
11
12
  }: CheckboxProps = $props()
@@ -20,6 +21,7 @@
20
21
  type="checkbox"
21
22
  bind:indeterminate
22
23
  bind:checked
24
+ bind:group
23
25
  aria-checked={indeterminate ? 'mixed' : undefined}
24
26
  />
25
27
  {#if !attributes.disabled}
@@ -1,4 +1,4 @@
1
1
  import type { CheckboxProps } from './types.ts';
2
- declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "element" | "checked" | "indeterminate">;
2
+ declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "element" | "group" | "checked" | "indeterminate">;
3
3
  type Checkbox = ReturnType<typeof Checkbox>;
4
4
  export default Checkbox;
@@ -1,4 +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
5
  }
@@ -6,6 +6,7 @@
6
6
  checked,
7
7
  defaultChecked,
8
8
  element = $bindable(),
9
+ group = $bindable(),
9
10
  style,
10
11
  ...attributes
11
12
  }: RadioProps = $props()
@@ -14,7 +15,7 @@
14
15
  </script>
15
16
 
16
17
  <label {style} class={['np-host', attributes.class]} bind:this={element}>
17
- <input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} />
18
+ <input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} bind:group />
18
19
  <div class="np-container" aria-hidden="true">
19
20
  {#if !attributes.disabled}
20
21
  <Ripple forElement={touchEl} class="np-radio-ripple" />
@@ -1,4 +1,4 @@
1
1
  import type { RadioProps } from './types.ts';
2
- declare const Radio: import("svelte").Component<RadioProps, {}, "element">;
2
+ declare const Radio: import("svelte").Component<RadioProps, {}, "element" | "group">;
3
3
  type Radio = ReturnType<typeof Radio>;
4
4
  export default Radio;
@@ -1,4 +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
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {