@yeverlibs/ds 1.1.28 → 1.1.29
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 +69 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9050,17 +9050,48 @@ var Input = React107.forwardRef(
|
|
|
9050
9050
|
maxLength: $charactersLimit,
|
|
9051
9051
|
value,
|
|
9052
9052
|
onChange: (e14) => {
|
|
9053
|
-
|
|
9053
|
+
let inputValue = e14.target.value;
|
|
9054
|
+
if (type === "number") {
|
|
9055
|
+
inputValue = inputValue.replace(/[^0-9]/g, "");
|
|
9056
|
+
}
|
|
9054
9057
|
const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
|
|
9055
|
-
|
|
9058
|
+
const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
|
|
9059
|
+
setValue(finalValue);
|
|
9056
9060
|
onChange?.({
|
|
9057
9061
|
...e14,
|
|
9058
9062
|
target: {
|
|
9059
9063
|
...e14.target,
|
|
9060
|
-
value:
|
|
9064
|
+
value: finalValue
|
|
9061
9065
|
}
|
|
9062
9066
|
});
|
|
9063
9067
|
},
|
|
9068
|
+
onKeyDown: (e14) => {
|
|
9069
|
+
if (type === "number") {
|
|
9070
|
+
const allowedKeys = [
|
|
9071
|
+
"Backspace",
|
|
9072
|
+
"Delete",
|
|
9073
|
+
"Tab",
|
|
9074
|
+
"Escape",
|
|
9075
|
+
"Enter",
|
|
9076
|
+
"ArrowLeft",
|
|
9077
|
+
"ArrowRight",
|
|
9078
|
+
"ArrowUp",
|
|
9079
|
+
"ArrowDown",
|
|
9080
|
+
"Home",
|
|
9081
|
+
"End"
|
|
9082
|
+
];
|
|
9083
|
+
const isAllowedKey = allowedKeys.includes(e14.key);
|
|
9084
|
+
const isNumberKey = /^[0-9]$/.test(e14.key);
|
|
9085
|
+
const isCtrlA = e14.ctrlKey && e14.key === "a";
|
|
9086
|
+
const isCtrlC = e14.ctrlKey && e14.key === "c";
|
|
9087
|
+
const isCtrlV = e14.ctrlKey && e14.key === "v";
|
|
9088
|
+
const isCtrlX = e14.ctrlKey && e14.key === "x";
|
|
9089
|
+
if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
|
|
9090
|
+
e14.preventDefault();
|
|
9091
|
+
}
|
|
9092
|
+
}
|
|
9093
|
+
rest.onKeyDown?.(e14);
|
|
9094
|
+
},
|
|
9064
9095
|
$inputClassName,
|
|
9065
9096
|
...rest
|
|
9066
9097
|
}
|
|
@@ -9081,18 +9112,49 @@ var Input = React107.forwardRef(
|
|
|
9081
9112
|
maxLength: $charactersLimit,
|
|
9082
9113
|
value: field.value || "",
|
|
9083
9114
|
onChange: (e14) => {
|
|
9084
|
-
|
|
9115
|
+
let inputValue = e14.target.value;
|
|
9116
|
+
if (type === "number") {
|
|
9117
|
+
inputValue = inputValue.replace(/[^0-9]/g, "");
|
|
9118
|
+
}
|
|
9085
9119
|
const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
|
|
9086
|
-
|
|
9087
|
-
|
|
9120
|
+
const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
|
|
9121
|
+
setValue(finalValue);
|
|
9122
|
+
field.onChange(finalValue);
|
|
9088
9123
|
onChange?.({
|
|
9089
9124
|
...e14,
|
|
9090
9125
|
target: {
|
|
9091
9126
|
...e14.target,
|
|
9092
|
-
value:
|
|
9127
|
+
value: finalValue
|
|
9093
9128
|
}
|
|
9094
9129
|
});
|
|
9095
9130
|
},
|
|
9131
|
+
onKeyDown: (e14) => {
|
|
9132
|
+
if (type === "number") {
|
|
9133
|
+
const allowedKeys = [
|
|
9134
|
+
"Backspace",
|
|
9135
|
+
"Delete",
|
|
9136
|
+
"Tab",
|
|
9137
|
+
"Escape",
|
|
9138
|
+
"Enter",
|
|
9139
|
+
"ArrowLeft",
|
|
9140
|
+
"ArrowRight",
|
|
9141
|
+
"ArrowUp",
|
|
9142
|
+
"ArrowDown",
|
|
9143
|
+
"Home",
|
|
9144
|
+
"End"
|
|
9145
|
+
];
|
|
9146
|
+
const isAllowedKey = allowedKeys.includes(e14.key);
|
|
9147
|
+
const isNumberKey = /^[0-9]$/.test(e14.key);
|
|
9148
|
+
const isCtrlA = e14.ctrlKey && e14.key === "a";
|
|
9149
|
+
const isCtrlC = e14.ctrlKey && e14.key === "c";
|
|
9150
|
+
const isCtrlV = e14.ctrlKey && e14.key === "v";
|
|
9151
|
+
const isCtrlX = e14.ctrlKey && e14.key === "x";
|
|
9152
|
+
if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
|
|
9153
|
+
e14.preventDefault();
|
|
9154
|
+
}
|
|
9155
|
+
}
|
|
9156
|
+
rest.onKeyDown?.(e14);
|
|
9157
|
+
},
|
|
9096
9158
|
$inputClassName,
|
|
9097
9159
|
...rest
|
|
9098
9160
|
}
|