componenteshospitais 1.9.8 → 2.0.0
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/cjs/index.js +11 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +11 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/Busca.d.ts +2 -0
- package/dist/types/components/InputField.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Busca.tsx +11 -7
- package/src/components/InputField.tsx +6 -4
package/dist/cjs/index.js
CHANGED
|
@@ -1504,7 +1504,9 @@ var InputField = function (_a) {
|
|
|
1504
1504
|
if (type === 'number' && e.target.value.length > appliedMaxLength) {
|
|
1505
1505
|
e.target.value = e.target.value.slice(0, appliedMaxLength);
|
|
1506
1506
|
}
|
|
1507
|
-
onChange
|
|
1507
|
+
if (onChange) { // Verificando se onChange foi passado antes de chamá-lo
|
|
1508
|
+
onChange(e);
|
|
1509
|
+
}
|
|
1508
1510
|
};
|
|
1509
1511
|
var mask = maskType === 'cpf' ? '999.999.999-99' :
|
|
1510
1512
|
maskType === 'phone' ? '(99) 99999-9999' :
|
|
@@ -1594,20 +1596,21 @@ var SelectField = function (_a) {
|
|
|
1594
1596
|
};
|
|
1595
1597
|
|
|
1596
1598
|
var Busca = function (_a) {
|
|
1597
|
-
var options = _a.options
|
|
1599
|
+
var options = _a.options; _a.value; var onChange = _a.onChange, label = _a.label, _b = _a.showIcon, showIcon = _b === void 0 ? false : _b, corLabel = _a.corLabel, corFundo = _a.corFundo;
|
|
1598
1600
|
var _c = React$2.useState(options), filteredOptions = _c[0], setFilteredOptions = _c[1];
|
|
1599
1601
|
var _d = React$2.useState(false), showOptions = _d[0], setShowOptions = _d[1];
|
|
1602
|
+
var _e = React$2.useState(''), inputValue = _e[0], setInputValue = _e[1];
|
|
1600
1603
|
var inputRef = React$2.useRef(null);
|
|
1601
1604
|
var handleInputChange = function (e) {
|
|
1602
1605
|
var inputValue = e.target.value;
|
|
1603
|
-
|
|
1606
|
+
setInputValue(inputValue);
|
|
1604
1607
|
if (inputValue === '') {
|
|
1605
1608
|
setFilteredOptions(options);
|
|
1606
1609
|
setShowOptions(true);
|
|
1607
1610
|
}
|
|
1608
1611
|
else {
|
|
1609
1612
|
var filtered = options.filter(function (option) {
|
|
1610
|
-
return option.
|
|
1613
|
+
return option.description.toLowerCase().includes(inputValue.toLowerCase());
|
|
1611
1614
|
});
|
|
1612
1615
|
setFilteredOptions(filtered);
|
|
1613
1616
|
setShowOptions(true);
|
|
@@ -1618,7 +1621,8 @@ var Busca = function (_a) {
|
|
|
1618
1621
|
setShowOptions(true);
|
|
1619
1622
|
};
|
|
1620
1623
|
var handleOptionClick = function (option) {
|
|
1621
|
-
|
|
1624
|
+
setInputValue(option.description);
|
|
1625
|
+
onChange(option.value);
|
|
1622
1626
|
setShowOptions(false);
|
|
1623
1627
|
};
|
|
1624
1628
|
var handleClickOutside = function (event) {
|
|
@@ -1633,10 +1637,10 @@ var Busca = function (_a) {
|
|
|
1633
1637
|
};
|
|
1634
1638
|
}, []);
|
|
1635
1639
|
return (React$2.createElement("div", { style: { position: 'relative', width: '100%' }, ref: inputRef },
|
|
1636
|
-
label && React$2.createElement("label", { htmlFor: "codigoCbhpm" }, label),
|
|
1640
|
+
label && React$2.createElement("label", { htmlFor: "codigoCbhpm", style: { color: corLabel ? corLabel : '' } }, label),
|
|
1637
1641
|
React$2.createElement("div", { style: { position: 'relative', display: 'flex', alignItems: 'center', gap: '10px', width: '100%' } },
|
|
1638
1642
|
showIcon && React$2.createElement(FaSearch, { className: styles$5.searchIcon }),
|
|
1639
|
-
React$2.createElement("input", { type: "text", id: "codigoCbhpm", value:
|
|
1643
|
+
React$2.createElement("input", { type: "text", id: "codigoCbhpm", value: inputValue, onChange: handleInputChange, onFocus: handleFocus, placeholder: "Digite para buscar...", autoComplete: "off", className: styles$5.inputPadrao, style: { width: '100%', paddingLeft: showIcon ? '30px' : '0', backgroundColor: (corFundo ? corFundo : '') } })),
|
|
1640
1644
|
showOptions && filteredOptions.length > 0 && (React$2.createElement("ul", { style: {
|
|
1641
1645
|
position: 'absolute',
|
|
1642
1646
|
width: '100%',
|