feat(elements): add autoSubmit bool to InputDigits

By default, InputDigits will auto submit unless autoSubmit is set to false.
This commit is contained in:
Steven Nguyen
2024-04-22 15:41:34 -07:00
parent 98b884b7eb
commit 125632728b
+5 -1
View File
@@ -10,6 +10,7 @@
export let readonly = false;
export let autofocus = false;
export let fullWidth = false;
export let autoSubmit = true;
let element: HTMLOListElement;
@@ -21,9 +22,12 @@
placeholder: '',
defaultValue: value.split(''),
onValueChange: ({ next }) => {
if (!autoSubmit) {
return next;
}
value = next.join('');
if (value.length === 6 && !autoSubmitted) {
if (value.length === length && !autoSubmitted) {
autoSubmitted = true;
const firstInputElement = element.querySelector('input');
firstInputElement?.form.requestSubmit();