noph-ui 0.10.9 → 0.10.11
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/list/Item.svelte
CHANGED
|
@@ -67,8 +67,9 @@
|
|
|
67
67
|
<button
|
|
68
68
|
{...attributes}
|
|
69
69
|
class={['np-item', selected && 'selected', attributes.class]}
|
|
70
|
-
bind:this={element}
|
|
71
|
-
|
|
70
|
+
bind:this={element}
|
|
71
|
+
>{@render content()}
|
|
72
|
+
</button>
|
|
72
73
|
{:else if attributes.variant === 'link'}
|
|
73
74
|
<a
|
|
74
75
|
{...attributes}
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
...attributes
|
|
21
21
|
}: TextFieldProps = $props()
|
|
22
22
|
|
|
23
|
+
let errorRaw: boolean = $state(error)
|
|
23
24
|
let errorTextRaw: string = $state(errorText)
|
|
24
25
|
$effect(() => {
|
|
26
|
+
errorRaw = error
|
|
25
27
|
errorTextRaw = errorText
|
|
26
28
|
})
|
|
27
29
|
let textElement: HTMLInputElement | HTMLTextAreaElement | undefined = $state()
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
$effect(() => {
|
|
30
32
|
if (textElement) {
|
|
31
33
|
textElement.form?.addEventListener('reset', () => {
|
|
32
|
-
|
|
34
|
+
errorRaw = error
|
|
33
35
|
value = ''
|
|
34
36
|
})
|
|
35
37
|
textElement.addEventListener('invalid', (event) => {
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
const { currentTarget } = event as Event & {
|
|
38
40
|
currentTarget: HTMLInputElement | HTMLTextAreaElement
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
errorRaw = true
|
|
41
43
|
if (errorText === '') {
|
|
42
44
|
errorTextRaw = currentTarget.validationMessage
|
|
43
45
|
}
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
currentTarget: HTMLInputElement | HTMLTextAreaElement
|
|
52
54
|
}
|
|
53
55
|
if (currentTarget.checkValidity()) {
|
|
54
|
-
|
|
56
|
+
errorRaw = error
|
|
55
57
|
errorTextRaw = errorText
|
|
56
58
|
}
|
|
57
59
|
})
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
>
|
|
71
73
|
<div
|
|
72
74
|
class="field"
|
|
73
|
-
class:error
|
|
75
|
+
class:error={errorRaw}
|
|
74
76
|
class:resizable={attributes.type === 'textarea'}
|
|
75
77
|
class:no-label={!label?.length}
|
|
76
78
|
class:with-start={start}
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
bind:this={textElement}
|
|
140
142
|
class="input"
|
|
141
143
|
{placeholder}
|
|
142
|
-
aria-invalid={
|
|
144
|
+
aria-invalid={errorRaw}
|
|
143
145
|
/>
|
|
144
146
|
{#if suffixText}
|
|
145
147
|
<span class="suffix">
|
|
@@ -157,10 +159,10 @@
|
|
|
157
159
|
{/if}
|
|
158
160
|
</div>
|
|
159
161
|
</div>
|
|
160
|
-
{#if supportingText || (errorTextRaw &&
|
|
161
|
-
<div class="supporting-text" role={
|
|
162
|
+
{#if supportingText || (errorTextRaw && errorRaw) || attributes.maxlength}
|
|
163
|
+
<div class="supporting-text" role={errorRaw ? 'alert' : undefined}>
|
|
162
164
|
<span>
|
|
163
|
-
{
|
|
165
|
+
{errorRaw && errorTextRaw ? errorTextRaw : supportingText}
|
|
164
166
|
</span>
|
|
165
167
|
{#if attributes.maxlength}
|
|
166
168
|
<span>{value?.length || 0}/{attributes.maxlength}</span>
|