@seekho/ui 0.1.54 → 0.1.55

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 CHANGED
@@ -248,11 +248,15 @@ function AutoComplete({
248
248
  );
249
249
  const [highlightedIndex, setHighlightedIndex] = React8.useState(-1);
250
250
  const [dropdownPos, setDropdownPos] = React8.useState(null);
251
+ const DROPDOWN_MAX_HEIGHT = 240;
251
252
  const handelUpdateDropdownPosition = () => {
252
253
  if (!containerRef.current) return;
253
254
  const rect = containerRef.current.getBoundingClientRect();
255
+ const spaceBelow = window.innerHeight - rect.bottom;
256
+ const openUpward = spaceBelow < DROPDOWN_MAX_HEIGHT + 8 && rect.top > spaceBelow;
254
257
  setDropdownPos({
255
- top: rect.bottom + 4,
258
+ top: openUpward ? void 0 : rect.bottom + 4,
259
+ bottom: openUpward ? window.innerHeight - rect.top + 4 : void 0,
256
260
  left: rect.left,
257
261
  width: rect.width
258
262
  });
@@ -472,6 +476,7 @@ function AutoComplete({
472
476
  style: {
473
477
  position: "fixed",
474
478
  top: dropdownPos.top,
479
+ bottom: dropdownPos.bottom,
475
480
  left: dropdownPos.left,
476
481
  width: dropdownPos.width
477
482
  },
package/dist/index.mjs CHANGED
@@ -241,11 +241,15 @@ function AutoComplete({
241
241
  );
242
242
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
243
243
  const [dropdownPos, setDropdownPos] = useState(null);
244
+ const DROPDOWN_MAX_HEIGHT = 240;
244
245
  const handelUpdateDropdownPosition = () => {
245
246
  if (!containerRef.current) return;
246
247
  const rect = containerRef.current.getBoundingClientRect();
248
+ const spaceBelow = window.innerHeight - rect.bottom;
249
+ const openUpward = spaceBelow < DROPDOWN_MAX_HEIGHT + 8 && rect.top > spaceBelow;
247
250
  setDropdownPos({
248
- top: rect.bottom + 4,
251
+ top: openUpward ? void 0 : rect.bottom + 4,
252
+ bottom: openUpward ? window.innerHeight - rect.top + 4 : void 0,
249
253
  left: rect.left,
250
254
  width: rect.width
251
255
  });
@@ -465,6 +469,7 @@ function AutoComplete({
465
469
  style: {
466
470
  position: "fixed",
467
471
  top: dropdownPos.top,
472
+ bottom: dropdownPos.bottom,
468
473
  left: dropdownPos.left,
469
474
  width: dropdownPos.width
470
475
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seekho/ui",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "Seekho internal UI component library",
5
5
  "keywords": [
6
6
  "seekho",