gdx-ui 1.15.2 → 1.15.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.
@@ -39,8 +39,7 @@ var Input = exports.Input = /*#__PURE__*/_react["default"].forwardRef(function (
39
39
  inputStyle = _ref.inputStyle,
40
40
  _ref$showArrows = _ref.showArrows,
41
41
  showArrows = _ref$showArrows === void 0 ? true : _ref$showArrows,
42
- _ref$align = _ref.align,
43
- align = _ref$align === void 0 ? 'left' : _ref$align,
42
+ align = _ref.align,
44
43
  min = _ref.min,
45
44
  max = _ref.max,
46
45
  props = _objectWithoutProperties(_ref, _excluded);
@@ -75,21 +74,44 @@ var Input = exports.Input = /*#__PURE__*/_react["default"].forwardRef(function (
75
74
  var handleBlur = function handleBlur(e) {
76
75
  if (type === 'number') {
77
76
  var val = e.target.value;
77
+ var correctedValue = null;
78
+
78
79
  // Si está vacío o es inválido, usar el valor mínimo o 0
79
80
  if (val === '' || isNaN(Number(val))) {
80
- var defaultValue = min !== undefined ? min : 0;
81
- // Crear un evento sintético con el valor por defecto
81
+ correctedValue = min !== undefined ? min : 0;
82
+ }
83
+ // Validar que el valor no sea menor que el mínimo
84
+ else if (min !== undefined && Number(val) < min) {
85
+ correctedValue = min;
86
+ }
87
+ // Validar que el valor no sea mayor que el máximo
88
+ else if (max !== undefined && Number(val) > max) {
89
+ correctedValue = max;
90
+ }
91
+
92
+ // Si se necesita corrección, actualizar el valor
93
+ if (correctedValue !== null) {
94
+ // Actualizar el input directamente
95
+ e.target.value = correctedValue;
96
+
97
+ // Crear evento sintético con el valor corregido como NUMBER
82
98
  var syntheticEvent = _objectSpread(_objectSpread({}, e), {}, {
83
99
  target: _objectSpread(_objectSpread({}, e.target), {}, {
84
- value: defaultValue
100
+ value: correctedValue,
101
+ valueAsNumber: correctedValue // ✅ Para react-hook-form
85
102
  })
86
103
  });
104
+
105
+ // Llamar a onChange con el valor corregido
87
106
  if (onChange) onChange(syntheticEvent);
88
107
  }
89
108
  }
109
+
110
+ // Llamar al onBlur original si existe
90
111
  if (onBlur) onBlur(e);
91
112
  };
92
113
  placeholder !== null && placeholder !== void 0 ? placeholder : placeholder = "".concat(label || '', " ").concat(required ? '(obligatorio)' : '');
114
+ var alignClass = !align ? type === 'number' ? 'right' : 'left' : align;
93
115
  return /*#__PURE__*/_react["default"].createElement("label", {
94
116
  className: "form-element"
95
117
  }, label && /*#__PURE__*/_react["default"].createElement("div", {
@@ -105,7 +127,7 @@ var Input = exports.Input = /*#__PURE__*/_react["default"].forwardRef(function (
105
127
  value: value,
106
128
  onChange: handleChange,
107
129
  onBlur: handleBlur,
108
- className: "".concat(expanded ? 'expanded' : '', " \n ").concat(type === 'number' ? 'right' : '', "\n ").concat(error ? 'input-alert' : '', " \n ").concat(showArrows ? '' : 'hidden-arrows', "\n ").concat(align, "\n ").concat(inputClass ? inputClass : ''),
130
+ className: "".concat(expanded ? 'expanded' : '', " \n ").concat(alignClass, "\n ").concat(error ? 'input-alert' : '', " \n ").concat(showArrows ? '' : 'hidden-arrows', "\n ").concat(inputClass ? inputClass : ''),
109
131
  style: inputStyle,
110
132
  placeholder: placeholder,
111
133
  min: type === 'number' ? min : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdx-ui",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "UI gdx",
5
5
  "main": "index.js",
6
6
  "module": "index.js",