@greghowe79/the-lib 0.7.7 → 0.7.9

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.
@@ -43,6 +43,19 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
43
43
  if (!error) internalError.value = result;
44
44
  }
45
45
  });
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
+ });
46
59
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
47
60
  class: "input-container",
48
61
  children: [
@@ -109,12 +122,8 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
109
122
  e.preventDefault();
110
123
  }
111
124
  },
112
- onBeforeInput$: (event) => {
113
- const e = event;
114
- if (e.data && /[^0-9]/.test(e.data)) {
115
- e.preventDefault();
116
- }
117
- }
125
+ onBeforeInput$: beforeInputHandler,
126
+ onChange$: changeHandler
118
127
  })
119
128
  ]
120
129
  })
@@ -41,6 +41,19 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
41
41
  if (!error) internalError.value = result;
42
42
  }
43
43
  });
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
+ });
44
57
  return /* @__PURE__ */ jsxs("div", {
45
58
  class: "input-container",
46
59
  children: [
@@ -107,12 +120,8 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
107
120
  e.preventDefault();
108
121
  }
109
122
  },
110
- onBeforeInput$: (event) => {
111
- const e = event;
112
- if (e.data && /[^0-9]/.test(e.data)) {
113
- e.preventDefault();
114
- }
115
- }
123
+ onBeforeInput$: beforeInputHandler,
124
+ onChange$: changeHandler
116
125
  })
117
126
  ]
118
127
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greghowe79/the-lib",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "Collection of fast components for Qwik",
5
5
  "main": "./lib/index.qwik.mjs",
6
6
  "qwik": "./lib/index.qwik.mjs",