noph-ui 0.16.4 → 0.16.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.
- package/dist/chip/InputChip.svelte +64 -30
- package/dist/list/Item.svelte +26 -4
- package/dist/select/Select.svelte +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
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'
|
|
5
6
|
import type { InputChipProps } from './types.ts'
|
|
6
7
|
|
|
7
8
|
let {
|
|
@@ -18,6 +19,24 @@
|
|
|
18
19
|
}: InputChipProps = $props()
|
|
19
20
|
|
|
20
21
|
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 () => observer.disconnect()
|
|
39
|
+
})
|
|
21
40
|
</script>
|
|
22
41
|
|
|
23
42
|
<div
|
|
@@ -34,41 +53,56 @@
|
|
|
34
53
|
attributes.class,
|
|
35
54
|
]}
|
|
36
55
|
>
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
{#if visible}
|
|
57
|
+
<div bind:this={chipLabel} class={['np-input-chip-label']}>
|
|
58
|
+
{#if icon}
|
|
59
|
+
<div class="np-chip-icon">
|
|
60
|
+
{@render icon()}
|
|
61
|
+
</div>
|
|
62
|
+
{/if}
|
|
63
|
+
<div class="np-chip-label">{label || value}</div>
|
|
64
|
+
<input type="hidden" {value} {name} {disabled} />
|
|
65
|
+
</div>
|
|
66
|
+
{#if !disabled}
|
|
67
|
+
<Ripple forElement={chipLabel} />
|
|
42
68
|
{/if}
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
<IconButton
|
|
70
|
+
{disabled}
|
|
71
|
+
type="button"
|
|
72
|
+
--np-icon-button-container-height="1.75rem"
|
|
73
|
+
--np-icon-button-container-width="1.75rem"
|
|
74
|
+
--np-icon-button-icon-size="1.125rem"
|
|
75
|
+
aria-label={ariaLabelRemove}
|
|
76
|
+
onclick={(
|
|
77
|
+
event: MouseEvent & {
|
|
78
|
+
currentTarget: EventTarget & HTMLButtonElement
|
|
79
|
+
},
|
|
80
|
+
) => {
|
|
81
|
+
if (element === undefined) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
onremove?.(event)
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<CloseIcon />
|
|
88
|
+
</IconButton>
|
|
89
|
+
{:else}
|
|
90
|
+
<div class="np-skeleton">{label}</div>
|
|
48
91
|
{/if}
|
|
49
|
-
<IconButton
|
|
50
|
-
{disabled}
|
|
51
|
-
type="button"
|
|
52
|
-
--np-icon-button-container-height="1.75rem"
|
|
53
|
-
--np-icon-button-container-width="1.75rem"
|
|
54
|
-
--np-icon-button-icon-size="1.125rem"
|
|
55
|
-
aria-label={ariaLabelRemove}
|
|
56
|
-
onclick={(
|
|
57
|
-
event: MouseEvent & {
|
|
58
|
-
currentTarget: EventTarget & HTMLButtonElement
|
|
59
|
-
},
|
|
60
|
-
) => {
|
|
61
|
-
if (element === undefined) {
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
onremove?.(event)
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
<CloseIcon />
|
|
68
|
-
</IconButton>
|
|
69
92
|
</div>
|
|
70
93
|
|
|
71
94
|
<style>
|
|
95
|
+
.np-skeleton {
|
|
96
|
+
height: 2rem;
|
|
97
|
+
line-height: 1.25rem;
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
font-weight: 500;
|
|
100
|
+
opacity: 0;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
padding-left: 1rem;
|
|
104
|
+
padding-right: 1rem;
|
|
105
|
+
}
|
|
72
106
|
.np-input-chip {
|
|
73
107
|
position: relative;
|
|
74
108
|
display: inline-flex;
|
package/dist/list/Item.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import Ripple from '../ripple/Ripple.svelte'
|
|
3
3
|
import type { FocusEventHandler } from 'svelte/elements'
|
|
4
4
|
import type { ItemProps } from './types.ts'
|
|
5
|
+
import { onMount } from 'svelte'
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
selected = false,
|
|
@@ -16,7 +17,24 @@
|
|
|
16
17
|
}: ItemProps = $props()
|
|
17
18
|
|
|
18
19
|
let focused = $state(false)
|
|
20
|
+
let visible = $state(false)
|
|
19
21
|
let element: HTMLButtonElement | HTMLAnchorElement | undefined = $state()
|
|
22
|
+
onMount(() => {
|
|
23
|
+
const observer = new IntersectionObserver((entries) => {
|
|
24
|
+
entries.forEach((entry) => {
|
|
25
|
+
if (entry.isIntersecting) {
|
|
26
|
+
visible = true
|
|
27
|
+
observer.disconnect()
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
if (element) {
|
|
33
|
+
observer.observe(element)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return () => observer.disconnect()
|
|
37
|
+
})
|
|
20
38
|
</script>
|
|
21
39
|
|
|
22
40
|
{#snippet content()}
|
|
@@ -67,8 +85,10 @@
|
|
|
67
85
|
class={['np-item', selected && 'selected', attributes.class]}
|
|
68
86
|
bind:this={element}
|
|
69
87
|
>
|
|
70
|
-
{
|
|
71
|
-
|
|
88
|
+
{#if visible}
|
|
89
|
+
{@render content()}
|
|
90
|
+
<Ripple forceHover={focused} />
|
|
91
|
+
{/if}
|
|
72
92
|
</button>
|
|
73
93
|
{:else if attributes.variant === 'link'}
|
|
74
94
|
<a
|
|
@@ -84,8 +104,10 @@
|
|
|
84
104
|
class={['np-item', selected && 'selected', attributes.class]}
|
|
85
105
|
bind:this={element}
|
|
86
106
|
>
|
|
87
|
-
{
|
|
88
|
-
|
|
107
|
+
{#if visible}
|
|
108
|
+
{@render content()}
|
|
109
|
+
<Ripple forceHover={focused} />
|
|
110
|
+
{/if}
|
|
89
111
|
</a>
|
|
90
112
|
{/if}
|
|
91
113
|
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
let selectedOption = $state(options.filter((option) => option.selected))
|
|
46
46
|
|
|
47
|
-
let useVirtualList = $derived(options.length >
|
|
47
|
+
let useVirtualList = $derived(options.length > 4000)
|
|
48
48
|
|
|
49
49
|
let errorTextRaw: string = $state(errorText)
|
|
50
50
|
let errorRaw = $state(error)
|