noph-ui 0.17.5 → 0.17.7

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.
@@ -15,7 +15,7 @@
15
15
  title,
16
16
  element = $bindable(),
17
17
  disabled,
18
- selected = false,
18
+ selected = $bindable(false),
19
19
  selectedIcon,
20
20
  keepTooltipOnClick,
21
21
  onclick,
@@ -23,7 +23,6 @@
23
23
  }: IconButtonProps = $props()
24
24
 
25
25
  const uid = $props.id()
26
- let selectedState = $state(!toggle || selected)
27
26
  let touchEl: HTMLSpanElement | undefined = $state()
28
27
 
29
28
  const isButton = (obj: unknown): obj is HTMLButtonAttributes => {
@@ -39,7 +38,7 @@
39
38
  <Ripple forElement={touchEl} />
40
39
  <span class="np-touch" bind:this={touchEl}></span>
41
40
  {/if}
42
- {#if selectedIcon && selectedState}
41
+ {#if selectedIcon && selected}
43
42
  {@render selectedIcon()}
44
43
  {:else if children}
45
44
  {@render children()}
@@ -50,13 +49,13 @@
50
49
  <button
51
50
  aria-describedby={title ? uid : attributes['aria-describedby']}
52
51
  aria-label={title || attributes['aria-label']}
53
- aria-pressed={selectedState}
52
+ aria-pressed={selected}
54
53
  {...attributes as HTMLButtonAttributes}
55
54
  {disabled}
56
55
  bind:this={element}
57
56
  onclick={(event) => {
58
57
  if (toggle) {
59
- selectedState = !selectedState
58
+ selected = !selected
60
59
  }
61
60
  ;(onclick as MouseEventHandler<HTMLButtonElement>)?.(event)
62
61
  }}
@@ -64,9 +63,7 @@
64
63
  'np-icon-button',
65
64
  disabled ? `${variant}-disabled disabled` : `${variant} enabled`,
66
65
  toggle && 'toggle',
67
- selectedState &&
68
- ((variant !== 'outlined' && variant !== 'text') || toggle || selected) &&
69
- 'selected',
66
+ (selected || (variant !== 'outlined' && variant !== 'text' && !toggle)) && 'selected',
70
67
  attributes.class,
71
68
  ]}
72
69
  >
@@ -82,9 +79,7 @@
82
79
  'np-icon-button',
83
80
  variant,
84
81
  'enabled',
85
- selectedState &&
86
- ((variant !== 'outlined' && variant !== 'text') || toggle || selected) &&
87
- 'selected',
82
+ (selected || (variant !== 'outlined' && variant !== 'text' && !toggle)) && 'selected',
88
83
  attributes.class,
89
84
  ]}
90
85
  >
@@ -1,4 +1,4 @@
1
1
  import type { IconButtonProps } from './types.ts';
2
- declare const IconButton: import("svelte").Component<IconButtonProps, {}, "element">;
2
+ declare const IconButton: import("svelte").Component<IconButtonProps, {}, "element" | "selected">;
3
3
  type IconButton = ReturnType<typeof IconButton>;
4
4
  export default IconButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {