@easyquery/ui 7.3.5-rc01 → 7.3.5-rc03

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.
@@ -427,6 +427,7 @@
427
427
  justify-content: flex-start;
428
428
  padding: 20px;
429
429
  position: relative;
430
+ width: 100%;
430
431
  }
431
432
 
432
433
  .kdlg-footer.align-right {
@@ -531,6 +532,7 @@
531
532
  padding: 20px;
532
533
  font-size: 1em;
533
534
  color: #4a4a4a;
535
+ width: 100%;
534
536
  }
535
537
 
536
538
 
@@ -5125,10 +5127,7 @@ input.eqjs-invalid {
5125
5127
  .eqjs-cb-addrow.eqjs-mobile a, .eqjs-sb-addrow.eqjs-mobile a {
5126
5128
  background: none!important;
5127
5129
  }
5128
-
5129
- .eqjs-menu-levelDiv {
5130
- max-height: 96vh;
5131
- }
5130
+
5132
5131
  /*setting to all page */
5133
5132
  #eqv-main{
5134
5133
  width:1174px;
@@ -453,7 +453,3 @@
453
453
  .eqjs-cb-addrow.eqjs-mobile a, .eqjs-sb-addrow.eqjs-mobile a {
454
454
  background: none!important;
455
455
  }
456
-
457
- .eqjs-menu-levelDiv {
458
- max-height: 96vh;
459
- }
@@ -1417,7 +1417,7 @@ class MenuLevel {
1417
1417
  }
1418
1418
  return res;
1419
1419
  }
1420
- showAt(x, y, adjustTopPos, hidden) {
1420
+ showAt(x, y, adjustTopPos, hidden, anchor) {
1421
1421
  if (!this.items) {
1422
1422
  return;
1423
1423
  }
@@ -1425,7 +1425,7 @@ class MenuLevel {
1425
1425
  //crocodile
1426
1426
  this.turnCheckboxes(this.items);
1427
1427
  this.renderItems();
1428
- const winSize = ui.getWinSize();
1428
+ ui.getWinSize();
1429
1429
  const levelStyle = this.levelDiv.style;
1430
1430
  if (hidden) {
1431
1431
  this.levelDiv.style.visibility = 'hidden';
@@ -1436,58 +1436,63 @@ class MenuLevel {
1436
1436
  this.scrollDiv.style.width = "auto";
1437
1437
  this.scrollDiv.style.height = "auto";
1438
1438
  const useMaxSpace = this.parentMenu.options.useMaxSpace;
1439
- if (useMaxSpace === false) {
1439
+ const viewportHeight = ui.getViewportSize().height;
1440
+ const top = y - scrollY;
1441
+ const bottom = viewportHeight - top;
1442
+ const anchorRect = anchor ? anchor.getBoundingClientRect() : null;
1443
+ const anchorHeight = anchorRect ? anchorRect.height : 0;
1444
+ const magic = 24;
1445
+ if (this.levelIndex > 0 || useMaxSpace) {
1446
+ let maxHeight = viewportHeight - 30;
1447
+ if (this.searchDiv) {
1448
+ maxHeight -= this.searchDiv.scrollHeight;
1449
+ }
1450
+ if (this.closeDiv) {
1451
+ maxHeight -= this.closeDiv.offsetHeight;
1452
+ }
1453
+ this.scrollDiv.style.maxHeight = maxHeight + 'px';
1440
1454
  const levelDivRect = this.levelDiv.getBoundingClientRect();
1441
- const ldHeight = levelDivRect.height;
1442
- const vpHeight = winSize.height;
1443
- const top = y - 16 - scrollY;
1444
- const bottom = vpHeight - top;
1445
- if (top > bottom) {
1446
- // console.log("top > bottom");
1447
- if (ldHeight > bottom) {
1448
- let maxHeight = top;
1449
- if (this.searchDiv != null) {
1450
- maxHeight -= this.searchDiv.offsetHeight;
1451
- }
1452
- if (this.closeDiv != null) {
1453
- maxHeight -= this.closeDiv.offsetHeight;
1454
- }
1455
- this.scrollDiv.style.maxHeight = (maxHeight - 24) + 'px';
1456
- this.levelDiv.style.top = Math.max(6, y - ldHeight - 24) + 'px';
1457
- }
1455
+ const levelDivHeight = levelDivRect.height;
1456
+ if (levelDivHeight < bottom - anchorHeight) {
1457
+ levelStyle.top = y + anchorHeight + 'px';
1458
1458
  }
1459
1459
  else {
1460
- // console.log("bottom > top");
1461
- this.scrollDiv.style.maxHeight = (bottom - 80) + 'px';
1460
+ if (top < bottom) {
1461
+ levelStyle.top = y - top + 5 + 'px';
1462
+ }
1463
+ else {
1464
+ levelStyle.top = Math.max(5, viewportHeight - levelDivHeight - 30) + 'px';
1465
+ }
1462
1466
  }
1463
1467
  }
1464
- //adjusting level top position
1465
- if (useMaxSpace) {
1466
- y = this.adjustTopPos(y);
1467
- levelStyle.top = y + 'px';
1468
- //adjustinng maximum height of the menu level if it does not fit to browser window
1469
- let maxHeight = winSize.height - (y - ui.getScrollPos().top) - 15; //document.documentElement.scrollTop
1470
- if (this.parentMenu.maxHeight > 0 && maxHeight > this.parentMenu.maxHeight) {
1471
- maxHeight = this.parentMenu.maxHeight;
1472
- }
1473
- if (this._applyItem != null && this._applyItem.itemDiv != null) {
1474
- maxHeight -= this._applyItem.itemDiv.offsetHeight + 5;
1475
- }
1476
- if (this.searchDiv != null) {
1477
- maxHeight -= this.searchDiv.offsetHeight;
1468
+ else {
1469
+ let maxHeight = Math.max(top, bottom) - magic;
1470
+ if (this.searchDiv) {
1471
+ maxHeight -= this.searchDiv.scrollHeight;
1478
1472
  }
1479
- if (this.closeDiv != null) {
1473
+ if (this.closeDiv) {
1480
1474
  maxHeight -= this.closeDiv.offsetHeight;
1481
1475
  }
1482
- if (this.levelDiv.offsetHeight > maxHeight) {
1483
- let newHeight = maxHeight;
1484
- if (newHeight < 50) {
1485
- newHeight = 50;
1486
- }
1487
- this.scrollDiv.style.height = newHeight + "px";
1476
+ // Рахуємо початковий контейнер
1477
+ let levelDivRect = this.levelDiv.getBoundingClientRect();
1478
+ if (levelDivRect.height < bottom - anchorHeight) {
1479
+ // Контейнер може впасти вниз
1480
+ this.scrollDiv.style.maxHeight = maxHeight - magic + 'px';
1481
+ levelStyle.top = y + anchorHeight + 'px';
1488
1482
  }
1489
1483
  else {
1490
- this.scrollDiv.style.height = "auto";
1484
+ // Визначаємо більший простір зверху чи знизу від анкора
1485
+ if (top > bottom) {
1486
+ // Падаємо вверх
1487
+ this.scrollDiv.style.maxHeight = maxHeight + 'px';
1488
+ levelDivRect = this.levelDiv.getBoundingClientRect();
1489
+ levelStyle.top = y - levelDivRect.height + 'px';
1490
+ }
1491
+ else {
1492
+ // Падаємо вниз
1493
+ this.scrollDiv.style.maxHeight = maxHeight - magic + 'px';
1494
+ levelStyle.top = y + anchorHeight + 'px';
1495
+ }
1491
1496
  }
1492
1497
  }
1493
1498
  //setting minimal level width if it is defined
@@ -1796,11 +1801,11 @@ class PopupMenu {
1796
1801
  else {
1797
1802
  const anchor = options.anchor || document.documentElement;
1798
1803
  const srcPos = ui.getElementAbsolutePos(anchor);
1799
- const anchorHeight = anchor.offsetHeight;
1804
+ anchor.offsetHeight;
1800
1805
  const anchorWidth = anchor.offsetWidth;
1801
1806
  const pos = {
1802
1807
  x: srcPos.x,
1803
- y: srcPos.y + anchorHeight + 2
1808
+ y: srcPos.y // + anchorHeight + 2
1804
1809
  };
1805
1810
  const scroll = ui.getScrollPos();
1806
1811
  const winSize = ui.getWinSize();
@@ -1808,7 +1813,7 @@ class PopupMenu {
1808
1813
  const leftSpace = pos.x + anchorWidth - scroll.left;
1809
1814
  const rightSpace = winSize.width - leftSpace + anchorWidth;
1810
1815
  pos.x += 2;
1811
- this.rootLevel.showAt(pos.x, pos.y, true, true);
1816
+ this.rootLevel.showAt(pos.x, pos.y, true, true, anchor);
1812
1817
  this.rootLevel.levelDiv.style.width = '';
1813
1818
  this.rootLevel.levelDiv.style.right = '';
1814
1819
  if (!this.rootLevel.levelDiv.style.zIndex) {
@@ -1415,7 +1415,7 @@ class MenuLevel {
1415
1415
  }
1416
1416
  return res;
1417
1417
  }
1418
- showAt(x, y, adjustTopPos, hidden) {
1418
+ showAt(x, y, adjustTopPos, hidden, anchor) {
1419
1419
  if (!this.items) {
1420
1420
  return;
1421
1421
  }
@@ -1423,7 +1423,7 @@ class MenuLevel {
1423
1423
  //crocodile
1424
1424
  this.turnCheckboxes(this.items);
1425
1425
  this.renderItems();
1426
- const winSize = getWinSize();
1426
+ getWinSize();
1427
1427
  const levelStyle = this.levelDiv.style;
1428
1428
  if (hidden) {
1429
1429
  this.levelDiv.style.visibility = 'hidden';
@@ -1434,58 +1434,63 @@ class MenuLevel {
1434
1434
  this.scrollDiv.style.width = "auto";
1435
1435
  this.scrollDiv.style.height = "auto";
1436
1436
  const useMaxSpace = this.parentMenu.options.useMaxSpace;
1437
- if (useMaxSpace === false) {
1437
+ const viewportHeight = getViewportSize().height;
1438
+ const top = y - scrollY;
1439
+ const bottom = viewportHeight - top;
1440
+ const anchorRect = anchor ? anchor.getBoundingClientRect() : null;
1441
+ const anchorHeight = anchorRect ? anchorRect.height : 0;
1442
+ const magic = 24;
1443
+ if (this.levelIndex > 0 || useMaxSpace) {
1444
+ let maxHeight = viewportHeight - 30;
1445
+ if (this.searchDiv) {
1446
+ maxHeight -= this.searchDiv.scrollHeight;
1447
+ }
1448
+ if (this.closeDiv) {
1449
+ maxHeight -= this.closeDiv.offsetHeight;
1450
+ }
1451
+ this.scrollDiv.style.maxHeight = maxHeight + 'px';
1438
1452
  const levelDivRect = this.levelDiv.getBoundingClientRect();
1439
- const ldHeight = levelDivRect.height;
1440
- const vpHeight = winSize.height;
1441
- const top = y - 16 - scrollY;
1442
- const bottom = vpHeight - top;
1443
- if (top > bottom) {
1444
- // console.log("top > bottom");
1445
- if (ldHeight > bottom) {
1446
- let maxHeight = top;
1447
- if (this.searchDiv != null) {
1448
- maxHeight -= this.searchDiv.offsetHeight;
1449
- }
1450
- if (this.closeDiv != null) {
1451
- maxHeight -= this.closeDiv.offsetHeight;
1452
- }
1453
- this.scrollDiv.style.maxHeight = (maxHeight - 24) + 'px';
1454
- this.levelDiv.style.top = Math.max(6, y - ldHeight - 24) + 'px';
1455
- }
1453
+ const levelDivHeight = levelDivRect.height;
1454
+ if (levelDivHeight < bottom - anchorHeight) {
1455
+ levelStyle.top = y + anchorHeight + 'px';
1456
1456
  }
1457
1457
  else {
1458
- // console.log("bottom > top");
1459
- this.scrollDiv.style.maxHeight = (bottom - 80) + 'px';
1458
+ if (top < bottom) {
1459
+ levelStyle.top = y - top + 5 + 'px';
1460
+ }
1461
+ else {
1462
+ levelStyle.top = Math.max(5, viewportHeight - levelDivHeight - 30) + 'px';
1463
+ }
1460
1464
  }
1461
1465
  }
1462
- //adjusting level top position
1463
- if (useMaxSpace) {
1464
- y = this.adjustTopPos(y);
1465
- levelStyle.top = y + 'px';
1466
- //adjustinng maximum height of the menu level if it does not fit to browser window
1467
- let maxHeight = winSize.height - (y - getScrollPos().top) - 15; //document.documentElement.scrollTop
1468
- if (this.parentMenu.maxHeight > 0 && maxHeight > this.parentMenu.maxHeight) {
1469
- maxHeight = this.parentMenu.maxHeight;
1470
- }
1471
- if (this._applyItem != null && this._applyItem.itemDiv != null) {
1472
- maxHeight -= this._applyItem.itemDiv.offsetHeight + 5;
1473
- }
1474
- if (this.searchDiv != null) {
1475
- maxHeight -= this.searchDiv.offsetHeight;
1466
+ else {
1467
+ let maxHeight = Math.max(top, bottom) - magic;
1468
+ if (this.searchDiv) {
1469
+ maxHeight -= this.searchDiv.scrollHeight;
1476
1470
  }
1477
- if (this.closeDiv != null) {
1471
+ if (this.closeDiv) {
1478
1472
  maxHeight -= this.closeDiv.offsetHeight;
1479
1473
  }
1480
- if (this.levelDiv.offsetHeight > maxHeight) {
1481
- let newHeight = maxHeight;
1482
- if (newHeight < 50) {
1483
- newHeight = 50;
1484
- }
1485
- this.scrollDiv.style.height = newHeight + "px";
1474
+ // Рахуємо початковий контейнер
1475
+ let levelDivRect = this.levelDiv.getBoundingClientRect();
1476
+ if (levelDivRect.height < bottom - anchorHeight) {
1477
+ // Контейнер може впасти вниз
1478
+ this.scrollDiv.style.maxHeight = maxHeight - magic + 'px';
1479
+ levelStyle.top = y + anchorHeight + 'px';
1486
1480
  }
1487
1481
  else {
1488
- this.scrollDiv.style.height = "auto";
1482
+ // Визначаємо більший простір зверху чи знизу від анкора
1483
+ if (top > bottom) {
1484
+ // Падаємо вверх
1485
+ this.scrollDiv.style.maxHeight = maxHeight + 'px';
1486
+ levelDivRect = this.levelDiv.getBoundingClientRect();
1487
+ levelStyle.top = y - levelDivRect.height + 'px';
1488
+ }
1489
+ else {
1490
+ // Падаємо вниз
1491
+ this.scrollDiv.style.maxHeight = maxHeight - magic + 'px';
1492
+ levelStyle.top = y + anchorHeight + 'px';
1493
+ }
1489
1494
  }
1490
1495
  }
1491
1496
  //setting minimal level width if it is defined
@@ -1794,11 +1799,11 @@ class PopupMenu {
1794
1799
  else {
1795
1800
  const anchor = options.anchor || document.documentElement;
1796
1801
  const srcPos = getElementAbsolutePos(anchor);
1797
- const anchorHeight = anchor.offsetHeight;
1802
+ anchor.offsetHeight;
1798
1803
  const anchorWidth = anchor.offsetWidth;
1799
1804
  const pos = {
1800
1805
  x: srcPos.x,
1801
- y: srcPos.y + anchorHeight + 2
1806
+ y: srcPos.y // + anchorHeight + 2
1802
1807
  };
1803
1808
  const scroll = getScrollPos();
1804
1809
  const winSize = getWinSize();
@@ -1806,7 +1811,7 @@ class PopupMenu {
1806
1811
  const leftSpace = pos.x + anchorWidth - scroll.left;
1807
1812
  const rightSpace = winSize.width - leftSpace + anchorWidth;
1808
1813
  pos.x += 2;
1809
- this.rootLevel.showAt(pos.x, pos.y, true, true);
1814
+ this.rootLevel.showAt(pos.x, pos.y, true, true, anchor);
1810
1815
  this.rootLevel.levelDiv.style.width = '';
1811
1816
  this.rootLevel.levelDiv.style.right = '';
1812
1817
  if (!this.rootLevel.levelDiv.style.zIndex) {
@@ -62,7 +62,7 @@ declare class MenuLevel {
62
62
  deactivateItem(menuItem: any): void;
63
63
  showSubLevel(menuItem: MenuItem): void;
64
64
  adjustTopPos(top: number): number;
65
- showAt(x: number, y: number, adjustTopPos: boolean, hidden: boolean): void;
65
+ showAt(x: number, y: number, adjustTopPos: boolean, hidden: boolean, anchor?: HTMLElement): void;
66
66
  focus(): void;
67
67
  hide(): void;
68
68
  initLevelDiv(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyquery/ui",
3
- "version": "7.3.5-rc01",
3
+ "version": "7.3.5-rc03",
4
4
  "description": "EasyQuery.JS Community UI widgets",
5
5
  "types": "./dist/types/public_api.d.ts",
6
6
  "main": "./dist/easyquery.ui.cjs.js",
@@ -30,7 +30,7 @@
30
30
  "bugs": "https://korzh.com/support",
31
31
  "license": "LGPL-3.0",
32
32
  "peerDependencies": {
33
- "@easyquery/core": "^7.3.5-rc01"
33
+ "@easyquery/core": "^7.3.5-rc03"
34
34
  },
35
35
  "files": [
36
36
  "dist",