Comparing version 1.0.56 to 1.0.57
@@ -90,5 +90,30 @@ "use strict"; | ||
// API call for suggestions through a custom hook | ||
var _0 = (0, autosuggestions_1.useSuggestions)(getData, data, dropOpen, async, paginationEnabled, initialLoad, inputValue, isMultiple, setNextPage, selectedItems | ||
var _0 = (0, react_1.useState)('bottom'), dropdownPosition = _0[0], setDropdownPosition = _0[1]; | ||
var inputRef = (0, react_1.useRef)(null); | ||
var dropRef = (0, react_1.useRef)(null); | ||
var adjustDropdownPosition = function () { | ||
if (inputRef.current && dropRef.current) { | ||
var inputBoxRect = inputRef.current.getBoundingClientRect(); | ||
var viewportHeight = window.innerHeight; | ||
var spaceAbove = inputBoxRect.top; | ||
var spaceBelow = viewportHeight - inputBoxRect.bottom; | ||
console.log(spaceAbove, spaceBelow); | ||
if (spaceAbove > spaceBelow) { | ||
setDropdownPosition('top'); | ||
} | ||
else { | ||
setDropdownPosition('bottom'); | ||
} | ||
} | ||
}; | ||
(0, react_1.useEffect)(function () { | ||
window.addEventListener('resize', adjustDropdownPosition); | ||
adjustDropdownPosition(); | ||
return function () { | ||
window.removeEventListener('resize', adjustDropdownPosition); | ||
}; | ||
}, [dropOpen]); | ||
var _1 = (0, autosuggestions_1.useSuggestions)(getData, data, dropOpen, async, paginationEnabled, initialLoad, inputValue, isMultiple, setNextPage, selectedItems | ||
// nextBlock | ||
), suggestions = _0.suggestions, isLoading = _0.isLoading, handlePickSuggestions = _0.handlePickSuggestions; | ||
), suggestions = _1.suggestions, isLoading = _1.isLoading, handlePickSuggestions = _1.handlePickSuggestions; | ||
// Handling the selection of a suggestion | ||
@@ -242,3 +267,3 @@ var handleSuggestionClick = (0, react_1.useCallback)(function (suggestion) { | ||
" more"))))), | ||
react_1.default.createElement("input", { id: id, type: "text", value: type === 'auto_suggestion' ? inputValue : searchValue || inputValue, onChange: handleChange, | ||
react_1.default.createElement("input", { id: id, ref: inputRef, type: "text", value: type === 'auto_suggestion' ? inputValue : searchValue || inputValue, onChange: handleChange, | ||
// onBlur={handleBlur} | ||
@@ -253,3 +278,3 @@ onClick: function () { return handleOnClick(); }, className: generateClassName(), placeholder: (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) > 0 ? '' : placeholder !== null && placeholder !== void 0 ? placeholder : '', readOnly: readOnly || type === 'custom_select' || type == 'auto_suggestion' | ||
react_1.default.createElement(icons_1.DropArrow, null))), | ||
dropOpen && (react_1.default.createElement("ul", { className: "qbs-autocomplete-suggestions" }, | ||
dropOpen && (react_1.default.createElement("ul", { ref: dropRef, className: "qbs-autocomplete-suggestions ".concat(dropdownPosition) }, | ||
type == 'auto_suggestion' && (react_1.default.createElement("div", { style: { position: 'relative' }, className: "qbs-core-search-container" }, | ||
@@ -256,0 +281,0 @@ react_1.default.createElement("span", { className: "dropdown-search-icon" }, |
{ | ||
"name": "qbs-core", | ||
"version": "1.0.56", | ||
"version": "1.0.57", | ||
"description": "React Components", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ const path = require('path'); | ||
//... | ||
entry: './dist', | ||
entry: './docs', | ||
devtool: 'source-map', | ||
@@ -10,0 +10,0 @@ devServer: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121317
47
2720