noph-ui 0.17.4 → 0.17.6
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 &&
|
|
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={
|
|
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
|
-
|
|
58
|
+
selected = !selected
|
|
60
59
|
}
|
|
61
60
|
;(onclick as MouseEventHandler<HTMLButtonElement>)?.(event)
|
|
62
61
|
}}
|
|
@@ -64,7 +63,9 @@
|
|
|
64
63
|
'np-icon-button',
|
|
65
64
|
disabled ? `${variant}-disabled disabled` : `${variant} enabled`,
|
|
66
65
|
toggle && 'toggle',
|
|
67
|
-
|
|
66
|
+
selected &&
|
|
67
|
+
((variant !== 'outlined' && variant !== 'text') || toggle || selected) &&
|
|
68
|
+
'selected',
|
|
68
69
|
attributes.class,
|
|
69
70
|
]}
|
|
70
71
|
>
|
|
@@ -80,7 +81,9 @@
|
|
|
80
81
|
'np-icon-button',
|
|
81
82
|
variant,
|
|
82
83
|
'enabled',
|
|
83
|
-
|
|
84
|
+
selected &&
|
|
85
|
+
((variant !== 'outlined' && variant !== 'text') || toggle || selected) &&
|
|
86
|
+
'selected',
|
|
84
87
|
attributes.class,
|
|
85
88
|
]}
|
|
86
89
|
>
|
|
@@ -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;
|