noph-ui 0.17.0 → 0.17.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.
|
@@ -29,12 +29,15 @@
|
|
|
29
29
|
autofocus,
|
|
30
30
|
onchange,
|
|
31
31
|
oninput,
|
|
32
|
+
reportValidity = $bindable(),
|
|
33
|
+
checkValidity = $bindable(),
|
|
32
34
|
multiple,
|
|
33
35
|
clampMenuWidth = false,
|
|
34
36
|
...attributes
|
|
35
37
|
}: SelectProps = $props()
|
|
36
38
|
|
|
37
39
|
const uid = $props.id()
|
|
40
|
+
let doValidity = $state(false)
|
|
38
41
|
if (value === undefined) {
|
|
39
42
|
if (multiple) {
|
|
40
43
|
value = options.filter((option) => option.selected).map((option) => option.value)
|
|
@@ -74,6 +77,26 @@
|
|
|
74
77
|
}
|
|
75
78
|
return options.find((option) => option.value === value)?.label || ''
|
|
76
79
|
})
|
|
80
|
+
|
|
81
|
+
reportValidity = () => {
|
|
82
|
+
if (selectElement) {
|
|
83
|
+
const valid = selectElement.reportValidity()
|
|
84
|
+
if (valid) {
|
|
85
|
+
errorRaw = error
|
|
86
|
+
errorTextRaw = errorText
|
|
87
|
+
}
|
|
88
|
+
return valid
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
checkValidity = () => {
|
|
94
|
+
if (selectElement) {
|
|
95
|
+
return selectElement.checkValidity()
|
|
96
|
+
}
|
|
97
|
+
return false
|
|
98
|
+
}
|
|
99
|
+
|
|
77
100
|
$effect(() => {
|
|
78
101
|
errorRaw = error
|
|
79
102
|
errorTextRaw = errorText
|
|
@@ -107,6 +130,10 @@
|
|
|
107
130
|
}
|
|
108
131
|
event.preventDefault()
|
|
109
132
|
tick().then(() => {
|
|
133
|
+
if (doValidity && checkValidity()) {
|
|
134
|
+
errorRaw = error
|
|
135
|
+
errorTextRaw = errorText
|
|
136
|
+
}
|
|
110
137
|
selectElement?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
111
138
|
})
|
|
112
139
|
}
|
|
@@ -222,12 +249,12 @@
|
|
|
222
249
|
event.preventDefault()
|
|
223
250
|
const { currentTarget } = event
|
|
224
251
|
errorRaw = true
|
|
252
|
+
doValidity = true
|
|
225
253
|
if (errorText === '') {
|
|
226
254
|
errorTextRaw = currentTarget.validationMessage
|
|
227
255
|
}
|
|
228
256
|
if (isFirstInvalidControlInForm(currentTarget.form, currentTarget)) {
|
|
229
257
|
field?.focus()
|
|
230
|
-
menuElement?.showPopover()
|
|
231
258
|
}
|
|
232
259
|
}}
|
|
233
260
|
bind:value
|
|
@@ -251,12 +278,12 @@
|
|
|
251
278
|
event.preventDefault()
|
|
252
279
|
const { currentTarget } = event
|
|
253
280
|
errorRaw = true
|
|
281
|
+
doValidity = true
|
|
254
282
|
if (errorText === '') {
|
|
255
283
|
errorTextRaw = currentTarget.validationMessage
|
|
256
284
|
}
|
|
257
285
|
if (isFirstInvalidControlInForm(currentTarget.form, currentTarget)) {
|
|
258
286
|
field?.focus()
|
|
259
|
-
menuElement?.showPopover()
|
|
260
287
|
}
|
|
261
288
|
}}
|
|
262
289
|
bind:value
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SelectProps } from './types.ts';
|
|
2
|
-
declare const Select: import("svelte").Component<SelectProps, {}, "element" | "value">;
|
|
2
|
+
declare const Select: import("svelte").Component<SelectProps, {}, "element" | "value" | "reportValidity" | "checkValidity">;
|
|
3
3
|
type Select = ReturnType<typeof Select>;
|
|
4
4
|
export default Select;
|
package/dist/select/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TextFieldProps } from './types.ts';
|
|
2
|
-
declare const TextField: import("svelte").Component<TextFieldProps, {}, "element" | "value" | "
|
|
2
|
+
declare const TextField: import("svelte").Component<TextFieldProps, {}, "element" | "value" | "reportValidity" | "checkValidity" | "inputElement">;
|
|
3
3
|
type TextField = ReturnType<typeof TextField>;
|
|
4
4
|
export default TextField;
|