@netless/telebox-insider 0.3.0-beta.9 → 0.3.1-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.
@@ -1183,6 +1183,8 @@ var TELE_BOX_EVENT = /* @__PURE__ */ ((TELE_BOX_EVENT2) => {
1183
1183
  TELE_BOX_EVENT2["Destroyed"] = "destroyed";
1184
1184
  TELE_BOX_EVENT2["BoxStatus"] = "box_status";
1185
1185
  TELE_BOX_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
1186
+ TELE_BOX_EVENT2["ForceTop"] = "force_top";
1187
+ TELE_BOX_EVENT2["ForceNormal"] = "force_normal";
1186
1188
  return TELE_BOX_EVENT2;
1187
1189
  })(TELE_BOX_EVENT || {});
1188
1190
  var TELE_BOX_DELEGATE_EVENT = /* @__PURE__ */ ((TELE_BOX_DELEGATE_EVENT2) => {
@@ -1237,7 +1239,10 @@ class DefaultTitleBar {
1237
1239
  onDragStart,
1238
1240
  namespace = "telebox",
1239
1241
  state = TELE_BOX_STATE.Normal,
1240
- boxStatus
1242
+ boxStatus,
1243
+ forceTop = false,
1244
+ forceNormal = false,
1245
+ forceMaximized = false
1241
1246
  } = {}) {
1242
1247
  this.$btns = [];
1243
1248
  this.sideEffect = new o();
@@ -1261,7 +1266,7 @@ class DefaultTitleBar {
1261
1266
  const now = Date.now();
1262
1267
  if (now - this.lastTitleBarClick.timestamp <= 500) {
1263
1268
  if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
1264
- if (this.onEvent) {
1269
+ if (this.onEvent && !this.forceMaximized) {
1265
1270
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1266
1271
  }
1267
1272
  }
@@ -1293,7 +1298,7 @@ class DefaultTitleBar {
1293
1298
  } = ev.touches[0] || {};
1294
1299
  if (now - this.lastTitleBarTouch.timestamp <= 500) {
1295
1300
  if (Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 10) {
1296
- if (this.onEvent) {
1301
+ if (this.onEvent && !this.forceMaximized) {
1297
1302
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1298
1303
  }
1299
1304
  }
@@ -1311,21 +1316,37 @@ class DefaultTitleBar {
1311
1316
  this.title = title;
1312
1317
  this.state = state;
1313
1318
  this.boxStatus = boxStatus;
1314
- this.buttons = buttons || [
1319
+ this.forceTop = forceTop;
1320
+ this.forceNormal = forceNormal;
1321
+ this.forceMaximized = forceMaximized;
1322
+ this.buttons = buttons || (forceNormal ? [
1323
+ {
1324
+ type: TELE_BOX_DELEGATE_EVENT.Close,
1325
+ iconClassName: this.wrapClassName(
1326
+ "titlebar-icon-close"
1327
+ )
1328
+ }
1329
+ ] : [
1315
1330
  {
1316
1331
  type: TELE_BOX_DELEGATE_EVENT.Minimize,
1317
- iconClassName: this.wrapClassName("titlebar-icon-minimize")
1332
+ iconClassName: this.wrapClassName(
1333
+ "titlebar-icon-minimize"
1334
+ )
1318
1335
  },
1319
1336
  {
1320
1337
  type: TELE_BOX_DELEGATE_EVENT.Maximize,
1321
- iconClassName: this.wrapClassName("titlebar-icon-maximize"),
1338
+ iconClassName: this.wrapClassName(
1339
+ "titlebar-icon-maximize"
1340
+ ),
1322
1341
  isActive: (state2) => state2 === TELE_BOX_STATE.Maximized
1323
1342
  },
1324
1343
  {
1325
1344
  type: TELE_BOX_DELEGATE_EVENT.Close,
1326
- iconClassName: this.wrapClassName("titlebar-icon-close")
1345
+ iconClassName: this.wrapClassName(
1346
+ "titlebar-icon-close"
1347
+ )
1327
1348
  }
1328
- ];
1349
+ ]);
1329
1350
  this.$dragArea = this.renderDragArea();
1330
1351
  }
1331
1352
  setTitle(title) {
@@ -1368,6 +1389,20 @@ class DefaultTitleBar {
1368
1389
  this.readonly = readonly;
1369
1390
  }
1370
1391
  }
1392
+ setForceMaximized(forceMaximized) {
1393
+ this.forceMaximized = forceMaximized;
1394
+ this.$btns.forEach((button, index2) => {
1395
+ var _a;
1396
+ if (((_a = this.buttons[index2]) == null ? void 0 : _a.type) === TELE_BOX_DELEGATE_EVENT.Maximize) {
1397
+ button.disabled = forceMaximized;
1398
+ button.setAttribute("aria-disabled", String(forceMaximized));
1399
+ button.classList.toggle(
1400
+ this.wrapClassName("disabled"),
1401
+ forceMaximized
1402
+ );
1403
+ }
1404
+ });
1405
+ }
1371
1406
  render() {
1372
1407
  if (!this.$titleBar) {
1373
1408
  this.$titleBar = document.createElement("div");
@@ -1395,7 +1430,10 @@ class DefaultTitleBar {
1395
1430
  $btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
1396
1431
  $btn.dataset.teleTitleBarNoDblClick = "true";
1397
1432
  if (isActive) {
1398
- $btn.classList.toggle("is-active", isActive(this.boxStatus || this.state));
1433
+ $btn.classList.toggle(
1434
+ "is-active",
1435
+ isActive(this.boxStatus || this.state)
1436
+ );
1399
1437
  }
1400
1438
  this.$btns.push($btn);
1401
1439
  $buttonsContainer.appendChild($btn);
@@ -1415,6 +1453,9 @@ class DefaultTitleBar {
1415
1453
  if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
1416
1454
  preventEvent(ev);
1417
1455
  const btn = this.buttons[teleTitleBarBtnIndex];
1456
+ if (this.forceMaximized && btn.type === TELE_BOX_DELEGATE_EVENT.Maximize) {
1457
+ return;
1458
+ }
1418
1459
  if (this.onEvent) {
1419
1460
  this.onEvent({
1420
1461
  type: btn.type,
@@ -1426,6 +1467,7 @@ class DefaultTitleBar {
1426
1467
  );
1427
1468
  this.$titleBar.appendChild($titleArea);
1428
1469
  this.$titleBar.appendChild($buttonsContainer);
1470
+ this.setForceMaximized(Boolean(this.forceMaximized));
1429
1471
  }
1430
1472
  return this.$titleBar;
1431
1473
  }
@@ -1498,7 +1540,11 @@ class TeleBox {
1498
1540
  },
1499
1541
  collectorRect,
1500
1542
  boxStatus,
1501
- lastNotMinimizedBoxStatus
1543
+ lastNotMinimizedBoxStatus,
1544
+ forceTop = false,
1545
+ forceNormal = false,
1546
+ forceMaximized = false,
1547
+ isDragContent = false
1502
1548
  } = {}) {
1503
1549
  this._renderSideEffect = new o();
1504
1550
  this.handleTrackStart = (ev) => {
@@ -1512,7 +1558,9 @@ class TeleBox {
1512
1558
  this.namespace = namespace;
1513
1559
  this.events = new EventEmitter();
1514
1560
  this._delegateEvents = new EventEmitter();
1515
- const boxStatus$ = createVal(boxStatus);
1561
+ const boxStatus$ = createVal(
1562
+ boxStatus
1563
+ );
1516
1564
  const lastNotMinimizedBoxStatus$ = createVal(lastNotMinimizedBoxStatus);
1517
1565
  const prefersColorScheme$ = createVal(
1518
1566
  prefersColorScheme
@@ -1565,6 +1613,23 @@ class TeleBox {
1565
1613
  });
1566
1614
  const containerRect$ = createVal(containerRect, shallowequal);
1567
1615
  const collectorRect$ = createVal(collectorRect, shallowequal);
1616
+ const forceTop$ = createVal(forceTop);
1617
+ forceTop$.reaction((forceTop2, _, skipUpdate) => {
1618
+ if (!skipUpdate) {
1619
+ this.events.emit(TELE_BOX_EVENT.ForceTop, forceTop2 || false);
1620
+ }
1621
+ });
1622
+ const forceNormal$ = createVal(forceNormal);
1623
+ const forceMaximized$ = createVal(forceMaximized);
1624
+ forceNormal$.reaction((forceNormal2, _, skipUpdate) => {
1625
+ if (!skipUpdate) {
1626
+ this.events.emit(
1627
+ TELE_BOX_EVENT.ForceNormal,
1628
+ forceNormal2 || false
1629
+ );
1630
+ }
1631
+ });
1632
+ const isDragContent$ = createVal(isDragContent);
1568
1633
  const title$ = createVal(title);
1569
1634
  title$.reaction((title2, _, skipUpdate) => {
1570
1635
  if (!skipUpdate) {
@@ -1742,6 +1807,9 @@ class TeleBox {
1742
1807
  title: title$.value,
1743
1808
  namespace: this.namespace,
1744
1809
  boxStatus: boxStatus$.value,
1810
+ forceTop: forceTop$.value,
1811
+ forceNormal: forceNormal$.value,
1812
+ forceMaximized: forceMaximized$.value,
1745
1813
  onDragStart: (event) => {
1746
1814
  var _a;
1747
1815
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1752,7 +1820,7 @@ class TeleBox {
1752
1820
  } else {
1753
1821
  switch (event.type) {
1754
1822
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
1755
- if (!boxStatus$.value) {
1823
+ if (!boxStatus$.value && !(forceMaximized$.value && maximized$.value)) {
1756
1824
  maximized$.setValue(!maximized$.value);
1757
1825
  }
1758
1826
  break;
@@ -1781,6 +1849,9 @@ class TeleBox {
1781
1849
  readonly$.reaction((readonly2) => {
1782
1850
  this.titleBar.setReadonly(readonly2);
1783
1851
  });
1852
+ forceMaximized$.reaction((forceMaximized2) => {
1853
+ this.titleBar.setForceMaximized(forceMaximized2);
1854
+ });
1784
1855
  boxStatus$.reaction((boxStatus2) => {
1785
1856
  this.titleBar.setBoxStatus(boxStatus2);
1786
1857
  });
@@ -1805,7 +1876,11 @@ class TeleBox {
1805
1876
  maximized: maximized$,
1806
1877
  $userContent: $userContent$,
1807
1878
  $userFooter: $userFooter$,
1808
- $userStyles: $userStyles$
1879
+ $userStyles: $userStyles$,
1880
+ forceTop: forceTop$,
1881
+ forceNormal: forceNormal$,
1882
+ forceMaximized: forceMaximized$,
1883
+ isDragContent: isDragContent$
1809
1884
  };
1810
1885
  i(this, valConfig);
1811
1886
  this._state$ = state$;
@@ -1866,21 +1941,33 @@ class TeleBox {
1866
1941
  setBoxStatus(boxStatus, skipUpdate = false) {
1867
1942
  if (boxStatus === TELE_BOX_STATE.Minimized) {
1868
1943
  if (this._boxStatus$.value && this._boxStatus$.value !== TELE_BOX_STATE.Minimized) {
1869
- this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1944
+ this.setLastNotMinimizedBoxStatus(
1945
+ this._boxStatus$.value,
1946
+ skipUpdate
1947
+ );
1870
1948
  }
1871
1949
  } else {
1872
1950
  this.setLastNotMinimizedBoxStatus(void 0, skipUpdate);
1873
1951
  }
1874
1952
  this._boxStatus$.setValue(boxStatus, skipUpdate);
1875
1953
  if (!skipUpdate) {
1876
- this.events.emit(TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1954
+ this.events.emit(TELE_BOX_EVENT.BoxStatus, {
1955
+ id: this.id,
1956
+ boxStatus
1957
+ });
1877
1958
  }
1878
1959
  return this;
1879
1960
  }
1880
1961
  setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1881
- this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1962
+ this._lastNotMinimizedBoxStatus$.setValue(
1963
+ lastNotMinimizedBoxStatus,
1964
+ skipUpdate
1965
+ );
1882
1966
  if (!skipUpdate) {
1883
- this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1967
+ this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, {
1968
+ id: this.id,
1969
+ lastNotMinimizedBoxStatus
1970
+ });
1884
1971
  }
1885
1972
  return this;
1886
1973
  }
@@ -2113,7 +2200,14 @@ class TeleBox {
2113
2200
  this._collectorRect$,
2114
2201
  this._boxStatus$
2115
2202
  ],
2116
- ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2203
+ ([
2204
+ coord,
2205
+ size,
2206
+ minimized,
2207
+ containerRect,
2208
+ collectorRect,
2209
+ boxStatus
2210
+ ]) => {
2117
2211
  const absoluteWidth = size.width * containerRect.width;
2118
2212
  const absoluteHeight = size.height * containerRect.height;
2119
2213
  return {
@@ -2142,6 +2236,9 @@ class TeleBox {
2142
2236
  const $content = document.createElement("div");
2143
2237
  $content.className = this.wrapClassName("content") + " tele-fancy-scrollbar";
2144
2238
  this.$content = $content;
2239
+ if (this.isDragContent) {
2240
+ this.$content.appendChild(this.titleBar.$dragArea);
2241
+ }
2145
2242
  this._renderSideEffect.add(() => {
2146
2243
  let last$userStyles;
2147
2244
  return this._$userStyles$.subscribe(($userStyles) => {
@@ -2571,6 +2668,7 @@ class TeleBoxCollector {
2571
2668
  return `${this.namespace}-${className}`;
2572
2669
  }
2573
2670
  }
2671
+ TeleBoxCollector.kind = "TeleBoxCollector";
2574
2672
  var TELE_BOX_MANAGER_EVENT = /* @__PURE__ */ ((TELE_BOX_MANAGER_EVENT2) => {
2575
2673
  TELE_BOX_MANAGER_EVENT2["Focused"] = "focused";
2576
2674
  TELE_BOX_MANAGER_EVENT2["Blurred"] = "blurred";
@@ -2619,7 +2717,7 @@ class MaxTitleBar extends DefaultTitleBar {
2619
2717
  if (this.getBoxesStatus) {
2620
2718
  const boxesStatus = this.getBoxesStatus();
2621
2719
  if (boxesStatus) {
2622
- return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
2720
+ return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized && !box.forceTop);
2623
2721
  }
2624
2722
  }
2625
2723
  return [];
@@ -2898,7 +2996,6 @@ class AppMenu {
2898
2996
  createMinimizedItem(appId) {
2899
2997
  const appItem = document.createElement("div");
2900
2998
  appItem.classList.add(this.c("app-menu-item"));
2901
- console.log("appId=====>", appId);
2902
2999
  appItem.setAttribute(`data-${this.c("app-id")}`, appId);
2903
3000
  const titleDiv = document.createElement("div");
2904
3001
  titleDiv.classList.add(this.c("app-menu-item-title"));
@@ -2949,6 +3046,7 @@ class TeleBoxManager {
2949
3046
  collector,
2950
3047
  namespace = "telebox",
2951
3048
  readonly = false,
3049
+ forceMaximized = false,
2952
3050
  useBoxesStatus = false
2953
3051
  } = {}) {
2954
3052
  this.events = new EventEmitter();
@@ -2960,9 +3058,11 @@ class TeleBoxManager {
2960
3058
  this.boxes$ = createVal([]);
2961
3059
  this.topBox$ = this.boxes$.derive((boxes) => {
2962
3060
  if (boxes.length > 0) {
2963
- console.log("topBox===>topBox$===>000");
2964
3061
  let currentTopBox = void 0;
2965
3062
  const topBox = boxes.reduce((topBox2, box) => {
3063
+ if (box.forceTop) {
3064
+ return topBox2;
3065
+ }
2966
3066
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
2967
3067
  return topBox2;
2968
3068
  }
@@ -2972,7 +3072,6 @@ class TeleBoxManager {
2972
3072
  }
2973
3073
  return topBox2.zIndex > box.zIndex ? topBox2 : box;
2974
3074
  }, currentTopBox);
2975
- console.log("topBox===>topBox$===>end", topBox == null ? void 0 : topBox.id);
2976
3075
  return topBox;
2977
3076
  }
2978
3077
  return;
@@ -3019,6 +3118,14 @@ class TeleBoxManager {
3019
3118
  });
3020
3119
  const minimized$ = createVal(minimized);
3021
3120
  const maximized$ = createVal(maximized);
3121
+ const forceMaximized$ = createVal(forceMaximized);
3122
+ forceMaximized$.reaction((forceMaximized2, _, skipUpdate) => {
3123
+ var _a;
3124
+ this.boxes.forEach(
3125
+ (box) => box.setForceMaximized(forceMaximized2, skipUpdate)
3126
+ );
3127
+ (_a = this.maxTitleBar) == null ? void 0 : _a.setForceMaximized(forceMaximized2);
3128
+ });
3022
3129
  maximized$.reaction((maximized2, _, skipUpdate) => {
3023
3130
  this.boxes.forEach(
3024
3131
  (box) => box.setMaximized(maximized2, skipUpdate)
@@ -3155,21 +3262,28 @@ class TeleBoxManager {
3155
3262
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3156
3263
  const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
3157
3264
  if (maxNormalBoxZIndex > box.zIndex) {
3158
- this.setBox(box, {
3159
- zIndex: maxNormalBoxZIndex + 1
3160
- }, false);
3265
+ this.setBox(
3266
+ box,
3267
+ {
3268
+ zIndex: maxNormalBoxZIndex + 1
3269
+ },
3270
+ false
3271
+ );
3161
3272
  }
3162
3273
  } else if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3163
3274
  const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
3164
3275
  if (maxMaximizedBoxZIndex > box.zIndex) {
3165
- this.setBox(box, {
3166
- zIndex: maxMaximizedBoxZIndex + 1
3167
- }, false);
3276
+ this.setBox(
3277
+ box,
3278
+ {
3279
+ zIndex: maxMaximizedBoxZIndex + 1
3280
+ },
3281
+ false
3282
+ );
3168
3283
  }
3169
3284
  this.makeMaximizedTopBoxFocus();
3170
3285
  }
3171
3286
  }
3172
- console.log("checkFocusBox===>", box.id);
3173
3287
  this.focusBox(box);
3174
3288
  return;
3175
3289
  }
@@ -3193,6 +3307,7 @@ class TeleBoxManager {
3193
3307
  readonly: readonly$.value,
3194
3308
  namespace: this.namespace,
3195
3309
  state: state$.value,
3310
+ forceMaximized: forceMaximized$.value,
3196
3311
  boxes: this.boxes$.value,
3197
3312
  containerRect: containerRect$.value,
3198
3313
  getBoxesStatus: () => {
@@ -3201,6 +3316,9 @@ class TeleBoxManager {
3201
3316
  onEvent: (event) => {
3202
3317
  switch (event.type) {
3203
3318
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
3319
+ if (forceMaximized$.value && this.state === TELE_BOX_STATE.Maximized) {
3320
+ return;
3321
+ }
3204
3322
  if (this.hasBoxesStatus()) {
3205
3323
  let targetBox = this.maxTitleBar.focusedBox;
3206
3324
  if (!targetBox) {
@@ -3209,12 +3327,17 @@ class TeleBoxManager {
3209
3327
  if (targetBox == null ? void 0 : targetBox.id) {
3210
3328
  const box = this.getBox(targetBox.id);
3211
3329
  if (box) {
3212
- this.setBox(box, {
3213
- status: TELE_BOX_STATE.Normal,
3214
- zIndex: this.getMaxNormalBoxZIndex() + 1
3215
- }, false, () => {
3216
- this.makeMaximizedTopBoxFocus();
3217
- });
3330
+ this.setBox(
3331
+ box,
3332
+ {
3333
+ status: TELE_BOX_STATE.Normal,
3334
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3335
+ },
3336
+ false,
3337
+ () => {
3338
+ this.makeMaximizedTopBoxFocus();
3339
+ }
3340
+ );
3218
3341
  }
3219
3342
  }
3220
3343
  } else {
@@ -3236,10 +3359,14 @@ class TeleBoxManager {
3236
3359
  this.blurBox(box);
3237
3360
  isFocusChanged = true;
3238
3361
  }
3239
- this.setBox(box, {
3240
- status: TELE_BOX_STATE.Minimized,
3241
- zIndex: -1
3242
- }, false);
3362
+ this.setBox(
3363
+ box,
3364
+ {
3365
+ status: TELE_BOX_STATE.Minimized,
3366
+ zIndex: -1
3367
+ },
3368
+ false
3369
+ );
3243
3370
  if (isFocusChanged) {
3244
3371
  this.focusTopBox();
3245
3372
  } else {
@@ -3300,7 +3427,8 @@ class TeleBoxManager {
3300
3427
  readonly: readonly$,
3301
3428
  fence: fence$,
3302
3429
  minimized: minimized$,
3303
- maximized: maximized$
3430
+ maximized: maximized$,
3431
+ forceMaximized: forceMaximized$
3304
3432
  };
3305
3433
  i(this, valConfig);
3306
3434
  this._state$ = state$;
@@ -3315,6 +3443,21 @@ class TeleBoxManager {
3315
3443
  get topBox() {
3316
3444
  return this.topBox$.value;
3317
3445
  }
3446
+ get forceTopBoxes() {
3447
+ return this.boxes.find((box) => box.forceTop);
3448
+ }
3449
+ get maxForceTopBox() {
3450
+ return this.boxes.reduce((maxTopBox, box) => {
3451
+ var _a;
3452
+ if (box.forceTop && box.zIndex > ((_a = maxTopBox == null ? void 0 : maxTopBox.zIndex) != null ? _a : 0)) {
3453
+ return box;
3454
+ }
3455
+ return maxTopBox;
3456
+ }, void 0);
3457
+ }
3458
+ get forceNormalBoxes() {
3459
+ return this.boxes.find((box) => box.forceNormal);
3460
+ }
3318
3461
  get darkMode() {
3319
3462
  return this._darkMode$.value;
3320
3463
  }
@@ -3322,6 +3465,9 @@ class TeleBoxManager {
3322
3465
  return this._state$.value;
3323
3466
  }
3324
3467
  setState(state, skipUpdate = false) {
3468
+ if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
3469
+ return this;
3470
+ }
3325
3471
  switch (state) {
3326
3472
  case TELE_BOX_STATE.Maximized: {
3327
3473
  this.setMinimized(false, skipUpdate);
@@ -3346,7 +3492,11 @@ class TeleBoxManager {
3346
3492
  const oldBoxStatus = this.boxesStatus$.get(boxId);
3347
3493
  this.boxesStatus$.set(boxId, boxStatus);
3348
3494
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
3349
- this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
3495
+ this.setLastNotMinimizedBoxStatus(
3496
+ boxId,
3497
+ oldBoxStatus,
3498
+ skipUpdate
3499
+ );
3350
3500
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
3351
3501
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3352
3502
  }
@@ -3355,7 +3505,10 @@ class TeleBoxManager {
3355
3505
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3356
3506
  }
3357
3507
  if (!skipUpdate) {
3358
- this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
3508
+ this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, {
3509
+ id: boxId,
3510
+ boxStatus
3511
+ });
3359
3512
  }
3360
3513
  }
3361
3514
  getBoxStatus(boxId) {
@@ -3401,14 +3554,13 @@ class TeleBoxManager {
3401
3554
  var _a;
3402
3555
  const boxStatus = this.boxesStatus$.get(box.id);
3403
3556
  if (boxStatus) {
3404
- if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > ((_a = newTopBox == null ? void 0 : newTopBox.zIndex) != null ? _a : 0)) {
3557
+ if (boxStatus !== TELE_BOX_STATE.Minimized && !this.isForceTop(box) && box.zIndex > ((_a = newTopBox == null ? void 0 : newTopBox.zIndex) != null ? _a : 0)) {
3405
3558
  newTopBox = box;
3406
3559
  }
3407
3560
  box.setBoxStatus(boxStatus, skipUpdate);
3408
3561
  }
3409
3562
  });
3410
3563
  this.effectBoxStatusChange();
3411
- console.log("effectBoxesStatusTimerFunc===>newTopBox", newTopBox, curTopBox);
3412
3564
  if (newTopBox && curTopBox !== newTopBox) {
3413
3565
  this.topBox$.setValue(newTopBox);
3414
3566
  }
@@ -3417,12 +3569,14 @@ class TeleBoxManager {
3417
3569
  }
3418
3570
  }
3419
3571
  async effectBoxesStatusChange(skipUpdate = false) {
3420
- var _a, _b, _c, _d, _e, _f;
3572
+ var _a, _b;
3421
3573
  if (!this.useBoxesStatus) {
3422
3574
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3423
3575
  clearTimeout(this.effectBoxesStatusTimer.timer);
3424
3576
  if (this.effectBoxesStatusTimer.resolve) {
3425
- this.effectBoxesStatusTimer.resolve(!!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate));
3577
+ this.effectBoxesStatusTimer.resolve(
3578
+ !!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate)
3579
+ );
3426
3580
  }
3427
3581
  }
3428
3582
  this.effectBoxesStatusTimer = void 0;
@@ -3432,11 +3586,11 @@ class TeleBoxManager {
3432
3586
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3433
3587
  clearTimeout(this.effectBoxesStatusTimer.timer);
3434
3588
  if (this.effectBoxesStatusTimer.resolve) {
3435
- console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
3436
- this.effectBoxesStatusTimer.resolve(!!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate));
3589
+ this.effectBoxesStatusTimer.resolve(
3590
+ !!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate)
3591
+ );
3437
3592
  }
3438
3593
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3439
- console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
3440
3594
  } else {
3441
3595
  return;
3442
3596
  }
@@ -3452,17 +3606,15 @@ class TeleBoxManager {
3452
3606
  const _skipUpdate = await new Promise((resolve) => {
3453
3607
  this.effectBoxesStatusTimer.resolve = resolve;
3454
3608
  this.effectBoxesStatusTimer.timer = setTimeout(() => {
3455
- var _a2, _b2;
3456
3609
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3457
- console.log("effectBoxStatusTimerFunc===>000", skipUpdate, { id: (_a2 = this.topBox$.value) == null ? void 0 : _a2.id, zIndex: (_b2 = this.topBox$.value) == null ? void 0 : _b2.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3458
- this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3610
+ this.effectBoxesStatusTimer.resolve(
3611
+ this.effectBoxesStatusTimer.skipUpdate
3612
+ );
3459
3613
  }
3460
3614
  }, 100);
3461
3615
  });
3462
- console.log("effectBoxStatusTimerFunc===>000==>00", skipUpdate, { id: (_c = this.topBox$.value) == null ? void 0 : _c.id, zIndex: (_d = this.topBox$.value) == null ? void 0 : _d.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3463
3616
  this.effectBoxesStatusTimerFunc(_skipUpdate);
3464
3617
  this.effectBoxesStatusTimer = void 0;
3465
- console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, { id: (_e = this.topBox$.value) == null ? void 0 : _e.id, zIndex: (_f = this.topBox$.value) == null ? void 0 : _f.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3466
3618
  }
3467
3619
  }
3468
3620
  hasBoxesStatus() {
@@ -3475,13 +3627,18 @@ class TeleBoxManager {
3475
3627
  if (!this.useBoxesStatus) {
3476
3628
  return false;
3477
3629
  }
3478
- return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
3630
+ return this.boxes.some(
3631
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized
3632
+ );
3479
3633
  }
3480
3634
  getMinimizedBoxesStatus() {
3481
3635
  const minimizedBoxes = /* @__PURE__ */ new Map();
3482
3636
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3483
3637
  if (boxStatus === TELE_BOX_STATE.Minimized) {
3484
- minimizedBoxes.set(boxId, boxStatus);
3638
+ minimizedBoxes.set(
3639
+ boxId,
3640
+ boxStatus
3641
+ );
3485
3642
  }
3486
3643
  });
3487
3644
  return minimizedBoxes;
@@ -3499,7 +3656,10 @@ class TeleBoxManager {
3499
3656
  const maximizedBoxes = /* @__PURE__ */ new Map();
3500
3657
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3501
3658
  if (boxStatus === TELE_BOX_STATE.Maximized) {
3502
- maximizedBoxes.set(boxId, boxStatus);
3659
+ maximizedBoxes.set(
3660
+ boxId,
3661
+ boxStatus
3662
+ );
3503
3663
  }
3504
3664
  });
3505
3665
  return maximizedBoxes;
@@ -3518,12 +3678,18 @@ class TeleBoxManager {
3518
3678
  }
3519
3679
  setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
3520
3680
  if (lastNotMinimizedBoxStatus) {
3521
- this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
3681
+ this.lastNotMinimizedBoxesStatus$.set(
3682
+ boxId,
3683
+ lastNotMinimizedBoxStatus
3684
+ );
3522
3685
  } else {
3523
3686
  this.lastNotMinimizedBoxesStatus$.delete(boxId);
3524
3687
  }
3525
3688
  if (!skipUpdate) {
3526
- this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
3689
+ this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, {
3690
+ id: boxId,
3691
+ boxStatus: lastNotMinimizedBoxStatus
3692
+ });
3527
3693
  }
3528
3694
  }
3529
3695
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
@@ -3536,7 +3702,9 @@ class TeleBoxManager {
3536
3702
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3537
3703
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3538
3704
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3539
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate));
3705
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3706
+ !!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate)
3707
+ );
3540
3708
  }
3541
3709
  }
3542
3710
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3546,11 +3714,11 @@ class TeleBoxManager {
3546
3714
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3547
3715
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3548
3716
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3549
- console.log("effectLastNotMinimizedBoxStatusFunc===>1111", skipUpdate);
3550
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate));
3717
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3718
+ !!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate)
3719
+ );
3551
3720
  }
3552
3721
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3553
- console.log("effectLastNotMinimizedBoxStatusFunc===>2222", skipUpdate);
3554
3722
  } else {
3555
3723
  return;
3556
3724
  }
@@ -3565,24 +3733,25 @@ class TeleBoxManager {
3565
3733
  if (this.effectLastNotMinimizedBoxStatusTimer) {
3566
3734
  const _skipUpdate = await new Promise((resolve) => {
3567
3735
  this.effectLastNotMinimizedBoxStatusTimer.resolve = resolve;
3568
- this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(() => {
3569
- if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3570
- console.log("effectLastNotMinimizedBoxStatusTimer===>000", skipUpdate);
3571
- this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate);
3572
- }
3573
- }, 100);
3736
+ this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(
3737
+ () => {
3738
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3739
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3740
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate
3741
+ );
3742
+ }
3743
+ },
3744
+ 100
3745
+ );
3574
3746
  });
3575
- console.log("effectLastNotMinimizedBoxStatusFunc===>000==>00", skipUpdate, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex, lastNotMinimizedBoxStatus: b._lastNotMinimizedBoxStatus$.value })));
3576
3747
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3577
3748
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
3578
- console.log("effectLastNotMinimizedBoxStatusFunc===>000==>11", skipUpdate, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex, lastNotMinimizedBoxStatus: b._lastNotMinimizedBoxStatus$.value })));
3579
3749
  }
3580
3750
  }
3581
3751
  effectLastNotMinimizedBoxStatusFunc(skipUpdate = false) {
3582
3752
  if (!this.useBoxesStatus) {
3583
3753
  return;
3584
3754
  }
3585
- console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
3586
3755
  this.boxes.forEach((box) => {
3587
3756
  const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
3588
3757
  if (boxStatus) {
@@ -3598,7 +3767,7 @@ class TeleBoxManager {
3598
3767
  return this.getUnabledBoxesStatusZIndex();
3599
3768
  }
3600
3769
  return this.boxes.reduce((maxZIndex, box) => {
3601
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3770
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized && !this.isForceTop(box)) {
3602
3771
  return Math.max(maxZIndex, box.zIndex);
3603
3772
  }
3604
3773
  return maxZIndex;
@@ -3609,17 +3778,32 @@ class TeleBoxManager {
3609
3778
  return this.getUnabledBoxesStatusZIndex();
3610
3779
  }
3611
3780
  return this.boxes.reduce((maxZIndex, box) => {
3612
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3781
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceTop(box)) {
3613
3782
  return Math.max(maxZIndex, box.zIndex);
3614
3783
  }
3615
3784
  return maxZIndex;
3616
3785
  }, 299);
3617
3786
  }
3787
+ getMaxForceTopBoxZIndex() {
3788
+ if (!this.useBoxesStatus) {
3789
+ return this.getUnabledBoxesStatusZIndex();
3790
+ }
3791
+ return this.boxes.reduce((maxZIndex, box) => {
3792
+ if (box.boxStatus && this.isForceTop(box)) {
3793
+ return Math.max(maxZIndex, box.zIndex);
3794
+ }
3795
+ return maxZIndex;
3796
+ }, 699);
3797
+ }
3798
+ isForceNormal(box) {
3799
+ return box._forceNormal$.value;
3800
+ }
3801
+ isForceTop(box) {
3802
+ return box._forceTop$.value;
3803
+ }
3618
3804
  create(config = {}, smartPosition = true) {
3619
- var _a;
3620
- console.log("create===>", config, (_a = this.topBox) == null ? void 0 : _a.zIndex);
3621
3805
  const box = new TeleBox({
3622
- zIndex: this.getMaxNormalBoxZIndex() + 1,
3806
+ zIndex: config.forceTop ? this.getMaxForceTopBoxZIndex() + 1 : this.getMaxNormalBoxZIndex() + 1,
3623
3807
  ...smartPosition ? this.smartPosition(config) : config,
3624
3808
  darkMode: this.darkMode,
3625
3809
  prefersColorScheme: this.prefersColorScheme,
@@ -3629,15 +3813,20 @@ class TeleBoxManager {
3629
3813
  namespace: this.namespace,
3630
3814
  containerRect: this.containerRect,
3631
3815
  readonly: this.readonly,
3816
+ forceMaximized: this.forceMaximized,
3632
3817
  collectorRect: this.collectorRect
3633
3818
  });
3634
3819
  box.mount(this.root);
3635
3820
  this.boxes$.setValue([...this.boxes, box]);
3636
3821
  if (box.boxStatus && this.useBoxesStatus) {
3637
- this.setBox(box, {
3638
- status: box.boxStatus,
3639
- lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3640
- }, true);
3822
+ this.setBox(
3823
+ box,
3824
+ {
3825
+ status: box.boxStatus,
3826
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3827
+ },
3828
+ true
3829
+ );
3641
3830
  }
3642
3831
  if (box.focus) {
3643
3832
  this.focusBox(box);
@@ -3647,38 +3836,60 @@ class TeleBoxManager {
3647
3836
  }
3648
3837
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
3649
3838
  if (this.useBoxesStatus && box.boxStatus) {
3839
+ if (box._forceNormal$.value) {
3840
+ return;
3841
+ }
3650
3842
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
3651
- this.setBox(box.id, {
3652
- status: TELE_BOX_STATE.Normal,
3653
- zIndex: this.getMaxNormalBoxZIndex() + 1
3654
- }, false);
3843
+ this.setBox(
3844
+ box.id,
3845
+ {
3846
+ status: TELE_BOX_STATE.Normal,
3847
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3848
+ },
3849
+ false
3850
+ );
3655
3851
  } else {
3656
- [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3852
+ [...this.boxes].filter(
3853
+ (box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)
3854
+ ).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3657
3855
  if (box2.boxStatus === TELE_BOX_STATE.Normal) {
3658
- console.log("maximized===>", box2.id);
3659
- this.setBox(box2.id, {
3660
- status: TELE_BOX_STATE.Maximized,
3661
- zIndex: this.getMaxMaximizedBoxZIndex() + 1
3662
- }, false);
3856
+ this.setBox(
3857
+ box2.id,
3858
+ {
3859
+ status: TELE_BOX_STATE.Maximized,
3860
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
3861
+ },
3862
+ false
3863
+ );
3663
3864
  }
3664
3865
  });
3665
3866
  this.makeMaximizedTopBoxFocus();
3666
3867
  }
3667
3868
  } else {
3668
- this.setMaximized(!this.maximized);
3869
+ if (!(this.forceMaximized && this.maximized)) {
3870
+ this.setMaximized(!this.maximized);
3871
+ }
3669
3872
  }
3670
3873
  });
3671
3874
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
3672
3875
  if (box.boxStatus && this.useBoxesStatus) {
3876
+ if (box._forceNormal$.value) {
3877
+ return;
3878
+ }
3673
3879
  if (box.focus) {
3674
3880
  this.blurBox(box);
3675
3881
  }
3676
- this.setBox(box, {
3677
- status: TELE_BOX_STATE.Minimized,
3678
- zIndex: -1
3679
- }, false, () => {
3680
- this.focusTopBox();
3681
- });
3882
+ this.setBox(
3883
+ box,
3884
+ {
3885
+ status: TELE_BOX_STATE.Minimized,
3886
+ zIndex: -1
3887
+ },
3888
+ false,
3889
+ () => {
3890
+ this.focusTopBox();
3891
+ }
3892
+ );
3682
3893
  } else {
3683
3894
  this.setMinimized(true);
3684
3895
  }
@@ -3717,9 +3928,11 @@ class TeleBoxManager {
3717
3928
  });
3718
3929
  box._zIndex$.reaction((_, __, skipUpdate) => {
3719
3930
  if (this.boxes.length > 0) {
3720
- console.log("topBox===>_zIndex", this.boxes.map((box2) => ({ id: box2.id, zIndex: box2.zIndex, boxStatus: box2.boxStatus })));
3721
3931
  let currentTopBox = void 0;
3722
3932
  const topBox = this.boxes.reduce((topBox2, box2) => {
3933
+ if (this.isForceTop(box2)) {
3934
+ return topBox2;
3935
+ }
3723
3936
  if (box2.boxStatus && box2.boxStatus === TELE_BOX_STATE.Minimized) {
3724
3937
  return topBox2;
3725
3938
  }
@@ -3729,7 +3942,6 @@ class TeleBoxManager {
3729
3942
  }
3730
3943
  return topBox2.zIndex > box2.zIndex ? topBox2 : box2;
3731
3944
  }, currentTopBox);
3732
- console.log("topBox===>_zIndex===>end", topBox == null ? void 0 : topBox.id);
3733
3945
  this.topBox$.setValue(topBox);
3734
3946
  }
3735
3947
  if (!skipUpdate) {
@@ -3769,8 +3981,15 @@ class TeleBoxManager {
3769
3981
  box.setZIndex(zIndex, skipUpdate);
3770
3982
  }
3771
3983
  if (lastNotMinimizedBoxStatus) {
3772
- this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
3773
- box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
3984
+ this.setLastNotMinimizedBoxStatus(
3985
+ box.id,
3986
+ lastNotMinimizedBoxStatus,
3987
+ skipUpdate
3988
+ );
3989
+ box.setLastNotMinimizedBoxStatus(
3990
+ lastNotMinimizedBoxStatus,
3991
+ skipUpdate
3992
+ );
3774
3993
  }
3775
3994
  effectFunc && effectFunc();
3776
3995
  }
@@ -3785,12 +4004,16 @@ class TeleBoxManager {
3785
4004
  deletedBoxes.forEach((box2) => box2.destroy());
3786
4005
  if (box && this.useBoxesStatus) {
3787
4006
  this.setBoxStatus(box.id, void 0, skipUpdate);
3788
- this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
4007
+ this.setLastNotMinimizedBoxStatus(
4008
+ box.id,
4009
+ void 0,
4010
+ skipUpdate
4011
+ );
3789
4012
  this.effectBoxStatusChange();
3790
4013
  effectFunc && effectFunc();
3791
4014
  }
3792
4015
  if (!skipUpdate) {
3793
- if (this.boxes.length <= 0) {
4016
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3794
4017
  this.setMaximized(false);
3795
4018
  this.setMinimized(false);
3796
4019
  }
@@ -3813,7 +4036,7 @@ class TeleBoxManager {
3813
4036
  this.boxesStatus$.clear();
3814
4037
  this.lastNotMinimizedBoxesStatus$.clear();
3815
4038
  if (!skipUpdate) {
3816
- if (this.boxes.length <= 0) {
4039
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3817
4040
  this.setMaximized(false);
3818
4041
  this.setMinimized(false);
3819
4042
  }
@@ -3945,10 +4168,20 @@ class TeleBoxManager {
3945
4168
  box.mountFooter(config.footer);
3946
4169
  }
3947
4170
  if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
3948
- this.setBox(box, {
3949
- status: config.boxStatus,
3950
- lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
3951
- }, skipUpdate);
4171
+ this.setBox(
4172
+ box,
4173
+ {
4174
+ status: config.boxStatus,
4175
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4176
+ },
4177
+ skipUpdate
4178
+ );
4179
+ }
4180
+ if (config.forceTop != null) {
4181
+ box.setForceTop(config.forceTop, skipUpdate);
4182
+ }
4183
+ if (config.forceNormal != null) {
4184
+ box.setForceNormal(config.forceNormal, skipUpdate);
3952
4185
  }
3953
4186
  }
3954
4187
  smartPosition(config = {}) {
@@ -3956,28 +4189,54 @@ class TeleBoxManager {
3956
4189
  const { width = 0.5, height = 0.5 } = config;
3957
4190
  if (x == null) {
3958
4191
  let vx = 20;
3959
- if (this.topBox) {
4192
+ if (config.forceTop) {
4193
+ const forceTopBox = this.maxForceTopBox || this.topBox;
4194
+ if (forceTopBox) {
4195
+ vx = forceTopBox.intrinsicX * this.containerRect.width + 20;
4196
+ if (vx > this.containerRect.width - width * this.containerRect.width) {
4197
+ vx = 20;
4198
+ }
4199
+ }
4200
+ } else if (this.topBox) {
3960
4201
  vx = this.topBox.intrinsicX * this.containerRect.width + 20;
3961
4202
  if (vx > this.containerRect.width - width * this.containerRect.width) {
3962
4203
  vx = 20;
3963
4204
  }
3964
4205
  } else if (this.hasMinimizedBox()) {
3965
- vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
3966
- return Math.max(maxX, box.intrinsicX * this.containerRect.width + 20);
4206
+ vx = [...this.boxes].filter(
4207
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4208
+ ).reduce((maxX, box) => {
4209
+ return Math.max(
4210
+ maxX,
4211
+ box.intrinsicX * this.containerRect.width + 20
4212
+ );
3967
4213
  }, vx);
3968
4214
  }
3969
4215
  x = vx / this.containerRect.width;
3970
4216
  }
3971
4217
  if (y == null) {
3972
4218
  let vy = 20;
3973
- if (this.topBox) {
4219
+ if (config.forceTop) {
4220
+ const forceTopBox = this.maxForceTopBox || this.topBox;
4221
+ if (forceTopBox) {
4222
+ vy = forceTopBox.intrinsicY * this.containerRect.height + 20;
4223
+ if (vy > this.containerRect.height - height * this.containerRect.height) {
4224
+ vy = 20;
4225
+ }
4226
+ }
4227
+ } else if (this.topBox) {
3974
4228
  vy = this.topBox.intrinsicY * this.containerRect.height + 20;
3975
4229
  if (vy > this.containerRect.height - height * this.containerRect.height) {
3976
4230
  vy = 20;
3977
4231
  }
3978
4232
  } else if (this.hasMinimizedBox()) {
3979
- vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
3980
- return Math.max(maxY, box.intrinsicY * this.containerRect.height + 20);
4233
+ vy = [...this.boxes].filter(
4234
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4235
+ ).reduce((maxY, box) => {
4236
+ return Math.max(
4237
+ maxY,
4238
+ box.intrinsicY * this.containerRect.height + 20
4239
+ );
3981
4240
  }, vy);
3982
4241
  }
3983
4242
  y = vy / this.containerRect.height;
@@ -3998,12 +4257,14 @@ class TeleBoxManager {
3998
4257
  }
3999
4258
  let maximizedBox;
4000
4259
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
4001
- maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
4002
- if (!topBox) {
4003
- return currentBox;
4260
+ maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce(
4261
+ (topBox, currentBox) => {
4262
+ if (!topBox) {
4263
+ return currentBox;
4264
+ }
4265
+ return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4004
4266
  }
4005
- return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4006
- });
4267
+ );
4007
4268
  }
4008
4269
  return maximizedBox;
4009
4270
  }
@@ -4012,9 +4273,7 @@ class TeleBoxManager {
4012
4273
  return;
4013
4274
  }
4014
4275
  const maximizedBox = this.getMaximizedTopBox();
4015
- console.log("makeMaximizedTopBoxFocus===>", maximizedBox == null ? void 0 : maximizedBox.id);
4016
4276
  this.maxTitleBar.focusBox(maximizedBox);
4017
- console.log("makeMaximizedTopBoxFocus===>end", maximizedBox == null ? void 0 : maximizedBox.id);
4018
4277
  }
4019
4278
  getBoxIndex(boxOrID) {
4020
4279
  return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
@@ -4037,5 +4296,6 @@ class TeleBoxManager {
4037
4296
  return;
4038
4297
  }
4039
4298
  }
4299
+ TeleBoxManager.kind = "TeleBoxManager";
4040
4300
  export { DefaultTitleBar, TELE_BOX_COLOR_SCHEME, TELE_BOX_DELEGATE_EVENT, TELE_BOX_EVENT, TELE_BOX_MANAGER_EVENT, TELE_BOX_RESIZE_HANDLE, TELE_BOX_STATE, TeleBox, TeleBoxCollector, TeleBoxDragHandleType, TeleBoxManager };
4041
4301
  //# sourceMappingURL=telebox-insider.es.js.map