gdx-ui 1.15.2 → 1.15.4
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/components/box/Box.js +7 -1
- package/components/forms/Input.js +28 -6
- package/package.json +1 -1
- package/stories/box/Box.stories.js +32 -0
package/components/box/Box.js
CHANGED
|
@@ -75,7 +75,13 @@ var BoxHeader = exports.BoxHeader = function BoxHeader(_ref2) {
|
|
|
75
75
|
open: !open
|
|
76
76
|
}));
|
|
77
77
|
},
|
|
78
|
-
icon:
|
|
78
|
+
icon: _freeSolidSvgIcons.faChevronDown,
|
|
79
|
+
style: {
|
|
80
|
+
transition: 'transform 0.3s ease',
|
|
81
|
+
// Si open=true → rotate(180deg) = chevron hacia abajo
|
|
82
|
+
// Si open=false → rotate(0deg) = chevron hacia arriba
|
|
83
|
+
transform: open ? 'rotate(180deg)' : 'rotate(0deg)'
|
|
84
|
+
}
|
|
79
85
|
})), children);
|
|
80
86
|
};
|
|
81
87
|
var BoxContent = exports.BoxContent = function BoxContent(_ref3) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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:
|
|
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(
|
|
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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.BoxDefault = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Box = require("../../components/box/Box");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
var _default = exports["default"] = {
|
|
11
|
+
title: 'Layout/Box',
|
|
12
|
+
component: _Box.Box,
|
|
13
|
+
parameters: {
|
|
14
|
+
layout: 'centered'
|
|
15
|
+
},
|
|
16
|
+
tags: ['autodocs']
|
|
17
|
+
};
|
|
18
|
+
var BoxDefault = exports.BoxDefault = {
|
|
19
|
+
args: {
|
|
20
|
+
color: 'primary',
|
|
21
|
+
open: true,
|
|
22
|
+
collapsible: true,
|
|
23
|
+
isLoading: false
|
|
24
|
+
},
|
|
25
|
+
render: function render(args) {
|
|
26
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
27
|
+
style: {
|
|
28
|
+
width: '400px'
|
|
29
|
+
}
|
|
30
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, args, /*#__PURE__*/_react["default"].createElement(_Box.BoxHeader, null, "Box Header"), /*#__PURE__*/_react["default"].createElement(_Box.BoxContent, null, "The content of the box goes here.")));
|
|
31
|
+
}
|
|
32
|
+
};
|