@netless/telebox-insider 0.2.32-beta.1 → 0.3.0-beta.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.
@@ -1230,6 +1230,8 @@ exports.TELE_BOX_EVENT = void 0;
1230
1230
  TELE_BOX_EVENT2["Maximized"] = "maximized";
1231
1231
  TELE_BOX_EVENT2["Readonly"] = "readonly";
1232
1232
  TELE_BOX_EVENT2["Destroyed"] = "destroyed";
1233
+ TELE_BOX_EVENT2["BoxStatus"] = "box_status";
1234
+ TELE_BOX_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
1233
1235
  })(exports.TELE_BOX_EVENT || (exports.TELE_BOX_EVENT = {}));
1234
1236
  exports.TELE_BOX_DELEGATE_EVENT = void 0;
1235
1237
  (function(TELE_BOX_DELEGATE_EVENT2) {
@@ -1282,7 +1284,8 @@ class DefaultTitleBar {
1282
1284
  onEvent,
1283
1285
  onDragStart,
1284
1286
  namespace = "telebox",
1285
- state = exports.TELE_BOX_STATE.Normal
1287
+ state = exports.TELE_BOX_STATE.Normal,
1288
+ boxStatus
1286
1289
  } = {}) {
1287
1290
  this.$btns = [];
1288
1291
  this.sideEffect = new o();
@@ -1355,6 +1358,7 @@ class DefaultTitleBar {
1355
1358
  this.namespace = namespace;
1356
1359
  this.title = title;
1357
1360
  this.state = state;
1361
+ this.boxStatus = boxStatus;
1358
1362
  this.buttons = buttons || [
1359
1363
  {
1360
1364
  type: exports.TELE_BOX_DELEGATE_EVENT.Minimize,
@@ -1389,6 +1393,18 @@ class DefaultTitleBar {
1389
1393
  });
1390
1394
  }
1391
1395
  }
1396
+ setBoxStatus(boxStatus) {
1397
+ if (this.boxStatus !== boxStatus) {
1398
+ this.boxStatus = boxStatus;
1399
+ if (boxStatus) {
1400
+ this.buttons.forEach((btn, i2) => {
1401
+ if (btn.isActive) {
1402
+ this.$btns[i2].classList.toggle("is-active", btn.isActive(boxStatus));
1403
+ }
1404
+ });
1405
+ }
1406
+ }
1407
+ }
1392
1408
  setReadonly(readonly) {
1393
1409
  if (this.readonly !== readonly) {
1394
1410
  this.readonly = readonly;
@@ -1419,7 +1435,7 @@ class DefaultTitleBar {
1419
1435
  $btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
1420
1436
  $btn.dataset.teleTitleBarNoDblClick = "true";
1421
1437
  if (isActive) {
1422
- $btn.classList.toggle("is-active", isActive(this.state));
1438
+ $btn.classList.toggle("is-active", isActive(this.boxStatus || this.state));
1423
1439
  }
1424
1440
  this.$btns.push($btn);
1425
1441
  $buttonsContainer.appendChild($btn);
@@ -1505,7 +1521,9 @@ class TeleBox {
1505
1521
  width: window.innerWidth,
1506
1522
  height: window.innerHeight
1507
1523
  },
1508
- collectorRect
1524
+ collectorRect,
1525
+ boxStatus,
1526
+ lastNotMinimizedBoxStatus
1509
1527
  } = {}) {
1510
1528
  this._renderSideEffect = new o();
1511
1529
  this.handleTrackStart = (ev) => {
@@ -1519,6 +1537,8 @@ class TeleBox {
1519
1537
  this.namespace = namespace;
1520
1538
  this.events = new EventEmitter();
1521
1539
  this._delegateEvents = new EventEmitter();
1540
+ const boxStatus$ = createVal(boxStatus);
1541
+ const lastNotMinimizedBoxStatus$ = createVal(lastNotMinimizedBoxStatus);
1522
1542
  const prefersColorScheme$ = createVal(prefersColorScheme);
1523
1543
  prefersColorScheme$.reaction((prefersColorScheme2, _, skipUpdate) => {
1524
1544
  if (!skipUpdate) {
@@ -1601,7 +1621,7 @@ class TeleBox {
1601
1621
  this.events.emit(exports.TELE_BOX_EVENT.Maximized, maximized2);
1602
1622
  }
1603
1623
  });
1604
- const state$ = combine([minimized$, maximized$], ([minimized2, maximized2]) => minimized2 ? exports.TELE_BOX_STATE.Minimized : maximized2 ? exports.TELE_BOX_STATE.Maximized : exports.TELE_BOX_STATE.Normal);
1624
+ const state$ = combine([minimized$, maximized$, boxStatus$], ([minimized2, maximized2, boxStatus2]) => minimized2 ? exports.TELE_BOX_STATE.Minimized : maximized2 ? exports.TELE_BOX_STATE.Maximized : !boxStatus2 ? exports.TELE_BOX_STATE.Normal : boxStatus2);
1605
1625
  state$.reaction((state, _, skipUpdate) => {
1606
1626
  if (!skipUpdate) {
1607
1627
  this.events.emit(exports.TELE_BOX_EVENT.State, state);
@@ -1626,8 +1646,8 @@ class TeleBox {
1626
1646
  this.events.emit(exports.TELE_BOX_EVENT.IntrinsicResize, size);
1627
1647
  }
1628
1648
  });
1629
- const size$ = combine([intrinsicSize$, maximized$], ([intrinsicSize, maximized2]) => {
1630
- if (maximized2) {
1649
+ const size$ = combine([intrinsicSize$, maximized$, boxStatus$], ([intrinsicSize, maximized2, boxStatus2]) => {
1650
+ if (maximized2 || boxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1631
1651
  return { width: 1, height: 1 };
1632
1652
  }
1633
1653
  return intrinsicSize;
@@ -1637,8 +1657,8 @@ class TeleBox {
1637
1657
  this.events.emit(exports.TELE_BOX_EVENT.Resize, size);
1638
1658
  }
1639
1659
  });
1640
- const visualSize$ = combine([size$, minimized$, containerRect$, collectorRect$], ([size, minimized2, containerRect2, collectorRect2]) => {
1641
- if (minimized2 && collectorRect2) {
1660
+ const visualSize$ = combine([size$, minimized$, containerRect$, collectorRect$, boxStatus$], ([size, minimized2, containerRect2, collectorRect2, boxStatus2]) => {
1661
+ if ((minimized2 || boxStatus2 === exports.TELE_BOX_STATE.Minimized) && collectorRect2) {
1642
1662
  return {
1643
1663
  width: collectorRect2.width / size.width / containerRect2.width,
1644
1664
  height: collectorRect2.height / size.height / containerRect2.height
@@ -1663,17 +1683,21 @@ class TeleBox {
1663
1683
  containerRect$,
1664
1684
  collectorRect$,
1665
1685
  minimized$,
1666
- maximized$
1686
+ maximized$,
1687
+ boxStatus$,
1688
+ lastNotMinimizedBoxStatus$
1667
1689
  ], ([
1668
1690
  intrinsicCoord,
1669
1691
  intrinsicSize,
1670
1692
  containerRect2,
1671
1693
  collectorRect2,
1672
1694
  minimized2,
1673
- maximized2
1695
+ maximized2,
1696
+ boxStatus2,
1697
+ lastNotMinimizedBoxStatus2
1674
1698
  ]) => {
1675
- if (minimized2 && collectorRect2) {
1676
- if (maximized2) {
1699
+ if ((minimized2 || boxStatus2 === exports.TELE_BOX_STATE.Minimized) && collectorRect2) {
1700
+ if (maximized2 || lastNotMinimizedBoxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1677
1701
  return {
1678
1702
  x: (collectorRect2.x + collectorRect2.width / 2) / containerRect2.width - 1 / 2,
1679
1703
  y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - 1 / 2
@@ -1684,7 +1708,7 @@ class TeleBox {
1684
1708
  y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - intrinsicSize.height / 2
1685
1709
  };
1686
1710
  }
1687
- if (maximized2) {
1711
+ if (maximized2 || boxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1688
1712
  return { x: 0, y: 0 };
1689
1713
  }
1690
1714
  return intrinsicCoord;
@@ -1698,6 +1722,7 @@ class TeleBox {
1698
1722
  readonly: readonly$.value,
1699
1723
  title: title$.value,
1700
1724
  namespace: this.namespace,
1725
+ boxStatus: boxStatus$.value,
1701
1726
  onDragStart: (event) => {
1702
1727
  var _a;
1703
1728
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1708,11 +1733,15 @@ class TeleBox {
1708
1733
  } else {
1709
1734
  switch (event.type) {
1710
1735
  case exports.TELE_BOX_DELEGATE_EVENT.Maximize: {
1711
- maximized$.setValue(!maximized$.value);
1736
+ if (!boxStatus$.value) {
1737
+ maximized$.setValue(!maximized$.value);
1738
+ }
1712
1739
  break;
1713
1740
  }
1714
1741
  case exports.TELE_BOX_DELEGATE_EVENT.Minimize: {
1715
- minimized$.setValue(true);
1742
+ if (!boxStatus$.value) {
1743
+ minimized$.setValue(true);
1744
+ }
1716
1745
  break;
1717
1746
  }
1718
1747
  case exports.TELE_BOX_DELEGATE_EVENT.Close: {
@@ -1730,6 +1759,9 @@ class TeleBox {
1730
1759
  readonly$.reaction((readonly2) => {
1731
1760
  this.titleBar.setReadonly(readonly2);
1732
1761
  });
1762
+ boxStatus$.reaction((boxStatus2) => {
1763
+ this.titleBar.setBoxStatus(boxStatus2);
1764
+ });
1733
1765
  const $userContent$ = createVal(content);
1734
1766
  const $userFooter$ = createVal(footer);
1735
1767
  const $userStyles$ = createVal(styles);
@@ -1761,11 +1793,22 @@ class TeleBox {
1761
1793
  this._visualSize$ = visualSize$;
1762
1794
  this._coord$ = coord$;
1763
1795
  this._intrinsicCoord$ = intrinsicCoord$;
1796
+ this._boxStatus$ = boxStatus$;
1797
+ this._lastNotMinimizedBoxStatus$ = lastNotMinimizedBoxStatus$;
1764
1798
  if (this.fixRatio) {
1765
1799
  this.transform(coord$.value.x, coord$.value.y, size$.value.width, size$.value.height, true);
1766
1800
  }
1767
1801
  this.$box = this.render();
1768
1802
  }
1803
+ get boxStatus() {
1804
+ return this._boxStatus$.value;
1805
+ }
1806
+ set boxStatus(boxStatus) {
1807
+ this._boxStatus$.setValue(boxStatus);
1808
+ }
1809
+ get lastNotMinimizedBoxStatus() {
1810
+ return this._lastNotMinimizedBoxStatus$.value;
1811
+ }
1769
1812
  get darkMode() {
1770
1813
  return this._darkMode$.value;
1771
1814
  }
@@ -1792,6 +1835,27 @@ class TeleBox {
1792
1835
  }
1793
1836
  return this;
1794
1837
  }
1838
+ setBoxStatus(boxStatus, skipUpdate = false) {
1839
+ if (boxStatus === exports.TELE_BOX_STATE.Minimized) {
1840
+ if (this._boxStatus$.value && this._boxStatus$.value !== exports.TELE_BOX_STATE.Minimized) {
1841
+ this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1842
+ }
1843
+ } else {
1844
+ this.setLastNotMinimizedBoxStatus(void 0, skipUpdate);
1845
+ }
1846
+ this._boxStatus$.setValue(boxStatus, skipUpdate);
1847
+ if (!skipUpdate) {
1848
+ this.events.emit(exports.TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1849
+ }
1850
+ return this;
1851
+ }
1852
+ setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1853
+ this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1854
+ if (!skipUpdate) {
1855
+ this.events.emit(exports.TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1856
+ }
1857
+ return this;
1858
+ }
1795
1859
  get minWidth() {
1796
1860
  return this._minSize$.value.width;
1797
1861
  }
@@ -1986,17 +2050,18 @@ class TeleBox {
1986
2050
  this._size$,
1987
2051
  this._minimized$,
1988
2052
  this._containerRect$,
1989
- this._collectorRect$
1990
- ], ([coord, size, minimized, containerRect, collectorRect]) => {
2053
+ this._collectorRect$,
2054
+ this._boxStatus$
2055
+ ], ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
1991
2056
  const absoluteWidth = size.width * containerRect.width;
1992
2057
  const absoluteHeight = size.height * containerRect.height;
1993
2058
  return {
1994
- width: absoluteWidth + (minimized && collectorRect ? 1 : 0),
1995
- height: absoluteHeight + (minimized && collectorRect ? 1 : 0),
2059
+ width: absoluteWidth + ((minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
2060
+ height: absoluteHeight + ((minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
1996
2061
  x: coord.x * containerRect.width,
1997
2062
  y: coord.y * containerRect.height,
1998
- scaleX: minimized && collectorRect ? collectorRect.width / absoluteWidth : 1,
1999
- scaleY: minimized && collectorRect ? collectorRect.height / absoluteHeight : 1
2063
+ scaleX: (minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.width / absoluteWidth : 1,
2064
+ scaleY: (minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.height / absoluteHeight : 1
2000
2065
  };
2001
2066
  }, shallowequal).subscribe((styles) => {
2002
2067
  boxStyler.set(styles);
@@ -2343,6 +2408,8 @@ exports.TELE_BOX_MANAGER_EVENT = void 0;
2343
2408
  TELE_BOX_MANAGER_EVENT2["ZIndex"] = "z_index";
2344
2409
  TELE_BOX_MANAGER_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
2345
2410
  TELE_BOX_MANAGER_EVENT2["DarkMode"] = "dark_mode";
2411
+ TELE_BOX_MANAGER_EVENT2["BoxStatus"] = "box_status";
2412
+ TELE_BOX_MANAGER_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
2346
2413
  })(exports.TELE_BOX_MANAGER_EVENT || (exports.TELE_BOX_MANAGER_EVENT = {}));
2347
2414
  var style = ".telebox-max-titlebar {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n display: none;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 50000;\n}\n.telebox-max-titlebar .telebox-title {\n display: none;\n}\n.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-titles {\n display: none;\n}\n.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-title {\n display: block;\n}\n.telebox-max-titlebar-maximized {\n display: flex;\n}\n.telebox-titles {\n height: 100%;\n margin: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n overflow-x: overlay;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n scrollbar-width: auto;\n}\n.telebox-titles::-webkit-scrollbar {\n height: 8px;\n width: 8px;\n}\n.telebox-titles::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.telebox-titles::-webkit-scrollbar-thumb {\n background-color: rgba(238, 238, 247, 0.8);\n background-color: transparent;\n border-radius: 4px;\n transition: background-color 0.4s;\n}\n.telebox-titles:hover::-webkit-scrollbar-thumb {\n background-color: rgba(238, 238, 247, 0.8);\n}\n.telebox-titles::-webkit-scrollbar-thumb:hover {\n background-color: #eeeef7;\n}\n.telebox-titles::-webkit-scrollbar-thumb:active {\n background-color: #eeeef7;\n}\n.telebox-titles::-webkit-scrollbar-thumb:vertical {\n min-height: 50px;\n}\n.telebox-titles::-webkit-scrollbar-thumb:horizontal {\n min-width: 50px;\n}\n.telebox-titles-content {\n height: 100%;\n display: flex;\n flex-wrap: nowrap;\n align-items: center;\n padding: 0;\n}\n.telebox-titles-tab {\n height: 100%;\n overflow: hidden;\n max-width: 182px;\n min-width: 50px;\n padding: 0 26px 0 16px;\n outline: none;\n font-size: 13px;\n font-family: PingFangSC-Regular, PingFang SC;\n font-weight: 400;\n text-overflow: ellipsis;\n white-space: nowrap;\n word-break: keep-all;\n border: none;\n border-right: 1px solid #e5e5f0;\n color: #7b88a0;\n background: transparent;\n cursor: pointer;\n user-select: none;\n}\n.telebox-titles-tab-focus {\n color: #357bf6;\n}\n.telebox-readonly .telebox-titles-tab {\n cursor: not-allowed;\n}\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n.telebox-color-scheme-dark.telebox-titlebar {\n color: #e9e9e9;\n background: #43434d;\n border-bottom: none;\n}\n.telebox-color-scheme-dark .telebox-titles-tab {\n border-right-color: #7b88a0;\n}\n.telebox-color-scheme-dark .telebox-title {\n color: #e9e9e9;\n}";
2348
2415
  class MaxTitleBar extends DefaultTitleBar {
@@ -2352,22 +2419,50 @@ class MaxTitleBar extends DefaultTitleBar {
2352
2419
  this.focusedBox = config.focusedBox;
2353
2420
  this.containerRect = config.containerRect;
2354
2421
  this.darkMode = config.darkMode;
2422
+ this.boxesStatus = config.boxesStatus;
2423
+ }
2424
+ hasMaximizedBoxInStatus() {
2425
+ if (!this.boxesStatus || this.boxesStatus.size === 0) {
2426
+ return false;
2427
+ }
2428
+ const hasMaximizedBox = [...this.boxesStatus.values()].find((state) => state === exports.TELE_BOX_STATE.Maximized);
2429
+ return !!hasMaximizedBox;
2430
+ }
2431
+ get MaximizedBoxes() {
2432
+ if (!this.boxesStatus || this.boxesStatus.size === 0) {
2433
+ return [];
2434
+ }
2435
+ return this.boxes.filter((box) => this.boxesStatus && this.boxesStatus.get(box.id) === exports.TELE_BOX_STATE.Maximized);
2355
2436
  }
2356
2437
  focusBox(box) {
2357
- var _a;
2438
+ var _a, _b;
2358
2439
  if (this.focusedBox && this.focusedBox === box) {
2359
2440
  return;
2360
2441
  }
2361
- if (this.$titles && this.state === exports.TELE_BOX_STATE.Maximized) {
2442
+ if (this.$titles) {
2362
2443
  const { children } = this.$titles.firstElementChild;
2363
- for (let i2 = children.length - 1; i2 >= 0; i2 -= 1) {
2364
- const $tab = children[i2];
2365
- const id = (_a = $tab.dataset) == null ? void 0 : _a.teleBoxID;
2366
- if (id) {
2367
- if (box && id === box.id) {
2368
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
2369
- } else if (this.focusedBox && id === this.focusedBox.id) {
2370
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
2444
+ if (this.state === exports.TELE_BOX_STATE.Maximized && !this.hasMaximizedBoxInStatus()) {
2445
+ for (let i2 = children.length - 1; i2 >= 0; i2 -= 1) {
2446
+ const $tab = children[i2];
2447
+ const id = (_a = $tab.dataset) == null ? void 0 : _a.teleBoxID;
2448
+ if (id) {
2449
+ if (box && id === box.id) {
2450
+ $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
2451
+ } else if (this.focusedBox && id === this.focusedBox.id) {
2452
+ $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
2453
+ }
2454
+ }
2455
+ }
2456
+ } else if (this.hasMaximizedBoxInStatus()) {
2457
+ for (let i2 = children.length - 1; i2 >= 0; i2 -= 1) {
2458
+ const $tab = children[i2];
2459
+ const id = (_b = $tab.dataset) == null ? void 0 : _b.teleBoxID;
2460
+ if (id) {
2461
+ if (box && id === box.id) {
2462
+ $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
2463
+ } else if (this.focusedBox && id === this.focusedBox.id) {
2464
+ $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
2465
+ }
2371
2466
  }
2372
2467
  }
2373
2468
  }
@@ -2382,17 +2477,27 @@ class MaxTitleBar extends DefaultTitleBar {
2382
2477
  this.$titleBar.style.width = width + "px";
2383
2478
  }
2384
2479
  }
2480
+ setBoxesStatus(boxesStatus) {
2481
+ this.boxesStatus = boxesStatus;
2482
+ if (this.hasMaximizedBoxInStatus()) {
2483
+ this.setBoxStatus(exports.TELE_BOX_STATE.Maximized);
2484
+ }
2485
+ if (this.$titleBar) {
2486
+ this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus());
2487
+ }
2488
+ this.updateTitles();
2489
+ }
2385
2490
  setBoxes(boxes) {
2386
2491
  this.boxes = boxes;
2387
2492
  if (this.$titleBar) {
2388
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && boxes.length > 0);
2493
+ this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && boxes.length > 0 || this.hasMaximizedBoxInStatus());
2389
2494
  }
2390
2495
  this.updateTitles();
2391
2496
  }
2392
2497
  setState(state) {
2393
2498
  super.setState(state);
2394
2499
  if (this.$titleBar) {
2395
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0);
2500
+ this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus());
2396
2501
  }
2397
2502
  this.updateTitles();
2398
2503
  }
@@ -2433,9 +2538,9 @@ class MaxTitleBar extends DefaultTitleBar {
2433
2538
  this.focusedBox = void 0;
2434
2539
  }
2435
2540
  updateTitles() {
2436
- if (this.$titleBar && this.state === exports.TELE_BOX_STATE.Maximized) {
2437
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"), this.boxes.length === 1);
2438
- if (this.boxes.length === 1) {
2541
+ if (this.$titleBar && (this.state === exports.TELE_BOX_STATE.Maximized || this.hasMaximizedBoxInStatus())) {
2542
+ this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"), this.boxes.length === 1 || this.hasMaximizedBoxInStatus() && this.MaximizedBoxes.length === 1);
2543
+ if (this.boxes.length === 1 || this.hasMaximizedBoxInStatus() && this.MaximizedBoxes.length === 1) {
2439
2544
  this.setTitle(this.boxes[0].title);
2440
2545
  } else {
2441
2546
  this.$titleBar.replaceChild(this.renderTitles(), this.$titleBar.firstElementChild);
@@ -2454,7 +2559,7 @@ class MaxTitleBar extends DefaultTitleBar {
2454
2559
  const $content = document.createElement("div");
2455
2560
  $content.className = this.wrapClassName("titles-content");
2456
2561
  this.$titles.appendChild($content);
2457
- this.boxes.forEach((box) => {
2562
+ (this.hasMaximizedBoxInStatus() ? this.MaximizedBoxes : this.boxes).forEach((box) => {
2458
2563
  const $tab = document.createElement("button");
2459
2564
  $tab.className = this.wrapClassName("titles-tab");
2460
2565
  $tab.textContent = box.title;
@@ -2493,11 +2598,18 @@ class TeleBoxManager {
2493
2598
  this.boxes$ = createVal([]);
2494
2599
  this.topBox$ = this.boxes$.derive((boxes) => {
2495
2600
  if (boxes.length > 0) {
2496
- const topBox = boxes.reduce((topBox2, box) => topBox2.zIndex > box.zIndex ? topBox2 : box);
2601
+ const topBox = boxes.reduce((topBox2, box) => {
2602
+ if (box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized) {
2603
+ return topBox2;
2604
+ }
2605
+ return topBox2.zIndex > box.zIndex ? topBox2 : box;
2606
+ });
2497
2607
  return topBox;
2498
2608
  }
2499
2609
  return;
2500
2610
  });
2611
+ this.boxesStatus$ = new Map();
2612
+ this.lastNotMinimizedBoxesStatus$ = new Map();
2501
2613
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
2502
2614
  const prefersDark$ = createVal(false);
2503
2615
  if (prefersDark) {
@@ -2565,6 +2677,16 @@ class TeleBoxManager {
2565
2677
  this._sideEffect.add(() => {
2566
2678
  collector2.onClick = () => {
2567
2679
  if (!readonly$.value) {
2680
+ if (this.hasMinimizedBox()) {
2681
+ this.getAllMinimizedBoxes().forEach((box) => {
2682
+ const lastNotMinimizedBoxStatus = box.lastNotMinimizedBoxStatus;
2683
+ if (lastNotMinimizedBoxStatus) {
2684
+ this.setBoxStatus(box.id, lastNotMinimizedBoxStatus);
2685
+ } else {
2686
+ this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Normal);
2687
+ }
2688
+ });
2689
+ }
2568
2690
  minimized$.setValue(false);
2569
2691
  }
2570
2692
  };
@@ -2580,7 +2702,7 @@ class TeleBoxManager {
2580
2702
  var _a;
2581
2703
  (_a = collector$.value) == null ? void 0 : _a.setDarkMode(darkMode);
2582
2704
  });
2583
- const calcCollectorRect = () => {
2705
+ this._calcCollectorRect = () => {
2584
2706
  var _a;
2585
2707
  if ((_a = collector$.value) == null ? void 0 : _a.$collector) {
2586
2708
  const { x, y, width, height } = collector$.value.$collector.getBoundingClientRect();
@@ -2594,7 +2716,7 @@ class TeleBoxManager {
2594
2716
  }
2595
2717
  return;
2596
2718
  };
2597
- const collectorRect$ = createVal(minimized$.value ? calcCollectorRect() : void 0);
2719
+ const collectorRect$ = createVal(minimized$.value ? this._calcCollectorRect() : void 0);
2598
2720
  collectorRect$.subscribe((collectorRect, _, skipUpdate) => {
2599
2721
  this.boxes.forEach((box) => {
2600
2722
  box.setCollectorRect(collectorRect, skipUpdate);
@@ -2605,7 +2727,7 @@ class TeleBoxManager {
2605
2727
  (_a = collector$.value) == null ? void 0 : _a.setVisible(minimized2);
2606
2728
  if (minimized2) {
2607
2729
  if ((_b = collector$.value) == null ? void 0 : _b.$collector) {
2608
- collectorRect$.setValue(calcCollectorRect());
2730
+ collectorRect$.setValue(this._calcCollectorRect());
2609
2731
  }
2610
2732
  }
2611
2733
  this.boxes.forEach((box) => box.setMinimized(minimized2, skipUpdate));
@@ -2632,7 +2754,9 @@ class TeleBoxManager {
2632
2754
  const box = this.getBox(id);
2633
2755
  if (box) {
2634
2756
  this.focusBox(box);
2635
- this.makeBoxTop(box);
2757
+ if (box.boxStatus && box.boxStatus !== exports.TELE_BOX_STATE.Maximized || !box.boxStatus) {
2758
+ this.makeBoxTop(box);
2759
+ }
2636
2760
  return;
2637
2761
  }
2638
2762
  }
@@ -2647,19 +2771,36 @@ class TeleBoxManager {
2647
2771
  state: state$.value,
2648
2772
  boxes: this.boxes$.value,
2649
2773
  containerRect: containerRect$.value,
2774
+ boxesStatus: this.boxesStatus$,
2650
2775
  onEvent: (event) => {
2776
+ var _a, _b, _c;
2651
2777
  switch (event.type) {
2652
2778
  case exports.TELE_BOX_DELEGATE_EVENT.Maximize: {
2653
- maximized$.setValue(!maximized$.value);
2779
+ if (this.hasBoxesStatus() && ((_a = this.maxTitleBar.focusedBox) == null ? void 0 : _a.id)) {
2780
+ this.setBoxStatus(this.maxTitleBar.focusedBox.id, exports.TELE_BOX_STATE.Normal);
2781
+ this.makeMaximizedTopBoxFocus();
2782
+ } else {
2783
+ maximized$.setValue(!maximized$.value);
2784
+ }
2654
2785
  break;
2655
2786
  }
2656
2787
  case exports.TELE_BOX_DELEGATE_EVENT.Minimize: {
2657
- minimized$.setValue(true);
2788
+ if (this.hasBoxesStatus() && ((_b = this.maxTitleBar.focusedBox) == null ? void 0 : _b.id)) {
2789
+ this.setBoxStatus(this.maxTitleBar.focusedBox.id, exports.TELE_BOX_STATE.Minimized);
2790
+ this.makeMaximizedTopBoxFocus();
2791
+ } else {
2792
+ minimized$.setValue(true);
2793
+ }
2658
2794
  break;
2659
2795
  }
2660
2796
  case exports.TELE_BOX_EVENT.Close: {
2661
- this.removeTopBox();
2662
- this.focusTopBox();
2797
+ if (this.hasBoxesStatus() && ((_c = this.maxTitleBar.focusedBox) == null ? void 0 : _c.id)) {
2798
+ this.remove(this.maxTitleBar.focusedBox.id);
2799
+ this.makeMaximizedTopBoxFocus();
2800
+ } else {
2801
+ this.removeTopBox();
2802
+ this.focusTopBox();
2803
+ }
2663
2804
  break;
2664
2805
  }
2665
2806
  }
@@ -2718,6 +2859,89 @@ class TeleBoxManager {
2718
2859
  }
2719
2860
  return this;
2720
2861
  }
2862
+ setBoxStatus(boxId, boxStatus, skipUpdate = false) {
2863
+ const boxesStatus = this.boxesStatus$;
2864
+ if (boxStatus) {
2865
+ const oldBoxStatus = boxesStatus.get(boxId);
2866
+ boxesStatus.set(boxId, boxStatus);
2867
+ if (boxStatus === exports.TELE_BOX_STATE.Minimized && oldBoxStatus !== exports.TELE_BOX_STATE.Minimized) {
2868
+ this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
2869
+ } else if (oldBoxStatus === exports.TELE_BOX_STATE.Minimized && boxStatus !== exports.TELE_BOX_STATE.Minimized) {
2870
+ this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
2871
+ }
2872
+ } else {
2873
+ boxesStatus.delete(boxId);
2874
+ this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
2875
+ }
2876
+ this.setBoxesStatus(boxesStatus, skipUpdate);
2877
+ if (!skipUpdate) {
2878
+ this.events.emit(exports.TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
2879
+ }
2880
+ }
2881
+ setBoxesStatus(boxesStatus, skipUpdate = false) {
2882
+ var _a, _b, _c, _d;
2883
+ let topBox;
2884
+ const topBoxId = (_a = this.topBox) == null ? void 0 : _a.id;
2885
+ let hasMinimizedBox = false;
2886
+ this.boxes.forEach((box) => {
2887
+ var _a2;
2888
+ const boxStatus = boxesStatus.get(box.id);
2889
+ if (boxStatus) {
2890
+ if (boxStatus !== exports.TELE_BOX_STATE.Minimized && box.zIndex > ((_a2 = topBox == null ? void 0 : topBox.zIndex) != null ? _a2 : 0)) {
2891
+ topBox = box;
2892
+ }
2893
+ box.setBoxStatus(boxStatus, skipUpdate);
2894
+ if (boxStatus === exports.TELE_BOX_STATE.Minimized) {
2895
+ hasMinimizedBox = true;
2896
+ }
2897
+ }
2898
+ });
2899
+ if (hasMinimizedBox) {
2900
+ (_b = this.collector) == null ? void 0 : _b.setVisible(true);
2901
+ if ((_c = this.collector) == null ? void 0 : _c.$collector) {
2902
+ this.setCollectorRect(this._calcCollectorRect());
2903
+ }
2904
+ } else {
2905
+ (_d = this.collector) == null ? void 0 : _d.setVisible(false);
2906
+ }
2907
+ if (topBox && topBoxId !== topBox.id) {
2908
+ this.makeBoxTop(topBox, skipUpdate);
2909
+ this.focusTopBox();
2910
+ this.topBox$.setValue(topBox);
2911
+ }
2912
+ if (this.maxTitleBar) {
2913
+ this.maxTitleBar.setBoxesStatus(boxesStatus);
2914
+ }
2915
+ }
2916
+ hasBoxesStatus() {
2917
+ return this.boxesStatus$.size > 0;
2918
+ }
2919
+ hasMinimizedBox() {
2920
+ return this.boxes.some((box) => box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized);
2921
+ }
2922
+ setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
2923
+ const boxesStatus = this.lastNotMinimizedBoxesStatus$;
2924
+ if (lastNotMinimizedBoxStatus) {
2925
+ boxesStatus.set(boxId, lastNotMinimizedBoxStatus);
2926
+ } else {
2927
+ boxesStatus.delete(boxId);
2928
+ }
2929
+ this.setLastNotMinimizedBoxesStatus(boxesStatus, skipUpdate);
2930
+ if (!skipUpdate) {
2931
+ this.events.emit(exports.TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
2932
+ }
2933
+ }
2934
+ setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
2935
+ this.boxes.forEach((box) => {
2936
+ const boxStatus = lastNotMinimizedBoxesStatus.get(box.id);
2937
+ if (boxStatus) {
2938
+ box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
2939
+ }
2940
+ });
2941
+ }
2942
+ getAllMinimizedBoxes() {
2943
+ return this.boxes.filter((box) => box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized);
2944
+ }
2721
2945
  create(config = {}, smartPosition = true) {
2722
2946
  const box = new TeleBox(__spreadProps(__spreadValues({
2723
2947
  zIndex: this.topBox ? this.topBox.zIndex + 1 : 100
@@ -2740,11 +2964,38 @@ class TeleBoxManager {
2740
2964
  }
2741
2965
  }
2742
2966
  this.boxes$.setValue([...this.boxes, box]);
2967
+ if (box.boxStatus) {
2968
+ this.setBoxStatus(box.id, box.boxStatus, true);
2969
+ }
2970
+ if (box._lastNotMinimizedBoxStatus$.value) {
2971
+ this.setLastNotMinimizedBoxStatus(box.id, box._lastNotMinimizedBoxStatus$.value, true);
2972
+ }
2743
2973
  box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize, () => {
2744
- this.setMaximized(!this.maximized);
2974
+ if (box.boxStatus) {
2975
+ if (box.boxStatus === exports.TELE_BOX_STATE.Maximized) {
2976
+ this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Normal);
2977
+ } else {
2978
+ this.boxes.forEach((box2) => {
2979
+ if (box2.boxStatus !== exports.TELE_BOX_STATE.Maximized) {
2980
+ this.setBoxStatus(box2.id, exports.TELE_BOX_STATE.Maximized);
2981
+ }
2982
+ });
2983
+ }
2984
+ this.makeMaximizedTopBoxFocus();
2985
+ } else {
2986
+ this.setMaximized(!this.maximized);
2987
+ }
2745
2988
  });
2746
2989
  box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize, () => {
2747
- this.setMinimized(true);
2990
+ if (box.boxStatus) {
2991
+ const oldBoxStatus = box.boxStatus;
2992
+ this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Minimized);
2993
+ if (oldBoxStatus === exports.TELE_BOX_STATE.Maximized) {
2994
+ this.makeMaximizedTopBoxFocus();
2995
+ }
2996
+ } else {
2997
+ this.setMinimized(true);
2998
+ }
2748
2999
  });
2749
3000
  box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close, () => {
2750
3001
  this.remove(box);
@@ -2777,7 +3028,12 @@ class TeleBoxManager {
2777
3028
  });
2778
3029
  box._zIndex$.reaction((_, __, skipUpdate) => {
2779
3030
  if (this.boxes.length > 0) {
2780
- const topBox = this.boxes.reduce((topBox2, box2) => topBox2.zIndex > box2.zIndex ? topBox2 : box2);
3031
+ const topBox = this.boxes.reduce((topBox2, box2) => {
3032
+ if (box2.boxStatus && box2.boxStatus === exports.TELE_BOX_STATE.Minimized) {
3033
+ return topBox2;
3034
+ }
3035
+ return topBox2.zIndex > box2.zIndex ? topBox2 : box2;
3036
+ });
2781
3037
  this.topBox$.setValue(topBox);
2782
3038
  }
2783
3039
  if (!skipUpdate) {
@@ -2805,12 +3061,17 @@ class TeleBoxManager {
2805
3061
  });
2806
3062
  }
2807
3063
  remove(boxOrID, skipUpdate = false) {
3064
+ const box = this.getBox(boxOrID);
3065
+ if (box) {
3066
+ this.setBoxStatus(box.id, void 0, skipUpdate);
3067
+ this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
3068
+ }
2808
3069
  const index2 = this.getBoxIndex(boxOrID);
2809
3070
  if (index2 >= 0) {
2810
3071
  const boxes = this.boxes.slice();
2811
3072
  const deletedBoxes = boxes.splice(index2, 1);
2812
3073
  this.boxes$.setValue(boxes);
2813
- deletedBoxes.forEach((box) => box.destroy());
3074
+ deletedBoxes.forEach((box2) => box2.destroy());
2814
3075
  if (!skipUpdate) {
2815
3076
  if (this.boxes.length <= 0) {
2816
3077
  this.setMaximized(false);
@@ -2832,6 +3093,8 @@ class TeleBoxManager {
2832
3093
  const deletedBoxes = this.boxes$.value;
2833
3094
  this.boxes$.setValue([]);
2834
3095
  deletedBoxes.forEach((box) => box.destroy());
3096
+ this.boxesStatus$.clear();
3097
+ this.lastNotMinimizedBoxesStatus$.clear();
2835
3098
  if (!skipUpdate) {
2836
3099
  if (this.boxes.length <= 0) {
2837
3100
  this.setMaximized(false);
@@ -2872,7 +3135,11 @@ class TeleBoxManager {
2872
3135
  this.blurBox(box, skipUpdate);
2873
3136
  }
2874
3137
  });
2875
- this.maxTitleBar.focusBox(targetBox);
3138
+ if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3139
+ this.makeMaximizedBoxFocus(targetBox);
3140
+ } else {
3141
+ this.maxTitleBar.focusBox(targetBox);
3142
+ }
2876
3143
  }
2877
3144
  }
2878
3145
  focusTopBox() {
@@ -2890,7 +3157,11 @@ class TeleBoxManager {
2890
3157
  }
2891
3158
  }
2892
3159
  if (this.maxTitleBar.focusedBox === targetBox) {
2893
- this.maxTitleBar.focusBox();
3160
+ if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3161
+ this.makeMaximizedTopBoxFocus();
3162
+ } else {
3163
+ this.maxTitleBar.focusBox();
3164
+ }
2894
3165
  }
2895
3166
  }
2896
3167
  }
@@ -2904,7 +3175,11 @@ class TeleBoxManager {
2904
3175
  }
2905
3176
  });
2906
3177
  if (this.maxTitleBar.focusedBox) {
2907
- this.maxTitleBar.focusBox();
3178
+ if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3179
+ this.makeMaximizedBoxBlur();
3180
+ } else {
3181
+ this.maxTitleBar.focusBox();
3182
+ }
2908
3183
  }
2909
3184
  }
2910
3185
  teleBoxMatcher(config) {
@@ -2949,6 +3224,12 @@ class TeleBoxManager {
2949
3224
  if (config.footer != null) {
2950
3225
  box.mountFooter(config.footer);
2951
3226
  }
3227
+ if (config.boxStatus) {
3228
+ this.setBoxStatus(box.id, config.boxStatus, skipUpdate);
3229
+ }
3230
+ if (config.lastNotMinimizedBoxStatus) {
3231
+ this.setLastNotMinimizedBoxStatus(box.id, config.lastNotMinimizedBoxStatus, skipUpdate);
3232
+ }
2952
3233
  }
2953
3234
  smartPosition(config = {}) {
2954
3235
  let { x, y } = config;
@@ -2978,10 +3259,62 @@ class TeleBoxManager {
2978
3259
  makeBoxTop(box, skipUpdate = false) {
2979
3260
  if (this.topBox) {
2980
3261
  if (box !== this.topBox) {
3262
+ const currentBoxZIndex = box.zIndex;
3263
+ const addZIndex = this.topBox.zIndex + 1 - box.zIndex;
2981
3264
  box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
3265
+ this.makeTopBoxEffect(box.id, addZIndex, currentBoxZIndex, skipUpdate);
3266
+ }
3267
+ }
3268
+ }
3269
+ makeMaximizedTopBoxFocus() {
3270
+ let maximizedBox;
3271
+ if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3272
+ maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
3273
+ if (!topBox) {
3274
+ return currentBox;
3275
+ }
3276
+ return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
3277
+ });
3278
+ if (maximizedBox) {
3279
+ this.maxTitleBar.focusBox(maximizedBox);
3280
+ }
3281
+ }
3282
+ }
3283
+ makeTopBoxEffect(boxId, addZIndex, currentZIndex, skipUpdate = false) {
3284
+ if (this.hasBoxesStatus() && this.hasMinimizedBox()) {
3285
+ this.boxes.forEach((b) => {
3286
+ if (b.boxStatus && b.id !== boxId && b.zIndex >= currentZIndex) {
3287
+ b.setZIndex(b.zIndex + addZIndex, skipUpdate);
3288
+ }
3289
+ });
3290
+ }
3291
+ }
3292
+ makeMaximizedBoxFocus(maximizedBox, skipUpdate = false) {
3293
+ if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
3294
+ const currentZIndex = maximizedBox.zIndex;
3295
+ const currentMaximizedTopBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, box) => {
3296
+ if (!topBox) {
3297
+ return box;
3298
+ }
3299
+ return topBox.zIndex > box.zIndex ? topBox : box;
3300
+ });
3301
+ if (currentMaximizedTopBox !== maximizedBox) {
3302
+ const addZIndex = currentMaximizedTopBox.zIndex - currentZIndex + 1;
3303
+ this.boxes.forEach((box) => {
3304
+ if (this.maxTitleBar.MaximizedBoxes.find((b) => b.id === box.id && b.id !== maximizedBox.id)) {
3305
+ return;
3306
+ }
3307
+ if (box.zIndex >= currentZIndex) {
3308
+ box.setZIndex(box.zIndex + addZIndex, skipUpdate);
3309
+ }
3310
+ });
2982
3311
  }
3312
+ this.maxTitleBar.focusBox(maximizedBox);
2983
3313
  }
2984
3314
  }
3315
+ makeMaximizedBoxBlur() {
3316
+ this.maxTitleBar.focusBox();
3317
+ }
2985
3318
  getBoxIndex(boxOrID) {
2986
3319
  return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
2987
3320
  }