noph-ui 0.29.4 → 0.30.0
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.
- package/dist/chip/InputChip.svelte +29 -57
- package/dist/list/Item.svelte +7 -3
- package/dist/list/types.d.ts +3 -0
- package/dist/menu/types.d.ts +3 -1
- package/dist/snackbar/Snackbar.svelte +4 -3
- package/dist/snackbar/Snackbar.svelte.d.ts +1 -1
- package/dist/snackbar/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import IconButton from '../button/IconButton.svelte'
|
|
3
3
|
import CloseIcon from '../icons/CloseIcon.svelte'
|
|
4
4
|
import Ripple from '../ripple/Ripple.svelte'
|
|
5
|
-
import { onMount } from 'svelte'
|
|
6
5
|
import type { InputChipProps } from './types.ts'
|
|
7
6
|
|
|
8
7
|
let {
|
|
@@ -19,26 +18,6 @@
|
|
|
19
18
|
}: InputChipProps = $props()
|
|
20
19
|
|
|
21
20
|
let chipLabel: HTMLDivElement | undefined = $state()
|
|
22
|
-
let visible = $state(false)
|
|
23
|
-
|
|
24
|
-
onMount(() => {
|
|
25
|
-
const observer = new IntersectionObserver((entries) => {
|
|
26
|
-
entries.forEach((entry) => {
|
|
27
|
-
if (entry.isIntersecting) {
|
|
28
|
-
visible = true
|
|
29
|
-
observer.disconnect()
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
if (element) {
|
|
35
|
-
observer.observe(element)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return () => {
|
|
39
|
-
observer.disconnect()
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
21
|
</script>
|
|
43
22
|
|
|
44
23
|
<div
|
|
@@ -55,44 +34,37 @@
|
|
|
55
34
|
attributes.class,
|
|
56
35
|
]}
|
|
57
36
|
>
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
</div>
|
|
64
|
-
{/if}
|
|
65
|
-
<div class="np-chip-label">{label || value}</div>
|
|
66
|
-
<input type="hidden" {value} {name} {disabled} />
|
|
67
|
-
</div>
|
|
68
|
-
{#if !disabled}
|
|
69
|
-
<Ripple forElement={chipLabel} />
|
|
37
|
+
<div bind:this={chipLabel} class={['np-input-chip-label']}>
|
|
38
|
+
{#if icon}
|
|
39
|
+
<div class="np-chip-icon">
|
|
40
|
+
{@render icon()}
|
|
41
|
+
</div>
|
|
70
42
|
{/if}
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
aria-label={ariaLabelRemove}
|
|
77
|
-
onclick={(
|
|
78
|
-
event: MouseEvent & {
|
|
79
|
-
currentTarget: EventTarget & HTMLButtonElement
|
|
80
|
-
},
|
|
81
|
-
) => {
|
|
82
|
-
if (element === undefined) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
onremove?.(event)
|
|
86
|
-
}}
|
|
87
|
-
>
|
|
88
|
-
<CloseIcon />
|
|
89
|
-
</IconButton>
|
|
90
|
-
{:else}
|
|
91
|
-
<div class="np-skeleton">
|
|
92
|
-
{label}
|
|
93
|
-
<input type="hidden" {value} {name} {disabled} />
|
|
94
|
-
</div>
|
|
43
|
+
<div class="np-chip-label">{label || value}</div>
|
|
44
|
+
<input type="hidden" {value} {name} {disabled} />
|
|
45
|
+
</div>
|
|
46
|
+
{#if !disabled}
|
|
47
|
+
<Ripple forElement={chipLabel} />
|
|
95
48
|
{/if}
|
|
49
|
+
<IconButton
|
|
50
|
+
{disabled}
|
|
51
|
+
type="button"
|
|
52
|
+
size="xs"
|
|
53
|
+
--np-icon-button-icon-size="1.125rem"
|
|
54
|
+
aria-label={ariaLabelRemove}
|
|
55
|
+
onclick={(
|
|
56
|
+
event: MouseEvent & {
|
|
57
|
+
currentTarget: EventTarget & HTMLButtonElement
|
|
58
|
+
},
|
|
59
|
+
) => {
|
|
60
|
+
if (element === undefined) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
onremove?.(event)
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<CloseIcon />
|
|
67
|
+
</IconButton>
|
|
96
68
|
</div>
|
|
97
69
|
|
|
98
70
|
<style>
|
package/dist/list/Item.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Ripple from '../ripple/Ripple.svelte'
|
|
3
|
+
import { onMount } from 'svelte'
|
|
3
4
|
import type { FocusEventHandler } from 'svelte/elements'
|
|
4
5
|
import type { ItemProps } from './types.ts'
|
|
5
|
-
import { onMount } from 'svelte'
|
|
6
6
|
|
|
7
7
|
let {
|
|
8
8
|
selected = false,
|
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
onfocus,
|
|
15
15
|
onblur,
|
|
16
16
|
softFocus = false,
|
|
17
|
+
lazy = false,
|
|
17
18
|
...attributes
|
|
18
19
|
}: ItemProps = $props()
|
|
19
20
|
|
|
20
21
|
let focused = $derived(softFocus)
|
|
21
|
-
let visible = $state(
|
|
22
|
+
let visible = $state(!lazy)
|
|
22
23
|
let element: HTMLButtonElement | HTMLAnchorElement | HTMLDivElement | undefined = $state()
|
|
23
24
|
let observer: IntersectionObserver | undefined
|
|
24
25
|
onMount(() => {
|
|
26
|
+
if (!lazy) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
25
29
|
observer = new IntersectionObserver((entries) => {
|
|
26
30
|
entries.forEach((entry) => {
|
|
27
31
|
if (entry.isIntersecting) {
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
return () => observer?.disconnect()
|
|
35
39
|
})
|
|
36
40
|
$effect(() => {
|
|
37
|
-
if (element) {
|
|
41
|
+
if (element && lazy) {
|
|
38
42
|
observer?.observe(element)
|
|
39
43
|
}
|
|
40
44
|
})
|
package/dist/list/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface ButtonProps extends HTMLButtonAttributes {
|
|
|
7
7
|
variant: 'button';
|
|
8
8
|
supportingText?: Snippet;
|
|
9
9
|
softFocus?: boolean;
|
|
10
|
+
lazy?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface AnchorProps extends HTMLAnchorAttributes {
|
|
12
13
|
selected?: boolean;
|
|
@@ -16,6 +17,7 @@ interface AnchorProps extends HTMLAnchorAttributes {
|
|
|
16
17
|
variant: 'link';
|
|
17
18
|
supportingText?: Snippet;
|
|
18
19
|
softFocus?: boolean;
|
|
20
|
+
lazy?: boolean;
|
|
19
21
|
}
|
|
20
22
|
interface TextProps extends HTMLAttributes<HTMLDivElement> {
|
|
21
23
|
selected?: boolean;
|
|
@@ -25,6 +27,7 @@ interface TextProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
25
27
|
variant?: 'text';
|
|
26
28
|
supportingText?: Snippet;
|
|
27
29
|
softFocus?: boolean;
|
|
30
|
+
lazy?: boolean;
|
|
28
31
|
}
|
|
29
32
|
export type ItemProps = ButtonProps | AnchorProps | TextProps;
|
|
30
33
|
export type ListItemProps = ButtonProps | AnchorProps | TextProps;
|
package/dist/menu/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
export interface MenuProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
children: Snippet;
|
|
5
5
|
anchor?: HTMLElement | undefined;
|
|
@@ -13,6 +13,7 @@ interface ButtonProps extends HTMLButtonAttributes {
|
|
|
13
13
|
start?: Snippet;
|
|
14
14
|
end?: Snippet;
|
|
15
15
|
supportingText?: Snippet;
|
|
16
|
+
lazy?: boolean;
|
|
16
17
|
}
|
|
17
18
|
interface AnchorProps extends HTMLAnchorAttributes {
|
|
18
19
|
selected?: boolean;
|
|
@@ -20,6 +21,7 @@ interface AnchorProps extends HTMLAnchorAttributes {
|
|
|
20
21
|
end?: Snippet;
|
|
21
22
|
disabled?: boolean;
|
|
22
23
|
supportingText?: Snippet;
|
|
24
|
+
lazy?: boolean;
|
|
23
25
|
}
|
|
24
26
|
export type MenuItemProps = ButtonProps | AnchorProps;
|
|
25
27
|
export {};
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
showPopover = $bindable(),
|
|
16
16
|
hidePopover = $bindable(),
|
|
17
|
+
open = $bindable(false),
|
|
17
18
|
onbeforetoggle,
|
|
18
19
|
timeout = 4000,
|
|
19
20
|
element = $bindable(),
|
|
@@ -42,10 +43,10 @@
|
|
|
42
43
|
aria-labelledby="np-snackbar-label-{uid}"
|
|
43
44
|
onbeforetoggle={(event) => {
|
|
44
45
|
let { newState } = event
|
|
45
|
-
|
|
46
|
+
open = newState === 'open'
|
|
47
|
+
if (!open) {
|
|
46
48
|
clearTimeout(timeoutId)
|
|
47
|
-
}
|
|
48
|
-
if (newState === 'open' && timeout > 0) {
|
|
49
|
+
} else if (timeout > 0) {
|
|
49
50
|
timeoutId = setTimeout(() => {
|
|
50
51
|
element?.hidePopover()
|
|
51
52
|
}, timeout)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SnackbarProps } from './types.ts';
|
|
2
|
-
declare const Snackbar: import("svelte").Component<SnackbarProps, {}, "element" | "showPopover" | "hidePopover">;
|
|
2
|
+
declare const Snackbar: import("svelte").Component<SnackbarProps, {}, "element" | "showPopover" | "hidePopover" | "open">;
|
|
3
3
|
type Snackbar = ReturnType<typeof Snackbar>;
|
|
4
4
|
export default Snackbar;
|
package/dist/snackbar/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
export interface SnackbarProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
label: string;
|
|
5
|
+
open?: boolean;
|
|
5
6
|
supportingText?: string | undefined;
|
|
6
7
|
actionLabel?: string | undefined;
|
|
7
8
|
onActionClick?: (event: Event) => void;
|