@greghowe79/the-lib 0.7.9 → 0.8.1
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,12 @@ 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)) {
|
|
36
|
+
if (value) {
|
|
37
|
+
elem.value = value.value;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
if (value) value.value = elem.value;
|
|
38
43
|
if (onInput$) {
|
|
@@ -43,19 +48,6 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
|
|
|
43
48
|
if (!error) internalError.value = result;
|
|
44
49
|
}
|
|
45
50
|
});
|
|
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
51
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
60
52
|
class: "input-container",
|
|
61
53
|
children: [
|
|
@@ -115,15 +107,7 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
|
|
|
115
107
|
placeholder,
|
|
116
108
|
"bind:value": value,
|
|
117
109
|
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
|
|
110
|
+
onBlur$: inputHandler
|
|
127
111
|
})
|
|
128
112
|
]
|
|
129
113
|
})
|
|
@@ -30,7 +30,12 @@ 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)) {
|
|
34
|
+
if (value) {
|
|
35
|
+
elem.value = value.value;
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
if (value) value.value = elem.value;
|
|
36
41
|
if (onInput$) {
|
|
@@ -41,19 +46,6 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
|
|
|
41
46
|
if (!error) internalError.value = result;
|
|
42
47
|
}
|
|
43
48
|
});
|
|
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
49
|
return /* @__PURE__ */ jsxs("div", {
|
|
58
50
|
class: "input-container",
|
|
59
51
|
children: [
|
|
@@ -113,15 +105,7 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
|
|
|
113
105
|
placeholder,
|
|
114
106
|
"bind:value": value,
|
|
115
107
|
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
|
|
108
|
+
onBlur$: inputHandler
|
|
125
109
|
})
|
|
126
110
|
]
|
|
127
111
|
})
|