@netless/telebox-insider 0.3.0 → 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.
@@ -1243,7 +1243,8 @@ class DefaultTitleBar {
1243
1243
  state = TELE_BOX_STATE.Normal,
1244
1244
  boxStatus,
1245
1245
  forceTop = false,
1246
- forceNormal = false
1246
+ forceNormal = false,
1247
+ forceMaximized = false
1247
1248
  } = {}) {
1248
1249
  this.$btns = [];
1249
1250
  this.sideEffect = new o();
@@ -1267,7 +1268,7 @@ class DefaultTitleBar {
1267
1268
  const now = Date.now();
1268
1269
  if (now - this.lastTitleBarClick.timestamp <= 500) {
1269
1270
  if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
1270
- if (this.onEvent) {
1271
+ if (this.onEvent && !this.forceMaximized) {
1271
1272
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1272
1273
  }
1273
1274
  }
@@ -1299,7 +1300,7 @@ class DefaultTitleBar {
1299
1300
  } = ev.touches[0] || {};
1300
1301
  if (now - this.lastTitleBarTouch.timestamp <= 500) {
1301
1302
  if (Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 10) {
1302
- if (this.onEvent) {
1303
+ if (this.onEvent && !this.forceMaximized) {
1303
1304
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1304
1305
  }
1305
1306
  }
@@ -1319,24 +1320,33 @@ class DefaultTitleBar {
1319
1320
  this.boxStatus = boxStatus;
1320
1321
  this.forceTop = forceTop;
1321
1322
  this.forceNormal = forceNormal;
1323
+ this.forceMaximized = forceMaximized;
1322
1324
  this.buttons = buttons || (forceNormal ? [
1323
1325
  {
1324
1326
  type: TELE_BOX_DELEGATE_EVENT.Close,
1325
- iconClassName: this.wrapClassName("titlebar-icon-close")
1327
+ iconClassName: this.wrapClassName(
1328
+ "titlebar-icon-close"
1329
+ )
1326
1330
  }
1327
1331
  ] : [
1328
1332
  {
1329
1333
  type: TELE_BOX_DELEGATE_EVENT.Minimize,
1330
- iconClassName: this.wrapClassName("titlebar-icon-minimize")
1334
+ iconClassName: this.wrapClassName(
1335
+ "titlebar-icon-minimize"
1336
+ )
1331
1337
  },
1332
1338
  {
1333
1339
  type: TELE_BOX_DELEGATE_EVENT.Maximize,
1334
- iconClassName: this.wrapClassName("titlebar-icon-maximize"),
1340
+ iconClassName: this.wrapClassName(
1341
+ "titlebar-icon-maximize"
1342
+ ),
1335
1343
  isActive: (state2) => state2 === TELE_BOX_STATE.Maximized
1336
1344
  },
1337
1345
  {
1338
1346
  type: TELE_BOX_DELEGATE_EVENT.Close,
1339
- iconClassName: this.wrapClassName("titlebar-icon-close")
1347
+ iconClassName: this.wrapClassName(
1348
+ "titlebar-icon-close"
1349
+ )
1340
1350
  }
1341
1351
  ]);
1342
1352
  this.$dragArea = this.renderDragArea();
@@ -1381,6 +1391,20 @@ class DefaultTitleBar {
1381
1391
  this.readonly = readonly;
1382
1392
  }
1383
1393
  }
1394
+ setForceMaximized(forceMaximized) {
1395
+ this.forceMaximized = forceMaximized;
1396
+ this.$btns.forEach((button, index2) => {
1397
+ var _a;
1398
+ if (((_a = this.buttons[index2]) == null ? void 0 : _a.type) === TELE_BOX_DELEGATE_EVENT.Maximize) {
1399
+ button.disabled = forceMaximized;
1400
+ button.setAttribute("aria-disabled", String(forceMaximized));
1401
+ button.classList.toggle(
1402
+ this.wrapClassName("disabled"),
1403
+ forceMaximized
1404
+ );
1405
+ }
1406
+ });
1407
+ }
1384
1408
  render() {
1385
1409
  if (!this.$titleBar) {
1386
1410
  this.$titleBar = document.createElement("div");
@@ -1408,7 +1432,10 @@ class DefaultTitleBar {
1408
1432
  $btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
1409
1433
  $btn.dataset.teleTitleBarNoDblClick = "true";
1410
1434
  if (isActive) {
1411
- $btn.classList.toggle("is-active", isActive(this.boxStatus || this.state));
1435
+ $btn.classList.toggle(
1436
+ "is-active",
1437
+ isActive(this.boxStatus || this.state)
1438
+ );
1412
1439
  }
1413
1440
  this.$btns.push($btn);
1414
1441
  $buttonsContainer.appendChild($btn);
@@ -1428,6 +1455,9 @@ class DefaultTitleBar {
1428
1455
  if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
1429
1456
  preventEvent(ev);
1430
1457
  const btn = this.buttons[teleTitleBarBtnIndex];
1458
+ if (this.forceMaximized && btn.type === TELE_BOX_DELEGATE_EVENT.Maximize) {
1459
+ return;
1460
+ }
1431
1461
  if (this.onEvent) {
1432
1462
  this.onEvent({
1433
1463
  type: btn.type,
@@ -1439,6 +1469,7 @@ class DefaultTitleBar {
1439
1469
  );
1440
1470
  this.$titleBar.appendChild($titleArea);
1441
1471
  this.$titleBar.appendChild($buttonsContainer);
1472
+ this.setForceMaximized(Boolean(this.forceMaximized));
1442
1473
  }
1443
1474
  return this.$titleBar;
1444
1475
  }
@@ -1514,6 +1545,7 @@ class TeleBox {
1514
1545
  lastNotMinimizedBoxStatus,
1515
1546
  forceTop = false,
1516
1547
  forceNormal = false,
1548
+ forceMaximized = false,
1517
1549
  isDragContent = false
1518
1550
  } = {}) {
1519
1551
  this._renderSideEffect = new o();
@@ -1528,7 +1560,9 @@ class TeleBox {
1528
1560
  this.namespace = namespace;
1529
1561
  this.events = new EventEmitter();
1530
1562
  this._delegateEvents = new EventEmitter();
1531
- const boxStatus$ = createVal(boxStatus);
1563
+ const boxStatus$ = createVal(
1564
+ boxStatus
1565
+ );
1532
1566
  const lastNotMinimizedBoxStatus$ = createVal(lastNotMinimizedBoxStatus);
1533
1567
  const prefersColorScheme$ = createVal(
1534
1568
  prefersColorScheme
@@ -1588,9 +1622,13 @@ class TeleBox {
1588
1622
  }
1589
1623
  });
1590
1624
  const forceNormal$ = createVal(forceNormal);
1625
+ const forceMaximized$ = createVal(forceMaximized);
1591
1626
  forceNormal$.reaction((forceNormal2, _, skipUpdate) => {
1592
1627
  if (!skipUpdate) {
1593
- this.events.emit(TELE_BOX_EVENT.ForceNormal, forceNormal2 || false);
1628
+ this.events.emit(
1629
+ TELE_BOX_EVENT.ForceNormal,
1630
+ forceNormal2 || false
1631
+ );
1594
1632
  }
1595
1633
  });
1596
1634
  const isDragContent$ = createVal(isDragContent);
@@ -1773,6 +1811,7 @@ class TeleBox {
1773
1811
  boxStatus: boxStatus$.value,
1774
1812
  forceTop: forceTop$.value,
1775
1813
  forceNormal: forceNormal$.value,
1814
+ forceMaximized: forceMaximized$.value,
1776
1815
  onDragStart: (event) => {
1777
1816
  var _a;
1778
1817
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1783,7 +1822,7 @@ class TeleBox {
1783
1822
  } else {
1784
1823
  switch (event.type) {
1785
1824
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
1786
- if (!boxStatus$.value) {
1825
+ if (!boxStatus$.value && !(forceMaximized$.value && maximized$.value)) {
1787
1826
  maximized$.setValue(!maximized$.value);
1788
1827
  }
1789
1828
  break;
@@ -1812,6 +1851,9 @@ class TeleBox {
1812
1851
  readonly$.reaction((readonly2) => {
1813
1852
  this.titleBar.setReadonly(readonly2);
1814
1853
  });
1854
+ forceMaximized$.reaction((forceMaximized2) => {
1855
+ this.titleBar.setForceMaximized(forceMaximized2);
1856
+ });
1815
1857
  boxStatus$.reaction((boxStatus2) => {
1816
1858
  this.titleBar.setBoxStatus(boxStatus2);
1817
1859
  });
@@ -1839,6 +1881,7 @@ class TeleBox {
1839
1881
  $userStyles: $userStyles$,
1840
1882
  forceTop: forceTop$,
1841
1883
  forceNormal: forceNormal$,
1884
+ forceMaximized: forceMaximized$,
1842
1885
  isDragContent: isDragContent$
1843
1886
  };
1844
1887
  i(this, valConfig);
@@ -1900,21 +1943,33 @@ class TeleBox {
1900
1943
  setBoxStatus(boxStatus, skipUpdate = false) {
1901
1944
  if (boxStatus === TELE_BOX_STATE.Minimized) {
1902
1945
  if (this._boxStatus$.value && this._boxStatus$.value !== TELE_BOX_STATE.Minimized) {
1903
- this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1946
+ this.setLastNotMinimizedBoxStatus(
1947
+ this._boxStatus$.value,
1948
+ skipUpdate
1949
+ );
1904
1950
  }
1905
1951
  } else {
1906
1952
  this.setLastNotMinimizedBoxStatus(void 0, skipUpdate);
1907
1953
  }
1908
1954
  this._boxStatus$.setValue(boxStatus, skipUpdate);
1909
1955
  if (!skipUpdate) {
1910
- this.events.emit(TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1956
+ this.events.emit(TELE_BOX_EVENT.BoxStatus, {
1957
+ id: this.id,
1958
+ boxStatus
1959
+ });
1911
1960
  }
1912
1961
  return this;
1913
1962
  }
1914
1963
  setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1915
- this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1964
+ this._lastNotMinimizedBoxStatus$.setValue(
1965
+ lastNotMinimizedBoxStatus,
1966
+ skipUpdate
1967
+ );
1916
1968
  if (!skipUpdate) {
1917
- this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1969
+ this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, {
1970
+ id: this.id,
1971
+ lastNotMinimizedBoxStatus
1972
+ });
1918
1973
  }
1919
1974
  return this;
1920
1975
  }
@@ -2147,7 +2202,14 @@ class TeleBox {
2147
2202
  this._collectorRect$,
2148
2203
  this._boxStatus$
2149
2204
  ],
2150
- ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2205
+ ([
2206
+ coord,
2207
+ size,
2208
+ minimized,
2209
+ containerRect,
2210
+ collectorRect,
2211
+ boxStatus
2212
+ ]) => {
2151
2213
  const absoluteWidth = size.width * containerRect.width;
2152
2214
  const absoluteHeight = size.height * containerRect.height;
2153
2215
  return {
@@ -2986,6 +3048,7 @@ class TeleBoxManager {
2986
3048
  collector,
2987
3049
  namespace = "telebox",
2988
3050
  readonly = false,
3051
+ forceMaximized = false,
2989
3052
  useBoxesStatus = false
2990
3053
  } = {}) {
2991
3054
  this.events = new EventEmitter();
@@ -3057,6 +3120,14 @@ class TeleBoxManager {
3057
3120
  });
3058
3121
  const minimized$ = createVal(minimized);
3059
3122
  const maximized$ = createVal(maximized);
3123
+ const forceMaximized$ = createVal(forceMaximized);
3124
+ forceMaximized$.reaction((forceMaximized2, _, skipUpdate) => {
3125
+ var _a;
3126
+ this.boxes.forEach(
3127
+ (box) => box.setForceMaximized(forceMaximized2, skipUpdate)
3128
+ );
3129
+ (_a = this.maxTitleBar) == null ? void 0 : _a.setForceMaximized(forceMaximized2);
3130
+ });
3060
3131
  maximized$.reaction((maximized2, _, skipUpdate) => {
3061
3132
  this.boxes.forEach(
3062
3133
  (box) => box.setMaximized(maximized2, skipUpdate)
@@ -3193,16 +3264,24 @@ class TeleBoxManager {
3193
3264
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3194
3265
  const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
3195
3266
  if (maxNormalBoxZIndex > box.zIndex) {
3196
- this.setBox(box, {
3197
- zIndex: maxNormalBoxZIndex + 1
3198
- }, false);
3267
+ this.setBox(
3268
+ box,
3269
+ {
3270
+ zIndex: maxNormalBoxZIndex + 1
3271
+ },
3272
+ false
3273
+ );
3199
3274
  }
3200
3275
  } else if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3201
3276
  const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
3202
3277
  if (maxMaximizedBoxZIndex > box.zIndex) {
3203
- this.setBox(box, {
3204
- zIndex: maxMaximizedBoxZIndex + 1
3205
- }, false);
3278
+ this.setBox(
3279
+ box,
3280
+ {
3281
+ zIndex: maxMaximizedBoxZIndex + 1
3282
+ },
3283
+ false
3284
+ );
3206
3285
  }
3207
3286
  this.makeMaximizedTopBoxFocus();
3208
3287
  }
@@ -3230,6 +3309,7 @@ class TeleBoxManager {
3230
3309
  readonly: readonly$.value,
3231
3310
  namespace: this.namespace,
3232
3311
  state: state$.value,
3312
+ forceMaximized: forceMaximized$.value,
3233
3313
  boxes: this.boxes$.value,
3234
3314
  containerRect: containerRect$.value,
3235
3315
  getBoxesStatus: () => {
@@ -3238,6 +3318,9 @@ class TeleBoxManager {
3238
3318
  onEvent: (event) => {
3239
3319
  switch (event.type) {
3240
3320
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
3321
+ if (forceMaximized$.value && this.state === TELE_BOX_STATE.Maximized) {
3322
+ return;
3323
+ }
3241
3324
  if (this.hasBoxesStatus()) {
3242
3325
  let targetBox = this.maxTitleBar.focusedBox;
3243
3326
  if (!targetBox) {
@@ -3246,12 +3329,17 @@ class TeleBoxManager {
3246
3329
  if (targetBox == null ? void 0 : targetBox.id) {
3247
3330
  const box = this.getBox(targetBox.id);
3248
3331
  if (box) {
3249
- this.setBox(box, {
3250
- status: TELE_BOX_STATE.Normal,
3251
- zIndex: this.getMaxNormalBoxZIndex() + 1
3252
- }, false, () => {
3253
- this.makeMaximizedTopBoxFocus();
3254
- });
3332
+ this.setBox(
3333
+ box,
3334
+ {
3335
+ status: TELE_BOX_STATE.Normal,
3336
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3337
+ },
3338
+ false,
3339
+ () => {
3340
+ this.makeMaximizedTopBoxFocus();
3341
+ }
3342
+ );
3255
3343
  }
3256
3344
  }
3257
3345
  } else {
@@ -3273,10 +3361,14 @@ class TeleBoxManager {
3273
3361
  this.blurBox(box);
3274
3362
  isFocusChanged = true;
3275
3363
  }
3276
- this.setBox(box, {
3277
- status: TELE_BOX_STATE.Minimized,
3278
- zIndex: -1
3279
- }, false);
3364
+ this.setBox(
3365
+ box,
3366
+ {
3367
+ status: TELE_BOX_STATE.Minimized,
3368
+ zIndex: -1
3369
+ },
3370
+ false
3371
+ );
3280
3372
  if (isFocusChanged) {
3281
3373
  this.focusTopBox();
3282
3374
  } else {
@@ -3337,7 +3429,8 @@ class TeleBoxManager {
3337
3429
  readonly: readonly$,
3338
3430
  fence: fence$,
3339
3431
  minimized: minimized$,
3340
- maximized: maximized$
3432
+ maximized: maximized$,
3433
+ forceMaximized: forceMaximized$
3341
3434
  };
3342
3435
  i(this, valConfig);
3343
3436
  this._state$ = state$;
@@ -3374,6 +3467,9 @@ class TeleBoxManager {
3374
3467
  return this._state$.value;
3375
3468
  }
3376
3469
  setState(state, skipUpdate = false) {
3470
+ if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
3471
+ return this;
3472
+ }
3377
3473
  switch (state) {
3378
3474
  case TELE_BOX_STATE.Maximized: {
3379
3475
  this.setMinimized(false, skipUpdate);
@@ -3398,7 +3494,11 @@ class TeleBoxManager {
3398
3494
  const oldBoxStatus = this.boxesStatus$.get(boxId);
3399
3495
  this.boxesStatus$.set(boxId, boxStatus);
3400
3496
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
3401
- this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
3497
+ this.setLastNotMinimizedBoxStatus(
3498
+ boxId,
3499
+ oldBoxStatus,
3500
+ skipUpdate
3501
+ );
3402
3502
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
3403
3503
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3404
3504
  }
@@ -3407,7 +3507,10 @@ class TeleBoxManager {
3407
3507
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3408
3508
  }
3409
3509
  if (!skipUpdate) {
3410
- this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
3510
+ this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, {
3511
+ id: boxId,
3512
+ boxStatus
3513
+ });
3411
3514
  }
3412
3515
  }
3413
3516
  getBoxStatus(boxId) {
@@ -3473,7 +3576,9 @@ class TeleBoxManager {
3473
3576
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3474
3577
  clearTimeout(this.effectBoxesStatusTimer.timer);
3475
3578
  if (this.effectBoxesStatusTimer.resolve) {
3476
- this.effectBoxesStatusTimer.resolve(!!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate));
3579
+ this.effectBoxesStatusTimer.resolve(
3580
+ !!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate)
3581
+ );
3477
3582
  }
3478
3583
  }
3479
3584
  this.effectBoxesStatusTimer = void 0;
@@ -3483,7 +3588,9 @@ class TeleBoxManager {
3483
3588
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3484
3589
  clearTimeout(this.effectBoxesStatusTimer.timer);
3485
3590
  if (this.effectBoxesStatusTimer.resolve) {
3486
- this.effectBoxesStatusTimer.resolve(!!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate));
3591
+ this.effectBoxesStatusTimer.resolve(
3592
+ !!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate)
3593
+ );
3487
3594
  }
3488
3595
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3489
3596
  } else {
@@ -3502,7 +3609,9 @@ class TeleBoxManager {
3502
3609
  this.effectBoxesStatusTimer.resolve = resolve;
3503
3610
  this.effectBoxesStatusTimer.timer = setTimeout(() => {
3504
3611
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3505
- this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3612
+ this.effectBoxesStatusTimer.resolve(
3613
+ this.effectBoxesStatusTimer.skipUpdate
3614
+ );
3506
3615
  }
3507
3616
  }, 100);
3508
3617
  });
@@ -3520,13 +3629,18 @@ class TeleBoxManager {
3520
3629
  if (!this.useBoxesStatus) {
3521
3630
  return false;
3522
3631
  }
3523
- return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
3632
+ return this.boxes.some(
3633
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized
3634
+ );
3524
3635
  }
3525
3636
  getMinimizedBoxesStatus() {
3526
3637
  const minimizedBoxes = /* @__PURE__ */ new Map();
3527
3638
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3528
3639
  if (boxStatus === TELE_BOX_STATE.Minimized) {
3529
- minimizedBoxes.set(boxId, boxStatus);
3640
+ minimizedBoxes.set(
3641
+ boxId,
3642
+ boxStatus
3643
+ );
3530
3644
  }
3531
3645
  });
3532
3646
  return minimizedBoxes;
@@ -3544,7 +3658,10 @@ class TeleBoxManager {
3544
3658
  const maximizedBoxes = /* @__PURE__ */ new Map();
3545
3659
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3546
3660
  if (boxStatus === TELE_BOX_STATE.Maximized) {
3547
- maximizedBoxes.set(boxId, boxStatus);
3661
+ maximizedBoxes.set(
3662
+ boxId,
3663
+ boxStatus
3664
+ );
3548
3665
  }
3549
3666
  });
3550
3667
  return maximizedBoxes;
@@ -3563,12 +3680,18 @@ class TeleBoxManager {
3563
3680
  }
3564
3681
  setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
3565
3682
  if (lastNotMinimizedBoxStatus) {
3566
- this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
3683
+ this.lastNotMinimizedBoxesStatus$.set(
3684
+ boxId,
3685
+ lastNotMinimizedBoxStatus
3686
+ );
3567
3687
  } else {
3568
3688
  this.lastNotMinimizedBoxesStatus$.delete(boxId);
3569
3689
  }
3570
3690
  if (!skipUpdate) {
3571
- this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
3691
+ this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, {
3692
+ id: boxId,
3693
+ boxStatus: lastNotMinimizedBoxStatus
3694
+ });
3572
3695
  }
3573
3696
  }
3574
3697
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
@@ -3581,7 +3704,9 @@ class TeleBoxManager {
3581
3704
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3582
3705
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3583
3706
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3584
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate));
3707
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3708
+ !!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate)
3709
+ );
3585
3710
  }
3586
3711
  }
3587
3712
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3591,7 +3716,9 @@ class TeleBoxManager {
3591
3716
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3592
3717
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3593
3718
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3594
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate));
3719
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3720
+ !!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate)
3721
+ );
3595
3722
  }
3596
3723
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3597
3724
  } else {
@@ -3608,11 +3735,16 @@ class TeleBoxManager {
3608
3735
  if (this.effectLastNotMinimizedBoxStatusTimer) {
3609
3736
  const _skipUpdate = await new Promise((resolve) => {
3610
3737
  this.effectLastNotMinimizedBoxStatusTimer.resolve = resolve;
3611
- this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(() => {
3612
- if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3613
- this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate);
3614
- }
3615
- }, 100);
3738
+ this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(
3739
+ () => {
3740
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3741
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3742
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate
3743
+ );
3744
+ }
3745
+ },
3746
+ 100
3747
+ );
3616
3748
  });
3617
3749
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3618
3750
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3683,15 +3815,20 @@ class TeleBoxManager {
3683
3815
  namespace: this.namespace,
3684
3816
  containerRect: this.containerRect,
3685
3817
  readonly: this.readonly,
3818
+ forceMaximized: this.forceMaximized,
3686
3819
  collectorRect: this.collectorRect
3687
3820
  });
3688
3821
  box.mount(this.root);
3689
3822
  this.boxes$.setValue([...this.boxes, box]);
3690
3823
  if (box.boxStatus && this.useBoxesStatus) {
3691
- this.setBox(box, {
3692
- status: box.boxStatus,
3693
- lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3694
- }, true);
3824
+ this.setBox(
3825
+ box,
3826
+ {
3827
+ status: box.boxStatus,
3828
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3829
+ },
3830
+ true
3831
+ );
3695
3832
  }
3696
3833
  if (box.focus) {
3697
3834
  this.focusBox(box);
@@ -3705,23 +3842,35 @@ class TeleBoxManager {
3705
3842
  return;
3706
3843
  }
3707
3844
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
3708
- this.setBox(box.id, {
3709
- status: TELE_BOX_STATE.Normal,
3710
- zIndex: this.getMaxNormalBoxZIndex() + 1
3711
- }, false);
3845
+ this.setBox(
3846
+ box.id,
3847
+ {
3848
+ status: TELE_BOX_STATE.Normal,
3849
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3850
+ },
3851
+ false
3852
+ );
3712
3853
  } else {
3713
- [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3854
+ [...this.boxes].filter(
3855
+ (box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)
3856
+ ).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3714
3857
  if (box2.boxStatus === TELE_BOX_STATE.Normal) {
3715
- this.setBox(box2.id, {
3716
- status: TELE_BOX_STATE.Maximized,
3717
- zIndex: this.getMaxMaximizedBoxZIndex() + 1
3718
- }, false);
3858
+ this.setBox(
3859
+ box2.id,
3860
+ {
3861
+ status: TELE_BOX_STATE.Maximized,
3862
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
3863
+ },
3864
+ false
3865
+ );
3719
3866
  }
3720
3867
  });
3721
3868
  this.makeMaximizedTopBoxFocus();
3722
3869
  }
3723
3870
  } else {
3724
- this.setMaximized(!this.maximized);
3871
+ if (!(this.forceMaximized && this.maximized)) {
3872
+ this.setMaximized(!this.maximized);
3873
+ }
3725
3874
  }
3726
3875
  });
3727
3876
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
@@ -3732,12 +3881,17 @@ class TeleBoxManager {
3732
3881
  if (box.focus) {
3733
3882
  this.blurBox(box);
3734
3883
  }
3735
- this.setBox(box, {
3736
- status: TELE_BOX_STATE.Minimized,
3737
- zIndex: -1
3738
- }, false, () => {
3739
- this.focusTopBox();
3740
- });
3884
+ this.setBox(
3885
+ box,
3886
+ {
3887
+ status: TELE_BOX_STATE.Minimized,
3888
+ zIndex: -1
3889
+ },
3890
+ false,
3891
+ () => {
3892
+ this.focusTopBox();
3893
+ }
3894
+ );
3741
3895
  } else {
3742
3896
  this.setMinimized(true);
3743
3897
  }
@@ -3829,8 +3983,15 @@ class TeleBoxManager {
3829
3983
  box.setZIndex(zIndex, skipUpdate);
3830
3984
  }
3831
3985
  if (lastNotMinimizedBoxStatus) {
3832
- this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
3833
- box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
3986
+ this.setLastNotMinimizedBoxStatus(
3987
+ box.id,
3988
+ lastNotMinimizedBoxStatus,
3989
+ skipUpdate
3990
+ );
3991
+ box.setLastNotMinimizedBoxStatus(
3992
+ lastNotMinimizedBoxStatus,
3993
+ skipUpdate
3994
+ );
3834
3995
  }
3835
3996
  effectFunc && effectFunc();
3836
3997
  }
@@ -3845,12 +4006,16 @@ class TeleBoxManager {
3845
4006
  deletedBoxes.forEach((box2) => box2.destroy());
3846
4007
  if (box && this.useBoxesStatus) {
3847
4008
  this.setBoxStatus(box.id, void 0, skipUpdate);
3848
- this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
4009
+ this.setLastNotMinimizedBoxStatus(
4010
+ box.id,
4011
+ void 0,
4012
+ skipUpdate
4013
+ );
3849
4014
  this.effectBoxStatusChange();
3850
4015
  effectFunc && effectFunc();
3851
4016
  }
3852
4017
  if (!skipUpdate) {
3853
- if (this.boxes.length <= 0) {
4018
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3854
4019
  this.setMaximized(false);
3855
4020
  this.setMinimized(false);
3856
4021
  }
@@ -3873,7 +4038,7 @@ class TeleBoxManager {
3873
4038
  this.boxesStatus$.clear();
3874
4039
  this.lastNotMinimizedBoxesStatus$.clear();
3875
4040
  if (!skipUpdate) {
3876
- if (this.boxes.length <= 0) {
4041
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3877
4042
  this.setMaximized(false);
3878
4043
  this.setMinimized(false);
3879
4044
  }
@@ -4005,10 +4170,14 @@ class TeleBoxManager {
4005
4170
  box.mountFooter(config.footer);
4006
4171
  }
4007
4172
  if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
4008
- this.setBox(box, {
4009
- status: config.boxStatus,
4010
- lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4011
- }, skipUpdate);
4173
+ this.setBox(
4174
+ box,
4175
+ {
4176
+ status: config.boxStatus,
4177
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4178
+ },
4179
+ skipUpdate
4180
+ );
4012
4181
  }
4013
4182
  if (config.forceTop != null) {
4014
4183
  box.setForceTop(config.forceTop, skipUpdate);
@@ -4036,8 +4205,13 @@ class TeleBoxManager {
4036
4205
  vx = 20;
4037
4206
  }
4038
4207
  } else if (this.hasMinimizedBox()) {
4039
- vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
4040
- return Math.max(maxX, box.intrinsicX * this.containerRect.width + 20);
4208
+ vx = [...this.boxes].filter(
4209
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4210
+ ).reduce((maxX, box) => {
4211
+ return Math.max(
4212
+ maxX,
4213
+ box.intrinsicX * this.containerRect.width + 20
4214
+ );
4041
4215
  }, vx);
4042
4216
  }
4043
4217
  x = vx / this.containerRect.width;
@@ -4058,8 +4232,13 @@ class TeleBoxManager {
4058
4232
  vy = 20;
4059
4233
  }
4060
4234
  } else if (this.hasMinimizedBox()) {
4061
- vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
4062
- return Math.max(maxY, box.intrinsicY * this.containerRect.height + 20);
4235
+ vy = [...this.boxes].filter(
4236
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4237
+ ).reduce((maxY, box) => {
4238
+ return Math.max(
4239
+ maxY,
4240
+ box.intrinsicY * this.containerRect.height + 20
4241
+ );
4063
4242
  }, vy);
4064
4243
  }
4065
4244
  y = vy / this.containerRect.height;
@@ -4080,12 +4259,14 @@ class TeleBoxManager {
4080
4259
  }
4081
4260
  let maximizedBox;
4082
4261
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
4083
- maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
4084
- if (!topBox) {
4085
- return currentBox;
4262
+ maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce(
4263
+ (topBox, currentBox) => {
4264
+ if (!topBox) {
4265
+ return currentBox;
4266
+ }
4267
+ return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4086
4268
  }
4087
- return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4088
- });
4269
+ );
4089
4270
  }
4090
4271
  return maximizedBox;
4091
4272
  }