raise-common-lib 0.0.214 → 0.0.215

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.
@@ -1278,10 +1278,57 @@ var FloatBoxComponent = /** @class */ (function () {
1278
1278
  * @return {?}
1279
1279
  */
1280
1280
  function () {
1281
+ var _a = this.rootElement.nativeElement.getBoundingClientRect(), y = _a.top, x = _a.left, width = _a.width, height = _a.height;
1282
+ // 临时显示内容以获取尺寸
1283
+ /** @type {?} */
1284
+ var wasVisible = this.contentElement.nativeElement.style.display !== "none";
1285
+ this.contentElement.nativeElement.style.visibility = "hidden";
1286
+ this.contentElement.nativeElement.style.display = "block";
1287
+ /** @type {?} */
1288
+ var contentRect = this.contentElement.nativeElement.getBoundingClientRect();
1289
+ /** @type {?} */
1290
+ var contentWidth = contentRect.width;
1291
+ /** @type {?} */
1292
+ var contentHeight = contentRect.height;
1293
+ // 获取视口尺寸
1294
+ /** @type {?} */
1295
+ var viewportWidth = window.innerWidth;
1296
+ /** @type {?} */
1297
+ var viewportHeight = window.innerHeight;
1298
+ /** @type {?} */
1299
+ var SAFE_MARGIN = 12;
1300
+ // 边界检测:计算最佳 placement
1301
+ /** @type {?} */
1302
+ var finalPlacement = this.placement;
1303
+ if (this.placement === "top" && y < contentHeight + SAFE_MARGIN) {
1304
+ if (viewportHeight - (y + height) >= contentHeight + SAFE_MARGIN) {
1305
+ finalPlacement = "bottom";
1306
+ }
1307
+ }
1308
+ else if (this.placement === "bottom" && viewportHeight - (y + height) < contentHeight + SAFE_MARGIN) {
1309
+ if (y >= contentHeight + SAFE_MARGIN) {
1310
+ finalPlacement = "top";
1311
+ }
1312
+ }
1313
+ else if (this.placement === "left" && x < contentWidth + SAFE_MARGIN) {
1314
+ if (viewportWidth - (x + width) >= contentWidth + SAFE_MARGIN) {
1315
+ finalPlacement = "right";
1316
+ }
1317
+ }
1318
+ else if (this.placement === "right" && viewportWidth - (x + width) < contentWidth + SAFE_MARGIN) {
1319
+ if (x >= contentWidth + SAFE_MARGIN) {
1320
+ finalPlacement = "left";
1321
+ }
1322
+ }
1323
+ // 保存调整后的 placement
1324
+ this.actualPlacement = finalPlacement;
1325
+ // 对于 fixed="no" 的情况,只更新 data-placement,让 CSS 处理
1281
1326
  if (this.fixed === "no") {
1327
+ this.contentElement.nativeElement.style.visibility = "";
1328
+ this.contentElement.nativeElement.style.display = wasVisible ? "" : "none";
1282
1329
  return;
1283
1330
  }
1284
- var _a = this.rootElement.nativeElement.getBoundingClientRect(), y = _a.top, x = _a.left, width = _a.width, height = _a.height;
1331
+ // 对于 fixed="yes" 的情况,计算具体位置
1285
1332
  /** @type {?} */
1286
1333
  var top = "0";
1287
1334
  /** @type {?} */
@@ -1290,7 +1337,7 @@ var FloatBoxComponent = /** @class */ (function () {
1290
1337
  var translateX = "0";
1291
1338
  /** @type {?} */
1292
1339
  var translateY = "0";
1293
- switch (this.placement + "_" + this.position) {
1340
+ switch (finalPlacement + "_" + this.position) {
1294
1341
  case "top_start":
1295
1342
  top = y + "px";
1296
1343
  left = x - 8 + "px";
@@ -1354,9 +1401,49 @@ var FloatBoxComponent = /** @class */ (function () {
1354
1401
  translateX = "-100%";
1355
1402
  break;
1356
1403
  }
1404
+ // 计算实际渲染位置(考虑 transform)进行边界调整
1405
+ /** @type {?} */
1406
+ var actualLeft = parseFloat(left) || 0;
1407
+ /** @type {?} */
1408
+ var actualTop = parseFloat(top) || 0;
1409
+ if (translateX === "-50%") {
1410
+ actualLeft = actualLeft - contentWidth / 2;
1411
+ }
1412
+ else if (translateX === "-100%") {
1413
+ actualLeft = actualLeft - contentWidth;
1414
+ }
1415
+ if (translateY === "-50%") {
1416
+ actualTop = actualTop - contentHeight / 2;
1417
+ }
1418
+ else if (translateY === "-100%") {
1419
+ actualTop = actualTop - contentHeight;
1420
+ }
1421
+ // 水平边界调整
1422
+ if (finalPlacement === "top" || finalPlacement === "bottom") {
1423
+ if (actualLeft < SAFE_MARGIN) {
1424
+ left = (x + SAFE_MARGIN) + "px";
1425
+ translateX = "0";
1426
+ }
1427
+ else if (actualLeft + contentWidth > viewportWidth - SAFE_MARGIN) {
1428
+ left = (viewportWidth - contentWidth - SAFE_MARGIN) + "px";
1429
+ translateX = "0";
1430
+ }
1431
+ }
1432
+ // 垂直边界调整
1433
+ else {
1434
+ if (actualTop < SAFE_MARGIN) {
1435
+ top = (y + SAFE_MARGIN) + "px";
1436
+ translateY = "0";
1437
+ }
1438
+ else if (actualTop + contentHeight > viewportHeight - SAFE_MARGIN) {
1439
+ top = (viewportHeight - contentHeight - SAFE_MARGIN) + "px";
1440
+ translateY = "0";
1441
+ }
1442
+ }
1357
1443
  this.contentElement.nativeElement.style.top = top;
1358
1444
  this.contentElement.nativeElement.style.left = left;
1359
1445
  this.contentElement.nativeElement.style.transform = "translate(" + translateX + ", " + translateY + ")";
1446
+ this.contentElement.nativeElement.style.visibility = "visible";
1360
1447
  };
1361
1448
  /**
1362
1449
  * @return {?}
@@ -1380,13 +1467,15 @@ var FloatBoxComponent = /** @class */ (function () {
1380
1467
  * @return {?}
1381
1468
  */
1382
1469
  function () {
1383
- if (this.fixed === "no" || this.trigger !== "hover") {
1470
+ if (this.trigger !== "hover") {
1384
1471
  return;
1385
1472
  }
1386
1473
  this.opened = "yes";
1387
1474
  this.openChange.emit(true);
1388
1475
  this.setFixedContentPosition();
1389
- window.addEventListener("mousemove", this.onMoveOutside);
1476
+ if (this.fixed === "yes") {
1477
+ window.addEventListener("mousemove", this.onMoveOutside);
1478
+ }
1390
1479
  };
1391
1480
  /**
1392
1481
  * @return {?}
@@ -1409,7 +1498,7 @@ var FloatBoxComponent = /** @class */ (function () {
1409
1498
  FloatBoxComponent.decorators = [
1410
1499
  { type: Component, args: [{
1411
1500
  selector: "rs-float-box",
1412
- template: "<div\r\n #element\r\n class=\"float-box-container\"\r\n [attr.data-trigger]=\"trigger\"\r\n (click)=\"onClickContainer()\"\r\n (mouseenter)=\"onMouseEnter()\"\r\n>\r\n <ng-content></ng-content>\r\n <div\r\n #content\r\n class=\"float-box-content\"\r\n [attr.data-placement]=\"placement\"\r\n [attr.data-position]=\"position\"\r\n [attr.data-animation]=\"animation\"\r\n [attr.data-fixed]=\"fixed\"\r\n [attr.data-opened]=\"opened\"\r\n >\r\n <div class=\"float-box-show-content\">\r\n <ng-content select=\"[float-content]\"></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n",
1501
+ template: "<div\r\n #element\r\n class=\"float-box-container\"\r\n [attr.data-trigger]=\"trigger\"\r\n (click)=\"onClickContainer()\"\r\n (mouseenter)=\"onMouseEnter()\"\r\n>\r\n <ng-content></ng-content>\r\n <div\r\n #content\r\n class=\"float-box-content\"\r\n [attr.data-placement]=\"actualPlacement || placement\"\r\n [attr.data-position]=\"position\"\r\n [attr.data-animation]=\"animation\"\r\n [attr.data-fixed]=\"fixed\"\r\n [attr.data-opened]=\"opened\"\r\n >\r\n <div class=\"float-box-show-content\">\r\n <ng-content select=\"[float-content]\"></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n",
1413
1502
  styles: [".float-box-container{position:relative}.float-box-container[data-trigger=click]>.float-box-content[data-opened=no],.float-box-container[data-trigger=hover]:not(:hover)>.float-box-content{display:none}.float-box-container>.float-box-content[data-fixed=no]{padding:8px;--top:0;--left:0;--translate-x:0;--translate-y:0;position:absolute;top:var(--top);left:var(--left);transform:translate(var(--translate-x),var(--translate-y));z-index:10}.float-box-container>.float-box-content[data-fixed=no][data-animation=yes]{-webkit-animation:.25s ease-in-out;animation:.25s ease-in-out}.float-box-container>.float-box-content[data-fixed=no][data-placement=top]{--translate-y:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-animation=true]{-webkit-animation-name:open-from-top;animation-name:open-from-top}.float-box-container>.float-box-content[data-fixed=no][data-placement=left]{--translate-x:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=right]{--left:100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom]{--top:100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=start],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=start]{--left:-8px}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=center],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=center]{--left:50%;--translate-x:-50%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=end],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=end]{--left:calc(100% + 8px);--translate-x:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=start],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=start]{--top:-8px}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=start][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=start][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=center],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=center]{--top:50%;--translate-y:-50%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=center][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=center][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=end],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=end]{--top:calc(100% + 8px);--translate-y:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=end][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=end][data-animation=yes]{-webkit-animation-name:open-from-top;animation-name:open-from-top}@-webkit-keyframes open-from-top{from{margin-top:-8px;opacity:.4}to{margin:0;opacity:1}}@keyframes open-from-top{from{margin-top:-8px;opacity:.4}to{margin:0;opacity:1}}@-webkit-keyframes open-from-bottom{from{margin-top:8px;opacity:.4}to{margin:0;opacity:1}}@keyframes open-from-bottom{from{margin-top:8px;opacity:.4}to{margin:0;opacity:1}}::ng-deep #kt-float-box-fixed-container{width:0;height:0;z-index:100000}::ng-deep #kt-float-box-fixed-container .float-box-content[data-fixed=yes]{padding:8px;position:fixed;z-index:10}::ng-deep #kt-float-box-fixed-container .float-box-content[data-fixed=yes][data-opened=no]{display:none}.float-box-show-content{padding:8px 8px 12px;border-radius:8px;background:#fff;box-shadow:0 0 8px 0 rgba(0,0,0,.25)}"]
1414
1503
  }] }
1415
1504
  ];
@@ -1441,6 +1530,8 @@ if (false) {
1441
1530
  /** @type {?} */
1442
1531
  FloatBoxComponent.prototype._fixed;
1443
1532
  /** @type {?} */
1533
+ FloatBoxComponent.prototype.actualPlacement;
1534
+ /** @type {?} */
1444
1535
  FloatBoxComponent.prototype.openChange;
1445
1536
  /** @type {?} */
1446
1537
  FloatBoxComponent.prototype.rootElement;