noph-ui 0.4.1 → 0.4.2
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.
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
noAsterisk = false,
|
|
17
17
|
variant = 'filled',
|
|
18
18
|
placeholder = ' ',
|
|
19
|
+
element = $bindable(),
|
|
19
20
|
...attributes
|
|
20
21
|
}: TextFieldProps = $props()
|
|
21
22
|
|
|
22
|
-
let contentEl: HTMLInputElement | HTMLTextAreaElement | undefined = $state()
|
|
23
23
|
let errorTextRaw = $state(errorText)
|
|
24
24
|
|
|
25
25
|
$effect(() => {
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (element) {
|
|
27
|
+
element.form?.addEventListener('reset', () => {
|
|
28
28
|
error = false
|
|
29
29
|
value = ''
|
|
30
30
|
})
|
|
31
|
-
|
|
31
|
+
element.addEventListener('invalid', (event) => {
|
|
32
32
|
event.preventDefault()
|
|
33
33
|
const { currentTarget } = event as Event & {
|
|
34
34
|
currentTarget: HTMLInputElement | HTMLTextAreaElement
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
})
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
element.addEventListener('change', (event) => {
|
|
46
46
|
const { currentTarget } = event as Event & {
|
|
47
47
|
currentTarget: HTMLInputElement | HTMLTextAreaElement
|
|
48
48
|
}
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
if (attributes.disabled) {
|
|
69
69
|
return
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
element?.focus()
|
|
72
72
|
}}
|
|
73
73
|
>
|
|
74
74
|
<div
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
<textarea
|
|
118
118
|
{...attributes}
|
|
119
119
|
bind:value
|
|
120
|
-
bind:this={
|
|
120
|
+
bind:this={element}
|
|
121
121
|
class="input"
|
|
122
122
|
aria-label={label}
|
|
123
123
|
{placeholder}
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
<input
|
|
134
134
|
{...attributes}
|
|
135
135
|
bind:value
|
|
136
|
-
bind:this={
|
|
136
|
+
bind:this={element}
|
|
137
137
|
class="input"
|
|
138
138
|
{placeholder}
|
|
139
139
|
aria-label={label}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TextFieldProps } from './types.ts';
|
|
2
|
-
declare const TextField: import("svelte").Component<TextFieldProps, {}, "value">;
|
|
2
|
+
declare const TextField: import("svelte").Component<TextFieldProps, {}, "element" | "value">;
|
|
3
3
|
type TextField = ReturnType<typeof TextField>;
|
|
4
4
|
export default TextField;
|
|
@@ -12,6 +12,7 @@ export interface InputFieldProps extends Omit<HTMLInputAttributes, 'class'> {
|
|
|
12
12
|
start?: Snippet;
|
|
13
13
|
end?: Snippet;
|
|
14
14
|
noAsterisk?: boolean;
|
|
15
|
+
element?: HTMLInputElement;
|
|
15
16
|
}
|
|
16
17
|
export interface TextAreaFieldProps extends Omit<HTMLTextareaAttributes, 'class'> {
|
|
17
18
|
label?: string;
|
|
@@ -25,5 +26,6 @@ export interface TextAreaFieldProps extends Omit<HTMLTextareaAttributes, 'class'
|
|
|
25
26
|
start?: Snippet;
|
|
26
27
|
end?: Snippet;
|
|
27
28
|
noAsterisk?: boolean;
|
|
29
|
+
element?: HTMLTextAreaElement;
|
|
28
30
|
}
|
|
29
31
|
export type TextFieldProps = InputFieldProps | TextAreaFieldProps;
|