@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.
@@ -1241,7 +1241,8 @@ class DefaultTitleBar {
1241
1241
  state = TELE_BOX_STATE.Normal,
1242
1242
  boxStatus,
1243
1243
  forceTop = false,
1244
- forceNormal = false
1244
+ forceNormal = false,
1245
+ forceMaximized = false
1245
1246
  } = {}) {
1246
1247
  this.$btns = [];
1247
1248
  this.sideEffect = new o();
@@ -1265,7 +1266,7 @@ class DefaultTitleBar {
1265
1266
  const now = Date.now();
1266
1267
  if (now - this.lastTitleBarClick.timestamp <= 500) {
1267
1268
  if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
1268
- if (this.onEvent) {
1269
+ if (this.onEvent && !this.forceMaximized) {
1269
1270
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1270
1271
  }
1271
1272
  }
@@ -1297,7 +1298,7 @@ class DefaultTitleBar {
1297
1298
  } = ev.touches[0] || {};
1298
1299
  if (now - this.lastTitleBarTouch.timestamp <= 500) {
1299
1300
  if (Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 10) {
1300
- if (this.onEvent) {
1301
+ if (this.onEvent && !this.forceMaximized) {
1301
1302
  this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1302
1303
  }
1303
1304
  }
@@ -1317,24 +1318,33 @@ class DefaultTitleBar {
1317
1318
  this.boxStatus = boxStatus;
1318
1319
  this.forceTop = forceTop;
1319
1320
  this.forceNormal = forceNormal;
1321
+ this.forceMaximized = forceMaximized;
1320
1322
  this.buttons = buttons || (forceNormal ? [
1321
1323
  {
1322
1324
  type: TELE_BOX_DELEGATE_EVENT.Close,
1323
- iconClassName: this.wrapClassName("titlebar-icon-close")
1325
+ iconClassName: this.wrapClassName(
1326
+ "titlebar-icon-close"
1327
+ )
1324
1328
  }
1325
1329
  ] : [
1326
1330
  {
1327
1331
  type: TELE_BOX_DELEGATE_EVENT.Minimize,
1328
- iconClassName: this.wrapClassName("titlebar-icon-minimize")
1332
+ iconClassName: this.wrapClassName(
1333
+ "titlebar-icon-minimize"
1334
+ )
1329
1335
  },
1330
1336
  {
1331
1337
  type: TELE_BOX_DELEGATE_EVENT.Maximize,
1332
- iconClassName: this.wrapClassName("titlebar-icon-maximize"),
1338
+ iconClassName: this.wrapClassName(
1339
+ "titlebar-icon-maximize"
1340
+ ),
1333
1341
  isActive: (state2) => state2 === TELE_BOX_STATE.Maximized
1334
1342
  },
1335
1343
  {
1336
1344
  type: TELE_BOX_DELEGATE_EVENT.Close,
1337
- iconClassName: this.wrapClassName("titlebar-icon-close")
1345
+ iconClassName: this.wrapClassName(
1346
+ "titlebar-icon-close"
1347
+ )
1338
1348
  }
1339
1349
  ]);
1340
1350
  this.$dragArea = this.renderDragArea();
@@ -1379,6 +1389,20 @@ class DefaultTitleBar {
1379
1389
  this.readonly = readonly;
1380
1390
  }
1381
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
+ }
1382
1406
  render() {
1383
1407
  if (!this.$titleBar) {
1384
1408
  this.$titleBar = document.createElement("div");
@@ -1406,7 +1430,10 @@ class DefaultTitleBar {
1406
1430
  $btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
1407
1431
  $btn.dataset.teleTitleBarNoDblClick = "true";
1408
1432
  if (isActive) {
1409
- $btn.classList.toggle("is-active", isActive(this.boxStatus || this.state));
1433
+ $btn.classList.toggle(
1434
+ "is-active",
1435
+ isActive(this.boxStatus || this.state)
1436
+ );
1410
1437
  }
1411
1438
  this.$btns.push($btn);
1412
1439
  $buttonsContainer.appendChild($btn);
@@ -1426,6 +1453,9 @@ class DefaultTitleBar {
1426
1453
  if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
1427
1454
  preventEvent(ev);
1428
1455
  const btn = this.buttons[teleTitleBarBtnIndex];
1456
+ if (this.forceMaximized && btn.type === TELE_BOX_DELEGATE_EVENT.Maximize) {
1457
+ return;
1458
+ }
1429
1459
  if (this.onEvent) {
1430
1460
  this.onEvent({
1431
1461
  type: btn.type,
@@ -1437,6 +1467,7 @@ class DefaultTitleBar {
1437
1467
  );
1438
1468
  this.$titleBar.appendChild($titleArea);
1439
1469
  this.$titleBar.appendChild($buttonsContainer);
1470
+ this.setForceMaximized(Boolean(this.forceMaximized));
1440
1471
  }
1441
1472
  return this.$titleBar;
1442
1473
  }
@@ -1512,6 +1543,7 @@ class TeleBox {
1512
1543
  lastNotMinimizedBoxStatus,
1513
1544
  forceTop = false,
1514
1545
  forceNormal = false,
1546
+ forceMaximized = false,
1515
1547
  isDragContent = false
1516
1548
  } = {}) {
1517
1549
  this._renderSideEffect = new o();
@@ -1526,7 +1558,9 @@ class TeleBox {
1526
1558
  this.namespace = namespace;
1527
1559
  this.events = new EventEmitter();
1528
1560
  this._delegateEvents = new EventEmitter();
1529
- const boxStatus$ = createVal(boxStatus);
1561
+ const boxStatus$ = createVal(
1562
+ boxStatus
1563
+ );
1530
1564
  const lastNotMinimizedBoxStatus$ = createVal(lastNotMinimizedBoxStatus);
1531
1565
  const prefersColorScheme$ = createVal(
1532
1566
  prefersColorScheme
@@ -1586,9 +1620,13 @@ class TeleBox {
1586
1620
  }
1587
1621
  });
1588
1622
  const forceNormal$ = createVal(forceNormal);
1623
+ const forceMaximized$ = createVal(forceMaximized);
1589
1624
  forceNormal$.reaction((forceNormal2, _, skipUpdate) => {
1590
1625
  if (!skipUpdate) {
1591
- this.events.emit(TELE_BOX_EVENT.ForceNormal, forceNormal2 || false);
1626
+ this.events.emit(
1627
+ TELE_BOX_EVENT.ForceNormal,
1628
+ forceNormal2 || false
1629
+ );
1592
1630
  }
1593
1631
  });
1594
1632
  const isDragContent$ = createVal(isDragContent);
@@ -1771,6 +1809,7 @@ class TeleBox {
1771
1809
  boxStatus: boxStatus$.value,
1772
1810
  forceTop: forceTop$.value,
1773
1811
  forceNormal: forceNormal$.value,
1812
+ forceMaximized: forceMaximized$.value,
1774
1813
  onDragStart: (event) => {
1775
1814
  var _a;
1776
1815
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1781,7 +1820,7 @@ class TeleBox {
1781
1820
  } else {
1782
1821
  switch (event.type) {
1783
1822
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
1784
- if (!boxStatus$.value) {
1823
+ if (!boxStatus$.value && !(forceMaximized$.value && maximized$.value)) {
1785
1824
  maximized$.setValue(!maximized$.value);
1786
1825
  }
1787
1826
  break;
@@ -1810,6 +1849,9 @@ class TeleBox {
1810
1849
  readonly$.reaction((readonly2) => {
1811
1850
  this.titleBar.setReadonly(readonly2);
1812
1851
  });
1852
+ forceMaximized$.reaction((forceMaximized2) => {
1853
+ this.titleBar.setForceMaximized(forceMaximized2);
1854
+ });
1813
1855
  boxStatus$.reaction((boxStatus2) => {
1814
1856
  this.titleBar.setBoxStatus(boxStatus2);
1815
1857
  });
@@ -1837,6 +1879,7 @@ class TeleBox {
1837
1879
  $userStyles: $userStyles$,
1838
1880
  forceTop: forceTop$,
1839
1881
  forceNormal: forceNormal$,
1882
+ forceMaximized: forceMaximized$,
1840
1883
  isDragContent: isDragContent$
1841
1884
  };
1842
1885
  i(this, valConfig);
@@ -1898,21 +1941,33 @@ class TeleBox {
1898
1941
  setBoxStatus(boxStatus, skipUpdate = false) {
1899
1942
  if (boxStatus === TELE_BOX_STATE.Minimized) {
1900
1943
  if (this._boxStatus$.value && this._boxStatus$.value !== TELE_BOX_STATE.Minimized) {
1901
- this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1944
+ this.setLastNotMinimizedBoxStatus(
1945
+ this._boxStatus$.value,
1946
+ skipUpdate
1947
+ );
1902
1948
  }
1903
1949
  } else {
1904
1950
  this.setLastNotMinimizedBoxStatus(void 0, skipUpdate);
1905
1951
  }
1906
1952
  this._boxStatus$.setValue(boxStatus, skipUpdate);
1907
1953
  if (!skipUpdate) {
1908
- 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
+ });
1909
1958
  }
1910
1959
  return this;
1911
1960
  }
1912
1961
  setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1913
- this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1962
+ this._lastNotMinimizedBoxStatus$.setValue(
1963
+ lastNotMinimizedBoxStatus,
1964
+ skipUpdate
1965
+ );
1914
1966
  if (!skipUpdate) {
1915
- 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
+ });
1916
1971
  }
1917
1972
  return this;
1918
1973
  }
@@ -2145,7 +2200,14 @@ class TeleBox {
2145
2200
  this._collectorRect$,
2146
2201
  this._boxStatus$
2147
2202
  ],
2148
- ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2203
+ ([
2204
+ coord,
2205
+ size,
2206
+ minimized,
2207
+ containerRect,
2208
+ collectorRect,
2209
+ boxStatus
2210
+ ]) => {
2149
2211
  const absoluteWidth = size.width * containerRect.width;
2150
2212
  const absoluteHeight = size.height * containerRect.height;
2151
2213
  return {
@@ -2984,6 +3046,7 @@ class TeleBoxManager {
2984
3046
  collector,
2985
3047
  namespace = "telebox",
2986
3048
  readonly = false,
3049
+ forceMaximized = false,
2987
3050
  useBoxesStatus = false
2988
3051
  } = {}) {
2989
3052
  this.events = new EventEmitter();
@@ -3055,6 +3118,14 @@ class TeleBoxManager {
3055
3118
  });
3056
3119
  const minimized$ = createVal(minimized);
3057
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
+ });
3058
3129
  maximized$.reaction((maximized2, _, skipUpdate) => {
3059
3130
  this.boxes.forEach(
3060
3131
  (box) => box.setMaximized(maximized2, skipUpdate)
@@ -3191,16 +3262,24 @@ class TeleBoxManager {
3191
3262
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3192
3263
  const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
3193
3264
  if (maxNormalBoxZIndex > box.zIndex) {
3194
- this.setBox(box, {
3195
- zIndex: maxNormalBoxZIndex + 1
3196
- }, false);
3265
+ this.setBox(
3266
+ box,
3267
+ {
3268
+ zIndex: maxNormalBoxZIndex + 1
3269
+ },
3270
+ false
3271
+ );
3197
3272
  }
3198
3273
  } else if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3199
3274
  const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
3200
3275
  if (maxMaximizedBoxZIndex > box.zIndex) {
3201
- this.setBox(box, {
3202
- zIndex: maxMaximizedBoxZIndex + 1
3203
- }, false);
3276
+ this.setBox(
3277
+ box,
3278
+ {
3279
+ zIndex: maxMaximizedBoxZIndex + 1
3280
+ },
3281
+ false
3282
+ );
3204
3283
  }
3205
3284
  this.makeMaximizedTopBoxFocus();
3206
3285
  }
@@ -3228,6 +3307,7 @@ class TeleBoxManager {
3228
3307
  readonly: readonly$.value,
3229
3308
  namespace: this.namespace,
3230
3309
  state: state$.value,
3310
+ forceMaximized: forceMaximized$.value,
3231
3311
  boxes: this.boxes$.value,
3232
3312
  containerRect: containerRect$.value,
3233
3313
  getBoxesStatus: () => {
@@ -3236,6 +3316,9 @@ class TeleBoxManager {
3236
3316
  onEvent: (event) => {
3237
3317
  switch (event.type) {
3238
3318
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
3319
+ if (forceMaximized$.value && this.state === TELE_BOX_STATE.Maximized) {
3320
+ return;
3321
+ }
3239
3322
  if (this.hasBoxesStatus()) {
3240
3323
  let targetBox = this.maxTitleBar.focusedBox;
3241
3324
  if (!targetBox) {
@@ -3244,12 +3327,17 @@ class TeleBoxManager {
3244
3327
  if (targetBox == null ? void 0 : targetBox.id) {
3245
3328
  const box = this.getBox(targetBox.id);
3246
3329
  if (box) {
3247
- this.setBox(box, {
3248
- status: TELE_BOX_STATE.Normal,
3249
- zIndex: this.getMaxNormalBoxZIndex() + 1
3250
- }, false, () => {
3251
- this.makeMaximizedTopBoxFocus();
3252
- });
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
+ );
3253
3341
  }
3254
3342
  }
3255
3343
  } else {
@@ -3271,10 +3359,14 @@ class TeleBoxManager {
3271
3359
  this.blurBox(box);
3272
3360
  isFocusChanged = true;
3273
3361
  }
3274
- this.setBox(box, {
3275
- status: TELE_BOX_STATE.Minimized,
3276
- zIndex: -1
3277
- }, false);
3362
+ this.setBox(
3363
+ box,
3364
+ {
3365
+ status: TELE_BOX_STATE.Minimized,
3366
+ zIndex: -1
3367
+ },
3368
+ false
3369
+ );
3278
3370
  if (isFocusChanged) {
3279
3371
  this.focusTopBox();
3280
3372
  } else {
@@ -3335,7 +3427,8 @@ class TeleBoxManager {
3335
3427
  readonly: readonly$,
3336
3428
  fence: fence$,
3337
3429
  minimized: minimized$,
3338
- maximized: maximized$
3430
+ maximized: maximized$,
3431
+ forceMaximized: forceMaximized$
3339
3432
  };
3340
3433
  i(this, valConfig);
3341
3434
  this._state$ = state$;
@@ -3372,6 +3465,9 @@ class TeleBoxManager {
3372
3465
  return this._state$.value;
3373
3466
  }
3374
3467
  setState(state, skipUpdate = false) {
3468
+ if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
3469
+ return this;
3470
+ }
3375
3471
  switch (state) {
3376
3472
  case TELE_BOX_STATE.Maximized: {
3377
3473
  this.setMinimized(false, skipUpdate);
@@ -3396,7 +3492,11 @@ class TeleBoxManager {
3396
3492
  const oldBoxStatus = this.boxesStatus$.get(boxId);
3397
3493
  this.boxesStatus$.set(boxId, boxStatus);
3398
3494
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
3399
- this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
3495
+ this.setLastNotMinimizedBoxStatus(
3496
+ boxId,
3497
+ oldBoxStatus,
3498
+ skipUpdate
3499
+ );
3400
3500
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
3401
3501
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3402
3502
  }
@@ -3405,7 +3505,10 @@ class TeleBoxManager {
3405
3505
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3406
3506
  }
3407
3507
  if (!skipUpdate) {
3408
- 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
+ });
3409
3512
  }
3410
3513
  }
3411
3514
  getBoxStatus(boxId) {
@@ -3471,7 +3574,9 @@ class TeleBoxManager {
3471
3574
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3472
3575
  clearTimeout(this.effectBoxesStatusTimer.timer);
3473
3576
  if (this.effectBoxesStatusTimer.resolve) {
3474
- 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
+ );
3475
3580
  }
3476
3581
  }
3477
3582
  this.effectBoxesStatusTimer = void 0;
@@ -3481,7 +3586,9 @@ class TeleBoxManager {
3481
3586
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3482
3587
  clearTimeout(this.effectBoxesStatusTimer.timer);
3483
3588
  if (this.effectBoxesStatusTimer.resolve) {
3484
- 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
+ );
3485
3592
  }
3486
3593
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3487
3594
  } else {
@@ -3500,7 +3607,9 @@ class TeleBoxManager {
3500
3607
  this.effectBoxesStatusTimer.resolve = resolve;
3501
3608
  this.effectBoxesStatusTimer.timer = setTimeout(() => {
3502
3609
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3503
- this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3610
+ this.effectBoxesStatusTimer.resolve(
3611
+ this.effectBoxesStatusTimer.skipUpdate
3612
+ );
3504
3613
  }
3505
3614
  }, 100);
3506
3615
  });
@@ -3518,13 +3627,18 @@ class TeleBoxManager {
3518
3627
  if (!this.useBoxesStatus) {
3519
3628
  return false;
3520
3629
  }
3521
- 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
+ );
3522
3633
  }
3523
3634
  getMinimizedBoxesStatus() {
3524
3635
  const minimizedBoxes = /* @__PURE__ */ new Map();
3525
3636
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3526
3637
  if (boxStatus === TELE_BOX_STATE.Minimized) {
3527
- minimizedBoxes.set(boxId, boxStatus);
3638
+ minimizedBoxes.set(
3639
+ boxId,
3640
+ boxStatus
3641
+ );
3528
3642
  }
3529
3643
  });
3530
3644
  return minimizedBoxes;
@@ -3542,7 +3656,10 @@ class TeleBoxManager {
3542
3656
  const maximizedBoxes = /* @__PURE__ */ new Map();
3543
3657
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3544
3658
  if (boxStatus === TELE_BOX_STATE.Maximized) {
3545
- maximizedBoxes.set(boxId, boxStatus);
3659
+ maximizedBoxes.set(
3660
+ boxId,
3661
+ boxStatus
3662
+ );
3546
3663
  }
3547
3664
  });
3548
3665
  return maximizedBoxes;
@@ -3561,12 +3678,18 @@ class TeleBoxManager {
3561
3678
  }
3562
3679
  setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
3563
3680
  if (lastNotMinimizedBoxStatus) {
3564
- this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
3681
+ this.lastNotMinimizedBoxesStatus$.set(
3682
+ boxId,
3683
+ lastNotMinimizedBoxStatus
3684
+ );
3565
3685
  } else {
3566
3686
  this.lastNotMinimizedBoxesStatus$.delete(boxId);
3567
3687
  }
3568
3688
  if (!skipUpdate) {
3569
- 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
+ });
3570
3693
  }
3571
3694
  }
3572
3695
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
@@ -3579,7 +3702,9 @@ class TeleBoxManager {
3579
3702
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3580
3703
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3581
3704
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3582
- 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
+ );
3583
3708
  }
3584
3709
  }
3585
3710
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3589,7 +3714,9 @@ class TeleBoxManager {
3589
3714
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3590
3715
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3591
3716
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3592
- 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
+ );
3593
3720
  }
3594
3721
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3595
3722
  } else {
@@ -3606,11 +3733,16 @@ class TeleBoxManager {
3606
3733
  if (this.effectLastNotMinimizedBoxStatusTimer) {
3607
3734
  const _skipUpdate = await new Promise((resolve) => {
3608
3735
  this.effectLastNotMinimizedBoxStatusTimer.resolve = resolve;
3609
- this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(() => {
3610
- if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3611
- this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate);
3612
- }
3613
- }, 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
+ );
3614
3746
  });
3615
3747
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3616
3748
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3681,15 +3813,20 @@ class TeleBoxManager {
3681
3813
  namespace: this.namespace,
3682
3814
  containerRect: this.containerRect,
3683
3815
  readonly: this.readonly,
3816
+ forceMaximized: this.forceMaximized,
3684
3817
  collectorRect: this.collectorRect
3685
3818
  });
3686
3819
  box.mount(this.root);
3687
3820
  this.boxes$.setValue([...this.boxes, box]);
3688
3821
  if (box.boxStatus && this.useBoxesStatus) {
3689
- this.setBox(box, {
3690
- status: box.boxStatus,
3691
- lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3692
- }, true);
3822
+ this.setBox(
3823
+ box,
3824
+ {
3825
+ status: box.boxStatus,
3826
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3827
+ },
3828
+ true
3829
+ );
3693
3830
  }
3694
3831
  if (box.focus) {
3695
3832
  this.focusBox(box);
@@ -3703,23 +3840,35 @@ class TeleBoxManager {
3703
3840
  return;
3704
3841
  }
3705
3842
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
3706
- this.setBox(box.id, {
3707
- status: TELE_BOX_STATE.Normal,
3708
- zIndex: this.getMaxNormalBoxZIndex() + 1
3709
- }, false);
3843
+ this.setBox(
3844
+ box.id,
3845
+ {
3846
+ status: TELE_BOX_STATE.Normal,
3847
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3848
+ },
3849
+ false
3850
+ );
3710
3851
  } else {
3711
- [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)).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) => {
3712
3855
  if (box2.boxStatus === TELE_BOX_STATE.Normal) {
3713
- this.setBox(box2.id, {
3714
- status: TELE_BOX_STATE.Maximized,
3715
- zIndex: this.getMaxMaximizedBoxZIndex() + 1
3716
- }, false);
3856
+ this.setBox(
3857
+ box2.id,
3858
+ {
3859
+ status: TELE_BOX_STATE.Maximized,
3860
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
3861
+ },
3862
+ false
3863
+ );
3717
3864
  }
3718
3865
  });
3719
3866
  this.makeMaximizedTopBoxFocus();
3720
3867
  }
3721
3868
  } else {
3722
- this.setMaximized(!this.maximized);
3869
+ if (!(this.forceMaximized && this.maximized)) {
3870
+ this.setMaximized(!this.maximized);
3871
+ }
3723
3872
  }
3724
3873
  });
3725
3874
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
@@ -3730,12 +3879,17 @@ class TeleBoxManager {
3730
3879
  if (box.focus) {
3731
3880
  this.blurBox(box);
3732
3881
  }
3733
- this.setBox(box, {
3734
- status: TELE_BOX_STATE.Minimized,
3735
- zIndex: -1
3736
- }, false, () => {
3737
- this.focusTopBox();
3738
- });
3882
+ this.setBox(
3883
+ box,
3884
+ {
3885
+ status: TELE_BOX_STATE.Minimized,
3886
+ zIndex: -1
3887
+ },
3888
+ false,
3889
+ () => {
3890
+ this.focusTopBox();
3891
+ }
3892
+ );
3739
3893
  } else {
3740
3894
  this.setMinimized(true);
3741
3895
  }
@@ -3827,8 +3981,15 @@ class TeleBoxManager {
3827
3981
  box.setZIndex(zIndex, skipUpdate);
3828
3982
  }
3829
3983
  if (lastNotMinimizedBoxStatus) {
3830
- this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
3831
- box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
3984
+ this.setLastNotMinimizedBoxStatus(
3985
+ box.id,
3986
+ lastNotMinimizedBoxStatus,
3987
+ skipUpdate
3988
+ );
3989
+ box.setLastNotMinimizedBoxStatus(
3990
+ lastNotMinimizedBoxStatus,
3991
+ skipUpdate
3992
+ );
3832
3993
  }
3833
3994
  effectFunc && effectFunc();
3834
3995
  }
@@ -3843,12 +4004,16 @@ class TeleBoxManager {
3843
4004
  deletedBoxes.forEach((box2) => box2.destroy());
3844
4005
  if (box && this.useBoxesStatus) {
3845
4006
  this.setBoxStatus(box.id, void 0, skipUpdate);
3846
- this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
4007
+ this.setLastNotMinimizedBoxStatus(
4008
+ box.id,
4009
+ void 0,
4010
+ skipUpdate
4011
+ );
3847
4012
  this.effectBoxStatusChange();
3848
4013
  effectFunc && effectFunc();
3849
4014
  }
3850
4015
  if (!skipUpdate) {
3851
- if (this.boxes.length <= 0) {
4016
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3852
4017
  this.setMaximized(false);
3853
4018
  this.setMinimized(false);
3854
4019
  }
@@ -3871,7 +4036,7 @@ class TeleBoxManager {
3871
4036
  this.boxesStatus$.clear();
3872
4037
  this.lastNotMinimizedBoxesStatus$.clear();
3873
4038
  if (!skipUpdate) {
3874
- if (this.boxes.length <= 0) {
4039
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3875
4040
  this.setMaximized(false);
3876
4041
  this.setMinimized(false);
3877
4042
  }
@@ -4003,10 +4168,14 @@ class TeleBoxManager {
4003
4168
  box.mountFooter(config.footer);
4004
4169
  }
4005
4170
  if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
4006
- this.setBox(box, {
4007
- status: config.boxStatus,
4008
- lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4009
- }, skipUpdate);
4171
+ this.setBox(
4172
+ box,
4173
+ {
4174
+ status: config.boxStatus,
4175
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4176
+ },
4177
+ skipUpdate
4178
+ );
4010
4179
  }
4011
4180
  if (config.forceTop != null) {
4012
4181
  box.setForceTop(config.forceTop, skipUpdate);
@@ -4034,8 +4203,13 @@ class TeleBoxManager {
4034
4203
  vx = 20;
4035
4204
  }
4036
4205
  } else if (this.hasMinimizedBox()) {
4037
- vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
4038
- 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
+ );
4039
4213
  }, vx);
4040
4214
  }
4041
4215
  x = vx / this.containerRect.width;
@@ -4056,8 +4230,13 @@ class TeleBoxManager {
4056
4230
  vy = 20;
4057
4231
  }
4058
4232
  } else if (this.hasMinimizedBox()) {
4059
- vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
4060
- 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
+ );
4061
4240
  }, vy);
4062
4241
  }
4063
4242
  y = vy / this.containerRect.height;
@@ -4078,12 +4257,14 @@ class TeleBoxManager {
4078
4257
  }
4079
4258
  let maximizedBox;
4080
4259
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
4081
- maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
4082
- if (!topBox) {
4083
- 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;
4084
4266
  }
4085
- return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4086
- });
4267
+ );
4087
4268
  }
4088
4269
  return maximizedBox;
4089
4270
  }