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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/app-input/app-input.tsx +29 -24
package/package.json
CHANGED
|
@@ -76,29 +76,32 @@ const AppInput = ({
|
|
|
76
76
|
|
|
77
77
|
const placeholder = isOptional ? `${label} (optional)` : label;
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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={
|
|
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}
|