@netless/telebox-insider 0.3.0 → 0.3.1

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);
@@ -1636,7 +1674,10 @@ class TeleBox {
1636
1674
  this.events.emit(TELE_BOX_EVENT.Minimized, minimized2);
1637
1675
  }
1638
1676
  });
1639
- const maximized$ = createVal(maximized);
1677
+ const maximized$ = createVal(
1678
+ maximized || forceMaximized,
1679
+ (next, previous) => next === previous || forceMaximized$.value && !next
1680
+ );
1640
1681
  maximized$.reaction((maximized2, _, skipUpdate) => {
1641
1682
  if (!skipUpdate) {
1642
1683
  this.events.emit(TELE_BOX_EVENT.Maximized, maximized2);
@@ -1773,6 +1814,7 @@ class TeleBox {
1773
1814
  boxStatus: boxStatus$.value,
1774
1815
  forceTop: forceTop$.value,
1775
1816
  forceNormal: forceNormal$.value,
1817
+ forceMaximized: forceMaximized$.value,
1776
1818
  onDragStart: (event) => {
1777
1819
  var _a;
1778
1820
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1783,7 +1825,7 @@ class TeleBox {
1783
1825
  } else {
1784
1826
  switch (event.type) {
1785
1827
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
1786
- if (!boxStatus$.value) {
1828
+ if (!boxStatus$.value && !(forceMaximized$.value && maximized$.value)) {
1787
1829
  maximized$.setValue(!maximized$.value);
1788
1830
  }
1789
1831
  break;
@@ -1812,6 +1854,12 @@ class TeleBox {
1812
1854
  readonly$.reaction((readonly2) => {
1813
1855
  this.titleBar.setReadonly(readonly2);
1814
1856
  });
1857
+ forceMaximized$.reaction((forceMaximized2) => {
1858
+ var _a, _b;
1859
+ if (forceMaximized2)
1860
+ maximized$.setValue(true);
1861
+ (_b = (_a = this.titleBar).setForceMaximized) == null ? void 0 : _b.call(_a, forceMaximized2);
1862
+ });
1815
1863
  boxStatus$.reaction((boxStatus2) => {
1816
1864
  this.titleBar.setBoxStatus(boxStatus2);
1817
1865
  });
@@ -1839,6 +1887,7 @@ class TeleBox {
1839
1887
  $userStyles: $userStyles$,
1840
1888
  forceTop: forceTop$,
1841
1889
  forceNormal: forceNormal$,
1890
+ forceMaximized: forceMaximized$,
1842
1891
  isDragContent: isDragContent$
1843
1892
  };
1844
1893
  i(this, valConfig);
@@ -1900,21 +1949,33 @@ class TeleBox {
1900
1949
  setBoxStatus(boxStatus, skipUpdate = false) {
1901
1950
  if (boxStatus === TELE_BOX_STATE.Minimized) {
1902
1951
  if (this._boxStatus$.value && this._boxStatus$.value !== TELE_BOX_STATE.Minimized) {
1903
- this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1952
+ this.setLastNotMinimizedBoxStatus(
1953
+ this._boxStatus$.value,
1954
+ skipUpdate
1955
+ );
1904
1956
  }
1905
1957
  } else {
1906
1958
  this.setLastNotMinimizedBoxStatus(void 0, skipUpdate);
1907
1959
  }
1908
1960
  this._boxStatus$.setValue(boxStatus, skipUpdate);
1909
1961
  if (!skipUpdate) {
1910
- this.events.emit(TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1962
+ this.events.emit(TELE_BOX_EVENT.BoxStatus, {
1963
+ id: this.id,
1964
+ boxStatus
1965
+ });
1911
1966
  }
1912
1967
  return this;
1913
1968
  }
1914
1969
  setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1915
- this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1970
+ this._lastNotMinimizedBoxStatus$.setValue(
1971
+ lastNotMinimizedBoxStatus,
1972
+ skipUpdate
1973
+ );
1916
1974
  if (!skipUpdate) {
1917
- this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1975
+ this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, {
1976
+ id: this.id,
1977
+ lastNotMinimizedBoxStatus
1978
+ });
1918
1979
  }
1919
1980
  return this;
1920
1981
  }
@@ -2147,7 +2208,14 @@ class TeleBox {
2147
2208
  this._collectorRect$,
2148
2209
  this._boxStatus$
2149
2210
  ],
2150
- ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2211
+ ([
2212
+ coord,
2213
+ size,
2214
+ minimized,
2215
+ containerRect,
2216
+ collectorRect,
2217
+ boxStatus
2218
+ ]) => {
2151
2219
  const absoluteWidth = size.width * containerRect.width;
2152
2220
  const absoluteHeight = size.height * containerRect.height;
2153
2221
  return {
@@ -2986,9 +3054,11 @@ class TeleBoxManager {
2986
3054
  collector,
2987
3055
  namespace = "telebox",
2988
3056
  readonly = false,
3057
+ forceMaximized = false,
2989
3058
  useBoxesStatus = false
2990
3059
  } = {}) {
2991
3060
  this.events = new EventEmitter();
3061
+ this.committedFocusDepth = 0;
2992
3062
  this._sideEffect = new o();
2993
3063
  this.useBoxesStatus = useBoxesStatus;
2994
3064
  const { combine, createVal } = c(this._sideEffect);
@@ -3056,7 +3126,20 @@ class TeleBoxManager {
3056
3126
  this.boxes.forEach((box) => box.setReadonly(readonly2, skipUpdate));
3057
3127
  });
3058
3128
  const minimized$ = createVal(minimized);
3059
- const maximized$ = createVal(maximized);
3129
+ const forceMaximized$ = createVal(forceMaximized);
3130
+ const maximized$ = createVal(
3131
+ maximized || forceMaximized,
3132
+ (next, previous) => next === previous || forceMaximized$.value && !next
3133
+ );
3134
+ forceMaximized$.reaction((forceMaximized2, _, skipUpdate) => {
3135
+ var _a, _b;
3136
+ if (forceMaximized2)
3137
+ maximized$.setValue(true, skipUpdate);
3138
+ this.boxes.forEach(
3139
+ (box) => box.setForceMaximized(forceMaximized2, skipUpdate)
3140
+ );
3141
+ (_b = (_a = this.maxTitleBar) == null ? void 0 : _a.setForceMaximized) == null ? void 0 : _b.call(_a, forceMaximized2);
3142
+ });
3060
3143
  maximized$.reaction((maximized2, _, skipUpdate) => {
3061
3144
  this.boxes.forEach(
3062
3145
  (box) => box.setMaximized(maximized2, skipUpdate)
@@ -3171,7 +3254,7 @@ class TeleBoxManager {
3171
3254
  });
3172
3255
  const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
3173
3256
  const checkFocusBox = (ev) => {
3174
- var _a;
3257
+ var _a, _b;
3175
3258
  if (readonly$.value) {
3176
3259
  return;
3177
3260
  }
@@ -3187,27 +3270,37 @@ class TeleBoxManager {
3187
3270
  if (id) {
3188
3271
  const box = this.getBox(id);
3189
3272
  if (box) {
3273
+ if ((_b = this.lazyFocusRequestHandler) == null ? void 0 : _b.call(this, box.id))
3274
+ return;
3190
3275
  if (!this.useBoxesStatus) {
3191
3276
  this.makeBoxTop(box);
3192
3277
  } else {
3193
3278
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3194
3279
  const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
3195
3280
  if (maxNormalBoxZIndex > box.zIndex) {
3196
- this.setBox(box, {
3197
- zIndex: maxNormalBoxZIndex + 1
3198
- }, false);
3281
+ this.setBox(
3282
+ box,
3283
+ {
3284
+ zIndex: maxNormalBoxZIndex + 1
3285
+ },
3286
+ false
3287
+ );
3199
3288
  }
3200
3289
  } else if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3201
3290
  const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
3202
3291
  if (maxMaximizedBoxZIndex > box.zIndex) {
3203
- this.setBox(box, {
3204
- zIndex: maxMaximizedBoxZIndex + 1
3205
- }, false);
3292
+ this.setBox(
3293
+ box,
3294
+ {
3295
+ zIndex: maxMaximizedBoxZIndex + 1
3296
+ },
3297
+ false
3298
+ );
3206
3299
  }
3207
3300
  this.makeMaximizedTopBoxFocus();
3208
3301
  }
3209
3302
  }
3210
- this.focusBox(box);
3303
+ this.focusBoxCommitted(box);
3211
3304
  return;
3212
3305
  }
3213
3306
  }
@@ -3230,6 +3323,7 @@ class TeleBoxManager {
3230
3323
  readonly: readonly$.value,
3231
3324
  namespace: this.namespace,
3232
3325
  state: state$.value,
3326
+ forceMaximized: forceMaximized$.value,
3233
3327
  boxes: this.boxes$.value,
3234
3328
  containerRect: containerRect$.value,
3235
3329
  getBoxesStatus: () => {
@@ -3238,6 +3332,9 @@ class TeleBoxManager {
3238
3332
  onEvent: (event) => {
3239
3333
  switch (event.type) {
3240
3334
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
3335
+ if (forceMaximized$.value && this.state === TELE_BOX_STATE.Maximized) {
3336
+ return;
3337
+ }
3241
3338
  if (this.hasBoxesStatus()) {
3242
3339
  let targetBox = this.maxTitleBar.focusedBox;
3243
3340
  if (!targetBox) {
@@ -3246,12 +3343,17 @@ class TeleBoxManager {
3246
3343
  if (targetBox == null ? void 0 : targetBox.id) {
3247
3344
  const box = this.getBox(targetBox.id);
3248
3345
  if (box) {
3249
- this.setBox(box, {
3250
- status: TELE_BOX_STATE.Normal,
3251
- zIndex: this.getMaxNormalBoxZIndex() + 1
3252
- }, false, () => {
3253
- this.makeMaximizedTopBoxFocus();
3254
- });
3346
+ this.setBox(
3347
+ box,
3348
+ {
3349
+ status: TELE_BOX_STATE.Normal,
3350
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3351
+ },
3352
+ false,
3353
+ () => {
3354
+ this.makeMaximizedTopBoxFocus();
3355
+ }
3356
+ );
3255
3357
  }
3256
3358
  }
3257
3359
  } else {
@@ -3273,10 +3375,14 @@ class TeleBoxManager {
3273
3375
  this.blurBox(box);
3274
3376
  isFocusChanged = true;
3275
3377
  }
3276
- this.setBox(box, {
3277
- status: TELE_BOX_STATE.Minimized,
3278
- zIndex: -1
3279
- }, false);
3378
+ this.setBox(
3379
+ box,
3380
+ {
3381
+ status: TELE_BOX_STATE.Minimized,
3382
+ zIndex: -1
3383
+ },
3384
+ false
3385
+ );
3280
3386
  if (isFocusChanged) {
3281
3387
  this.focusTopBox();
3282
3388
  } else {
@@ -3337,7 +3443,8 @@ class TeleBoxManager {
3337
3443
  readonly: readonly$,
3338
3444
  fence: fence$,
3339
3445
  minimized: minimized$,
3340
- maximized: maximized$
3446
+ maximized: maximized$,
3447
+ forceMaximized: forceMaximized$
3341
3448
  };
3342
3449
  i(this, valConfig);
3343
3450
  this._state$ = state$;
@@ -3373,7 +3480,27 @@ class TeleBoxManager {
3373
3480
  get state() {
3374
3481
  return this._state$.value;
3375
3482
  }
3483
+ setUseBoxesStatus(useBoxesStatus) {
3484
+ var _a, _b;
3485
+ if (this.useBoxesStatus === useBoxesStatus)
3486
+ return;
3487
+ this.useBoxesStatus = useBoxesStatus;
3488
+ this.boxes.forEach(
3489
+ (box) => box.setBoxStatus(useBoxesStatus ? this.boxesStatus$.get(box.id) : void 0, true)
3490
+ );
3491
+ this.boxes$.setValue([...this.boxes]);
3492
+ if (useBoxesStatus) {
3493
+ this.appMenu || (this.appMenu = this.createMinimizedAppMenu());
3494
+ this.effectBoxStatusChange();
3495
+ } else {
3496
+ (_a = this.appMenu) == null ? void 0 : _a.render(/* @__PURE__ */ new Map());
3497
+ (_b = this.collector) == null ? void 0 : _b.setVisible(false);
3498
+ }
3499
+ }
3376
3500
  setState(state, skipUpdate = false) {
3501
+ if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
3502
+ return this;
3503
+ }
3377
3504
  switch (state) {
3378
3505
  case TELE_BOX_STATE.Maximized: {
3379
3506
  this.setMinimized(false, skipUpdate);
@@ -3398,7 +3525,11 @@ class TeleBoxManager {
3398
3525
  const oldBoxStatus = this.boxesStatus$.get(boxId);
3399
3526
  this.boxesStatus$.set(boxId, boxStatus);
3400
3527
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
3401
- this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
3528
+ this.setLastNotMinimizedBoxStatus(
3529
+ boxId,
3530
+ oldBoxStatus,
3531
+ skipUpdate
3532
+ );
3402
3533
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
3403
3534
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3404
3535
  }
@@ -3407,7 +3538,10 @@ class TeleBoxManager {
3407
3538
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
3408
3539
  }
3409
3540
  if (!skipUpdate) {
3410
- this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
3541
+ this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, {
3542
+ id: boxId,
3543
+ boxStatus
3544
+ });
3411
3545
  }
3412
3546
  }
3413
3547
  getBoxStatus(boxId) {
@@ -3473,7 +3607,9 @@ class TeleBoxManager {
3473
3607
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3474
3608
  clearTimeout(this.effectBoxesStatusTimer.timer);
3475
3609
  if (this.effectBoxesStatusTimer.resolve) {
3476
- this.effectBoxesStatusTimer.resolve(!!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate));
3610
+ this.effectBoxesStatusTimer.resolve(
3611
+ !!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate)
3612
+ );
3477
3613
  }
3478
3614
  }
3479
3615
  this.effectBoxesStatusTimer = void 0;
@@ -3483,7 +3619,9 @@ class TeleBoxManager {
3483
3619
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3484
3620
  clearTimeout(this.effectBoxesStatusTimer.timer);
3485
3621
  if (this.effectBoxesStatusTimer.resolve) {
3486
- this.effectBoxesStatusTimer.resolve(!!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate));
3622
+ this.effectBoxesStatusTimer.resolve(
3623
+ !!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate)
3624
+ );
3487
3625
  }
3488
3626
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3489
3627
  } else {
@@ -3502,7 +3640,9 @@ class TeleBoxManager {
3502
3640
  this.effectBoxesStatusTimer.resolve = resolve;
3503
3641
  this.effectBoxesStatusTimer.timer = setTimeout(() => {
3504
3642
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3505
- this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3643
+ this.effectBoxesStatusTimer.resolve(
3644
+ this.effectBoxesStatusTimer.skipUpdate
3645
+ );
3506
3646
  }
3507
3647
  }, 100);
3508
3648
  });
@@ -3520,13 +3660,18 @@ class TeleBoxManager {
3520
3660
  if (!this.useBoxesStatus) {
3521
3661
  return false;
3522
3662
  }
3523
- return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
3663
+ return this.boxes.some(
3664
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized
3665
+ );
3524
3666
  }
3525
3667
  getMinimizedBoxesStatus() {
3526
3668
  const minimizedBoxes = /* @__PURE__ */ new Map();
3527
3669
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3528
3670
  if (boxStatus === TELE_BOX_STATE.Minimized) {
3529
- minimizedBoxes.set(boxId, boxStatus);
3671
+ minimizedBoxes.set(
3672
+ boxId,
3673
+ boxStatus
3674
+ );
3530
3675
  }
3531
3676
  });
3532
3677
  return minimizedBoxes;
@@ -3544,7 +3689,10 @@ class TeleBoxManager {
3544
3689
  const maximizedBoxes = /* @__PURE__ */ new Map();
3545
3690
  this.boxesStatus$.forEach((boxStatus, boxId) => {
3546
3691
  if (boxStatus === TELE_BOX_STATE.Maximized) {
3547
- maximizedBoxes.set(boxId, boxStatus);
3692
+ maximizedBoxes.set(
3693
+ boxId,
3694
+ boxStatus
3695
+ );
3548
3696
  }
3549
3697
  });
3550
3698
  return maximizedBoxes;
@@ -3563,12 +3711,18 @@ class TeleBoxManager {
3563
3711
  }
3564
3712
  setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
3565
3713
  if (lastNotMinimizedBoxStatus) {
3566
- this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
3714
+ this.lastNotMinimizedBoxesStatus$.set(
3715
+ boxId,
3716
+ lastNotMinimizedBoxStatus
3717
+ );
3567
3718
  } else {
3568
3719
  this.lastNotMinimizedBoxesStatus$.delete(boxId);
3569
3720
  }
3570
3721
  if (!skipUpdate) {
3571
- this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
3722
+ this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, {
3723
+ id: boxId,
3724
+ boxStatus: lastNotMinimizedBoxStatus
3725
+ });
3572
3726
  }
3573
3727
  }
3574
3728
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
@@ -3581,7 +3735,9 @@ class TeleBoxManager {
3581
3735
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3582
3736
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3583
3737
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3584
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate));
3738
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3739
+ !!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate)
3740
+ );
3585
3741
  }
3586
3742
  }
3587
3743
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3591,7 +3747,9 @@ class TeleBoxManager {
3591
3747
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3592
3748
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3593
3749
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3594
- this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate));
3750
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3751
+ !!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate)
3752
+ );
3595
3753
  }
3596
3754
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3597
3755
  } else {
@@ -3608,11 +3766,16 @@ class TeleBoxManager {
3608
3766
  if (this.effectLastNotMinimizedBoxStatusTimer) {
3609
3767
  const _skipUpdate = await new Promise((resolve) => {
3610
3768
  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);
3769
+ this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(
3770
+ () => {
3771
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3772
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(
3773
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate
3774
+ );
3775
+ }
3776
+ },
3777
+ 100
3778
+ );
3616
3779
  });
3617
3780
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3618
3781
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
@@ -3675,6 +3838,7 @@ class TeleBoxManager {
3675
3838
  const box = new TeleBox({
3676
3839
  zIndex: config.forceTop ? this.getMaxForceTopBoxZIndex() + 1 : this.getMaxNormalBoxZIndex() + 1,
3677
3840
  ...smartPosition ? this.smartPosition(config) : config,
3841
+ ...!this.useBoxesStatus ? { boxStatus: void 0, lastNotMinimizedBoxStatus: void 0 } : {},
3678
3842
  darkMode: this.darkMode,
3679
3843
  prefersColorScheme: this.prefersColorScheme,
3680
3844
  maximized: this.maximized,
@@ -3683,15 +3847,20 @@ class TeleBoxManager {
3683
3847
  namespace: this.namespace,
3684
3848
  containerRect: this.containerRect,
3685
3849
  readonly: this.readonly,
3850
+ forceMaximized: this.forceMaximized,
3686
3851
  collectorRect: this.collectorRect
3687
3852
  });
3688
3853
  box.mount(this.root);
3689
3854
  this.boxes$.setValue([...this.boxes, box]);
3690
3855
  if (box.boxStatus && this.useBoxesStatus) {
3691
- this.setBox(box, {
3692
- status: box.boxStatus,
3693
- lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3694
- }, true);
3856
+ this.setBox(
3857
+ box,
3858
+ {
3859
+ status: box.boxStatus,
3860
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3861
+ },
3862
+ true
3863
+ );
3695
3864
  }
3696
3865
  if (box.focus) {
3697
3866
  this.focusBox(box);
@@ -3705,23 +3874,35 @@ class TeleBoxManager {
3705
3874
  return;
3706
3875
  }
3707
3876
  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);
3877
+ this.setBox(
3878
+ box.id,
3879
+ {
3880
+ status: TELE_BOX_STATE.Normal,
3881
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3882
+ },
3883
+ false
3884
+ );
3712
3885
  } else {
3713
- [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3886
+ [...this.boxes].filter(
3887
+ (box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)
3888
+ ).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3714
3889
  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);
3890
+ this.setBox(
3891
+ box2.id,
3892
+ {
3893
+ status: TELE_BOX_STATE.Maximized,
3894
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
3895
+ },
3896
+ false
3897
+ );
3719
3898
  }
3720
3899
  });
3721
3900
  this.makeMaximizedTopBoxFocus();
3722
3901
  }
3723
3902
  } else {
3724
- this.setMaximized(!this.maximized);
3903
+ if (!(this.forceMaximized && this.maximized)) {
3904
+ this.setMaximized(!this.maximized);
3905
+ }
3725
3906
  }
3726
3907
  });
3727
3908
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
@@ -3732,12 +3913,17 @@ class TeleBoxManager {
3732
3913
  if (box.focus) {
3733
3914
  this.blurBox(box);
3734
3915
  }
3735
- this.setBox(box, {
3736
- status: TELE_BOX_STATE.Minimized,
3737
- zIndex: -1
3738
- }, false, () => {
3739
- this.focusTopBox();
3740
- });
3916
+ this.setBox(
3917
+ box,
3918
+ {
3919
+ status: TELE_BOX_STATE.Minimized,
3920
+ zIndex: -1
3921
+ },
3922
+ false,
3923
+ () => {
3924
+ this.focusTopBox();
3925
+ }
3926
+ );
3741
3927
  } else {
3742
3928
  this.setMinimized(true);
3743
3929
  }
@@ -3829,8 +4015,15 @@ class TeleBoxManager {
3829
4015
  box.setZIndex(zIndex, skipUpdate);
3830
4016
  }
3831
4017
  if (lastNotMinimizedBoxStatus) {
3832
- this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
3833
- box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
4018
+ this.setLastNotMinimizedBoxStatus(
4019
+ box.id,
4020
+ lastNotMinimizedBoxStatus,
4021
+ skipUpdate
4022
+ );
4023
+ box.setLastNotMinimizedBoxStatus(
4024
+ lastNotMinimizedBoxStatus,
4025
+ skipUpdate
4026
+ );
3834
4027
  }
3835
4028
  effectFunc && effectFunc();
3836
4029
  }
@@ -3845,12 +4038,16 @@ class TeleBoxManager {
3845
4038
  deletedBoxes.forEach((box2) => box2.destroy());
3846
4039
  if (box && this.useBoxesStatus) {
3847
4040
  this.setBoxStatus(box.id, void 0, skipUpdate);
3848
- this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
4041
+ this.setLastNotMinimizedBoxStatus(
4042
+ box.id,
4043
+ void 0,
4044
+ skipUpdate
4045
+ );
3849
4046
  this.effectBoxStatusChange();
3850
4047
  effectFunc && effectFunc();
3851
4048
  }
3852
4049
  if (!skipUpdate) {
3853
- if (this.boxes.length <= 0) {
4050
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3854
4051
  this.setMaximized(false);
3855
4052
  this.setMinimized(false);
3856
4053
  }
@@ -3873,7 +4070,7 @@ class TeleBoxManager {
3873
4070
  this.boxesStatus$.clear();
3874
4071
  this.lastNotMinimizedBoxesStatus$.clear();
3875
4072
  if (!skipUpdate) {
3876
- if (this.boxes.length <= 0) {
4073
+ if (this.boxes.length <= 0 && !this.forceMaximized) {
3877
4074
  this.setMaximized(false);
3878
4075
  this.setMinimized(false);
3879
4076
  }
@@ -3895,9 +4092,15 @@ class TeleBoxManager {
3895
4092
  wrapClassName(className) {
3896
4093
  return `${this.namespace}-${className}`;
3897
4094
  }
4095
+ setLazyFocusRequestHandler(handler) {
4096
+ this.lazyFocusRequestHandler = handler;
4097
+ }
3898
4098
  focusBox(boxOrID, skipUpdate = false) {
4099
+ var _a;
3899
4100
  const targetBox = this.getBox(boxOrID);
3900
4101
  if (targetBox) {
4102
+ if (!skipUpdate && !this.committedFocusDepth && ((_a = this.lazyFocusRequestHandler) == null ? void 0 : _a.call(this, targetBox.id)))
4103
+ return;
3901
4104
  this.boxes.forEach((box) => {
3902
4105
  if (targetBox === box) {
3903
4106
  let focusChanged = false;
@@ -3922,6 +4125,15 @@ class TeleBoxManager {
3922
4125
  }
3923
4126
  }
3924
4127
  }
4128
+ focusBoxCommitted(boxOrID, skipUpdate = false) {
4129
+ var _a;
4130
+ this.committedFocusDepth = ((_a = this.committedFocusDepth) != null ? _a : 0) + 1;
4131
+ try {
4132
+ this.focusBox(boxOrID, skipUpdate);
4133
+ } finally {
4134
+ this.committedFocusDepth -= 1;
4135
+ }
4136
+ }
3925
4137
  focusTopBox() {
3926
4138
  if (this.topBox && !this.topBox.focus) {
3927
4139
  return this.focusBox(this.topBox);
@@ -4005,10 +4217,14 @@ class TeleBoxManager {
4005
4217
  box.mountFooter(config.footer);
4006
4218
  }
4007
4219
  if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
4008
- this.setBox(box, {
4009
- status: config.boxStatus,
4010
- lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4011
- }, skipUpdate);
4220
+ this.setBox(
4221
+ box,
4222
+ {
4223
+ status: config.boxStatus,
4224
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
4225
+ },
4226
+ skipUpdate
4227
+ );
4012
4228
  }
4013
4229
  if (config.forceTop != null) {
4014
4230
  box.setForceTop(config.forceTop, skipUpdate);
@@ -4036,8 +4252,13 @@ class TeleBoxManager {
4036
4252
  vx = 20;
4037
4253
  }
4038
4254
  } 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);
4255
+ vx = [...this.boxes].filter(
4256
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4257
+ ).reduce((maxX, box) => {
4258
+ return Math.max(
4259
+ maxX,
4260
+ box.intrinsicX * this.containerRect.width + 20
4261
+ );
4041
4262
  }, vx);
4042
4263
  }
4043
4264
  x = vx / this.containerRect.width;
@@ -4058,8 +4279,13 @@ class TeleBoxManager {
4058
4279
  vy = 20;
4059
4280
  }
4060
4281
  } 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);
4282
+ vy = [...this.boxes].filter(
4283
+ (box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal
4284
+ ).reduce((maxY, box) => {
4285
+ return Math.max(
4286
+ maxY,
4287
+ box.intrinsicY * this.containerRect.height + 20
4288
+ );
4063
4289
  }, vy);
4064
4290
  }
4065
4291
  y = vy / this.containerRect.height;
@@ -4080,12 +4306,14 @@ class TeleBoxManager {
4080
4306
  }
4081
4307
  let maximizedBox;
4082
4308
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
4083
- maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
4084
- if (!topBox) {
4085
- return currentBox;
4309
+ maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce(
4310
+ (topBox, currentBox) => {
4311
+ if (!topBox) {
4312
+ return currentBox;
4313
+ }
4314
+ return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4086
4315
  }
4087
- return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
4088
- });
4316
+ );
4089
4317
  }
4090
4318
  return maximizedBox;
4091
4319
  }