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