@greghowe79/the-lib 0.7.9 → 0.8.0
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.
|
@@ -32,7 +32,8 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
|
|
|
32
32
|
const showError = error ?? internalError;
|
|
33
33
|
const inputHandler = qwik.$(async (_, elem) => {
|
|
34
34
|
if (type === "tel") {
|
|
35
|
-
|
|
35
|
+
if (!/^[0-9]*$/.test(elem.value)) return;
|
|
36
|
+
if (value) value.value = elem.value;
|
|
36
37
|
}
|
|
37
38
|
if (value) value.value = elem.value;
|
|
38
39
|
if (onInput$) {
|
|
@@ -43,19 +44,6 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
|
|
|
43
44
|
if (!error) internalError.value = result;
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
|
-
const beforeInputHandler = qwik.$((event) => {
|
|
47
|
-
const e = event;
|
|
48
|
-
if (e.data && /[^0-9]/.test(e.data)) {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const changeHandler = qwik.$((event) => {
|
|
53
|
-
const elem = event.target;
|
|
54
|
-
if (!/^[0-9]*$/.test(elem.value)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (value) value.value = elem.value;
|
|
58
|
-
});
|
|
59
47
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
60
48
|
class: "input-container",
|
|
61
49
|
children: [
|
|
@@ -115,15 +103,7 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
|
|
|
115
103
|
placeholder,
|
|
116
104
|
"bind:value": value,
|
|
117
105
|
onInput$: inputHandler,
|
|
118
|
-
onBlur$: inputHandler
|
|
119
|
-
onKeyDown$: (e) => {
|
|
120
|
-
const allowed = /[0-9]/;
|
|
121
|
-
if (!allowed.test(e.key) && e.key.length === 1) {
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
onBeforeInput$: beforeInputHandler,
|
|
126
|
-
onChange$: changeHandler
|
|
106
|
+
onBlur$: inputHandler
|
|
127
107
|
})
|
|
128
108
|
]
|
|
129
109
|
})
|
|
@@ -30,7 +30,8 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
|
|
|
30
30
|
const showError = error ?? internalError;
|
|
31
31
|
const inputHandler = $(async (_, elem) => {
|
|
32
32
|
if (type === "tel") {
|
|
33
|
-
|
|
33
|
+
if (!/^[0-9]*$/.test(elem.value)) return;
|
|
34
|
+
if (value) value.value = elem.value;
|
|
34
35
|
}
|
|
35
36
|
if (value) value.value = elem.value;
|
|
36
37
|
if (onInput$) {
|
|
@@ -41,19 +42,6 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
|
|
|
41
42
|
if (!error) internalError.value = result;
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
|
-
const beforeInputHandler = $((event) => {
|
|
45
|
-
const e = event;
|
|
46
|
-
if (e.data && /[^0-9]/.test(e.data)) {
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const changeHandler = $((event) => {
|
|
51
|
-
const elem = event.target;
|
|
52
|
-
if (!/^[0-9]*$/.test(elem.value)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (value) value.value = elem.value;
|
|
56
|
-
});
|
|
57
45
|
return /* @__PURE__ */ jsxs("div", {
|
|
58
46
|
class: "input-container",
|
|
59
47
|
children: [
|
|
@@ -113,15 +101,7 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
|
|
|
113
101
|
placeholder,
|
|
114
102
|
"bind:value": value,
|
|
115
103
|
onInput$: inputHandler,
|
|
116
|
-
onBlur$: inputHandler
|
|
117
|
-
onKeyDown$: (e) => {
|
|
118
|
-
const allowed = /[0-9]/;
|
|
119
|
-
if (!allowed.test(e.key) && e.key.length === 1) {
|
|
120
|
-
e.preventDefault();
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
onBeforeInput$: beforeInputHandler,
|
|
124
|
-
onChange$: changeHandler
|
|
104
|
+
onBlur$: inputHandler
|
|
125
105
|
})
|
|
126
106
|
]
|
|
127
107
|
})
|