react-frontend-common-components 0.1.1 → 0.1.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-frontend-common-components",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Reusable frontend library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -76,29 +76,32 @@ const AppInput = ({
76
76
 
77
77
  const placeholder = isOptional ? `${label} (optional)` : label;
78
78
 
79
- const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
80
- let newValue = e.target.value;
81
-
82
- const isFloat = type === "float";
83
- const isNumber = type === "number" || isFloat;
84
-
85
- if (isNumber) {
86
- const floatRegex = /^-?\d*\.?\d*$/;
87
- if (!floatRegex.test(newValue)) return;
88
-
89
- const digitCount = newValue.replace(/\./g, "").length;
90
- if (maxLength && digitCount > maxLength) return;
91
- }
92
-
93
- if (name === "name") {
94
- const alphabetOnly = /^[a-zA-Z\s]*$/;
95
- if (!alphabetOnly.test(newValue)) return;
96
- }
79
+ const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
80
+ let newValue = e.target.value;
81
+
82
+ const isFloat = type === "float";
83
+ const isNumber = type === "number" || isFloat;
84
+
85
+ if (isNumber) {
86
+ const floatRegex = /^-?\d*\.?\d*$/;
87
+ if (!floatRegex.test(newValue)) return;
88
+
89
+ const digitCount = newValue.replace(/\./g, "").length;
90
+ if (maxLength && digitCount > maxLength) return;
91
+ }
92
+
93
+ if (name === "name") {
94
+ newValue = newValue.replace(/[^a-zA-Z\s]/g, "");
95
+ }
96
+
97
+ setInputValue(newValue);
98
+ setIsTyping(newValue.length > 0);
99
+ handleChange?.({
100
+ ...e,
101
+ target: { ...e.target, value: newValue },
102
+ });
103
+ };
97
104
 
98
- setInputValue(newValue);
99
- setIsTyping(newValue.length > 0);
100
- handleChange?.(e);
101
- };
102
105
 
103
106
  return (
104
107
  <div className={`appInput ${className || ""}`}>
@@ -112,8 +115,10 @@ const AppInput = ({
112
115
  )}
113
116
 
114
117
  <Input
115
- type={type === "float" ? "text" : type}
116
- inputMode={type === "float" ? "decimal" : undefined}
118
+ type={name === "name" ? "text" : type === "float" ? "text" : type}
119
+ inputMode={
120
+ name === "name" ? "text" : type === "float" ? "decimal" : undefined
121
+ }
117
122
  data-test-id={dataTestId}
118
123
  id={id}
119
124
  disabled={disabled}