@netless/telebox-insider 0.3.0-beta.5 → 0.3.0-beta.6

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.
@@ -30,6 +30,7 @@ import {
30
30
  ValEnhancedResult,
31
31
  withValueEnhancer,
32
32
  } from "value-enhancer";
33
+ import { AppMenu } from "../AppMenu";
33
34
 
34
35
  export * from "./typings";
35
36
  export * from "./constants";
@@ -49,13 +50,17 @@ export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
49
50
  export class TeleBoxManager {
50
51
  private boxesStatus$: Map<string, TeleBoxState>;
51
52
  private lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
52
- private effectBoxStatusTimer?: {
53
+ private appMenu: AppMenu | undefined;
54
+ private useBoxesStatus: boolean;
55
+ private effectBoxesStatusTimer?: {
53
56
  skipUpdate: boolean;
54
57
  timer: number | undefined;
58
+ resolve?: (skipUpdate: boolean) => void;
55
59
  }
56
60
  private effectLastNotMinimizedBoxStatusTimer?: {
57
61
  skipUpdate: boolean;
58
62
  timer: number | undefined;
63
+ resolve?: (skipUpdate: boolean) => void;
59
64
  }
60
65
 
61
66
  public constructor({
@@ -73,8 +78,10 @@ export class TeleBoxManager {
73
78
  collector,
74
79
  namespace = "telebox",
75
80
  readonly = false,
81
+ useBoxesStatus = false,
76
82
  }: TeleBoxManagerConfig = {}) {
77
83
  this._sideEffect = new SideEffectManager();
84
+ this.useBoxesStatus = useBoxesStatus;
78
85
  const { combine, createVal } = createSideEffectBinder(this._sideEffect);
79
86
 
80
87
  this.root = root;
@@ -83,12 +90,19 @@ export class TeleBoxManager {
83
90
  this.boxes$ = createVal<TeleBox[]>([]);
84
91
  this.topBox$ = this.boxes$.derive((boxes) => {
85
92
  if (boxes.length > 0) {
86
- const topBox = boxes.reduce((topBox, box) => {
93
+ console.log("topBox===>topBox$===>000");
94
+ let currentTopBox: TeleBox | undefined = undefined;
95
+ const topBox = boxes.reduce((topBox, box) => {
87
96
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
88
97
  return topBox;
89
98
  }
99
+ if (!topBox) {
100
+ topBox = box;
101
+ return topBox;
102
+ }
90
103
  return topBox.zIndex > box.zIndex ? topBox : box;
91
- });
104
+ }, currentTopBox as (TeleBox | undefined));
105
+ console.log("topBox===>topBox$===>end", topBox?.id);
92
106
  return topBox;
93
107
  }
94
108
  return;
@@ -189,7 +203,7 @@ export class TeleBoxManager {
189
203
  new TeleBoxCollector({
190
204
  visible: minimized,
191
205
  readonly: readonly,
192
- namespace,
206
+ namespace
193
207
  }).mount(root)
194
208
  );
195
209
  collector$.subscribe((collector) => {
@@ -198,20 +212,16 @@ export class TeleBoxManager {
198
212
  collector.setReadonly(readonly$.value);
199
213
  collector.setDarkMode(this._darkMode$.value);
200
214
  this._sideEffect.add(() => {
215
+ collector.getBoxesStatus = () => {
216
+ return this.boxesStatus$;
217
+ };
201
218
  collector.onClick = () => {
202
219
  if (!readonly$.value) {
203
- if (this.hasMinimizedBox()) {
204
- this.getAllMinimizedBoxes().forEach((box) => {
205
- const lastNotMinimizedBoxStatus = box.lastNotMinimizedBoxStatus;
206
- if (lastNotMinimizedBoxStatus) {
207
- this.setBoxStatus(box.id, lastNotMinimizedBoxStatus);
208
- } else {
209
- this.setBoxStatus(box.id, TELE_BOX_STATE.Normal);
210
- }
211
- });
212
- this.effectBoxStatusChange();
220
+ if (!this.useBoxesStatus) {
221
+ minimized$.setValue(false);
222
+ } else if (this.useBoxesStatus && this.appMenu) {
223
+ this.appMenu.containerClickHandler();
213
224
  }
214
- minimized$.setValue(false);
215
225
  }
216
226
  };
217
227
  return () => collector.destroy();
@@ -241,6 +251,14 @@ export class TeleBoxManager {
241
251
  return;
242
252
  };
243
253
 
254
+ this._setCollectorRect = (collectorRect: TeleBoxRect | undefined) => {
255
+ if (collector$.value?.$collector) {
256
+ collectorRect$.setValue(collectorRect);
257
+ } else if (import.meta.env.DEV) {
258
+ console.warn("No collector for minimized boxes.");
259
+ }
260
+ };
261
+
244
262
  const collectorRect$ = createVal(
245
263
  minimized$.value ? this._calcCollectorRect() : void 0
246
264
  );
@@ -254,11 +272,7 @@ export class TeleBoxManager {
254
272
  collector$.value?.setVisible(minimized);
255
273
 
256
274
  if (minimized) {
257
- if (collector$.value?.$collector) {
258
- collectorRect$.setValue(this._calcCollectorRect());
259
- } else if (import.meta.env.DEV) {
260
- console.warn("No collector for minimized boxes.");
261
- }
275
+ this._setCollectorRect(this._calcCollectorRect());
262
276
  }
263
277
 
264
278
  this.boxes.forEach((box) =>
@@ -294,10 +308,28 @@ export class TeleBoxManager {
294
308
  if (id) {
295
309
  const box = this.getBox(id);
296
310
  if (box) {
297
- this.focusBox(box);
298
- if ((box.boxStatus && box.boxStatus !== TELE_BOX_STATE.Maximized) || !box.boxStatus) {
311
+ if (!this.useBoxesStatus) {
299
312
  this.makeBoxTop(box);
300
- }
313
+ } else {
314
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
315
+ const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
316
+ if (maxNormalBoxZIndex > box.zIndex) {
317
+ this.setBox(box, {
318
+ zIndex: maxNormalBoxZIndex + 1
319
+ }, false);
320
+ }
321
+ } else if(box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized){
322
+ const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
323
+ if (maxMaximizedBoxZIndex > box.zIndex) {
324
+ this.setBox(box, {
325
+ zIndex: maxMaximizedBoxZIndex + 1
326
+ }, false);
327
+ }
328
+ this.makeMaximizedTopBoxFocus();
329
+ }
330
+ }
331
+ console.log("checkFocusBox===>", box.id);
332
+ this.focusBox(box);
301
333
  return;
302
334
  }
303
335
  }
@@ -330,29 +362,79 @@ export class TeleBoxManager {
330
362
  onEvent: (event): void => {
331
363
  switch (event.type) {
332
364
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
333
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
334
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, TELE_BOX_STATE.Normal);
335
- this.effectBoxStatusChange();
336
- this.makeMaximizedTopBoxFocus();
365
+ if (this.hasBoxesStatus()) {
366
+ let targetBox = this.maxTitleBar.focusedBox;
367
+ if (!targetBox) {
368
+ targetBox = this.getMaximizedTopBox();
369
+ }
370
+ if (targetBox?.id) {
371
+ const box = this.getBox(targetBox.id);
372
+ if (box) {
373
+ this.setBox(box, {
374
+ status: TELE_BOX_STATE.Normal,
375
+ zIndex: this.getMaxNormalBoxZIndex() + 1
376
+ }, false, ()=>{
377
+ this.makeMaximizedTopBoxFocus();
378
+ });
379
+ }
380
+ }
337
381
  } else {
338
382
  maximized$.setValue(!maximized$.value);
339
383
  }
340
384
  break;
341
385
  }
342
386
  case TELE_BOX_DELEGATE_EVENT.Minimize: {
343
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
344
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, TELE_BOX_STATE.Minimized);
345
- this.effectBoxStatusChange();
346
- this.makeMaximizedTopBoxFocus();
387
+ if (this.hasBoxesStatus()) {
388
+ let targetBox = this.maxTitleBar.focusedBox;
389
+ if (!targetBox) {
390
+ targetBox = this.getMaximizedTopBox();
391
+ }
392
+ if(targetBox?.id){
393
+ const box = this.getBox(targetBox.id);
394
+ if (box) {
395
+ let isFocusChanged = false;
396
+ if (this.topBox === box) {
397
+ this.blurBox(box);
398
+ isFocusChanged = true;
399
+ }
400
+ this.setBox(box, {
401
+ status: TELE_BOX_STATE.Minimized,
402
+ zIndex: -1
403
+ }, false);
404
+ if (isFocusChanged) {
405
+ this.focusTopBox();
406
+ } else {
407
+ this.makeMaximizedTopBoxFocus();
408
+ }
409
+ }
410
+ }
347
411
  } else {
348
412
  minimized$.setValue(true);
349
413
  }
350
414
  break;
351
415
  }
352
416
  case TELE_BOX_EVENT.Close: {
353
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
354
- this.remove(this.maxTitleBar.focusedBox.id);
355
- this.makeMaximizedTopBoxFocus();
417
+ if (this.hasBoxesStatus()) {
418
+ let targetBox = this.maxTitleBar.focusedBox;
419
+ if (!targetBox) {
420
+ targetBox = this.getMaximizedTopBox();
421
+ }
422
+ if (targetBox?.id) {
423
+ const box = this.getBox(targetBox.id);
424
+ if (box) {
425
+ let isFocusChanged = false;
426
+ if (this.topBox === box) {
427
+ this.blurBox(box);
428
+ isFocusChanged = true;
429
+ }
430
+ this.remove(box, false);
431
+ if (isFocusChanged) {
432
+ this.focusTopBox();
433
+ } else {
434
+ this.makeMaximizedTopBoxFocus();
435
+ }
436
+ }
437
+ }
356
438
  } else {
357
439
  this.removeTopBox();
358
440
  this.focusTopBox();
@@ -391,6 +473,10 @@ export class TeleBoxManager {
391
473
  this._state$ = state$;
392
474
 
393
475
  this.root.appendChild(this.maxTitleBar.render());
476
+
477
+ if (useBoxesStatus) {
478
+ this.appMenu = this.createMinimizedAppMenu();
479
+ }
394
480
  }
395
481
 
396
482
  public get boxes(): ReadonlyArray<TeleBox> {
@@ -413,6 +499,8 @@ export class TeleBoxManager {
413
499
 
414
500
  public _calcCollectorRect: () => TeleBoxRect | undefined;
415
501
 
502
+ public _setCollectorRect: (collectorRect: TeleBoxRect | undefined) => void;
503
+
416
504
  public get darkMode(): boolean {
417
505
  return this._darkMode$.value;
418
506
  }
@@ -451,15 +539,12 @@ export class TeleBoxManager {
451
539
  this.boxesStatus$.set(boxId, boxStatus);
452
540
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
453
541
  this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
454
- this.effectLastNotMinimizedBoxStatusChange();
455
542
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
456
543
  this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
457
- this.effectLastNotMinimizedBoxStatusChange();
458
544
  }
459
545
  } else {
460
546
  this.boxesStatus$.delete(boxId);
461
547
  this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
462
- this.effectLastNotMinimizedBoxStatusChange();
463
548
  }
464
549
  if (!skipUpdate) {
465
550
  this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus});
@@ -470,10 +555,6 @@ export class TeleBoxManager {
470
555
  return this.boxesStatus$.get(boxId);
471
556
  }
472
557
 
473
- public getLastNotMinimizedBoxStatus(boxId: string): NotMinimizedBoxState | undefined {
474
- return this.lastNotMinimizedBoxesStatus$.get(boxId);
475
- }
476
-
477
558
  public get boxesStatus(): ReadonlyMap<string, TeleBoxState> {
478
559
  return this.boxesStatus$;
479
560
  }
@@ -482,82 +563,164 @@ export class TeleBoxManager {
482
563
  return this.lastNotMinimizedBoxesStatus$;
483
564
  }
484
565
 
485
- public setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate = false): void {
566
+ public async setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate = false): Promise<void> {
486
567
  this.boxesStatus$ = boxesStatus;
487
- this.effectBoxStatusChange(skipUpdate);
568
+ this.effectBoxesStatusChange(skipUpdate);
488
569
  }
489
570
 
571
+ private effectBoxStatusChange(){
572
+ if (!this.useBoxesStatus) {
573
+ return;
574
+ }
575
+ if(this.collector){
576
+ this.collector.updateBoxesStatus();
577
+ if(this.hasMinimizedBox()){
578
+ this._setCollectorRect(this._calcCollectorRect());
579
+ }
580
+ }
581
+ if (this.appMenu) {
582
+ this.appMenu.appMenuChange();
583
+ }
584
+ if (this.maxTitleBar) {
585
+ this.maxTitleBar.updateBoxesStatus();
586
+ }
587
+ }
490
588
 
491
- private effectBoxStatusTimerFunc(skipUpdate: boolean){
492
- this.effectBoxStatusTimer = undefined;
493
- let topBox:TeleBox | undefined;
494
- const topBoxId = this.topBox?.id;
495
- let hasMinimizedBox = false;
589
+ private effectBoxesStatusTimerFunc(skipUpdate: boolean){
590
+ if (!this.useBoxesStatus) {
591
+ return;
592
+ }
593
+ let newTopBox:TeleBox | undefined;
594
+ const curTopBox = this.topBox;
496
595
  this.boxes.forEach((box) => {
497
596
  const boxStatus = this.boxesStatus$.get(box.id);
498
597
  if (boxStatus) {
499
- if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (topBox?.zIndex ?? 0)) {
500
- topBox = box;
598
+ if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (newTopBox?.zIndex ?? 0)) {
599
+ newTopBox = box;
501
600
  }
502
601
  box.setBoxStatus(boxStatus, skipUpdate);
503
- if (boxStatus === TELE_BOX_STATE.Minimized) {
504
- hasMinimizedBox = true;
505
- }
506
602
  }
507
603
  });
508
- if (hasMinimizedBox) {
509
- this.collector?.setVisible(true);
510
- if (this.collector?.$collector) {
511
- this.setCollectorRect(this._calcCollectorRect());
512
- } else if (import.meta.env.DEV) {
513
- console.warn("No collector for minimized boxes.");
514
- }
515
- } else {
516
- this.collector?.setVisible(false);
604
+ this.effectBoxStatusChange();
605
+ if (newTopBox && curTopBox !== newTopBox) {
606
+ this.topBox$.setValue(newTopBox);
607
+ this.focusBox(newTopBox, skipUpdate);
517
608
  }
518
- if (topBox && topBoxId !== topBox.id) {
519
- this.makeBoxTop(topBox, skipUpdate);
520
- this.topBox$.setValue(topBox);
521
- this.focusTopBox();
522
- }
523
- if (this.maxTitleBar) {
524
- this.maxTitleBar.updateBoxesStatus();
609
+ if (!newTopBox && curTopBox) {
610
+ this.topBox$.setValue(undefined);
611
+ this.blurBox(curTopBox, skipUpdate);
525
612
  }
526
- console.log("effectBoxStatusTimerFunc===>end", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
527
613
  }
528
614
 
529
- private effectBoxStatusChange(skipUpdate = false){
530
- if (this.effectBoxStatusTimer && this.effectBoxStatusTimer.timer) {
531
- clearTimeout(this.effectBoxStatusTimer.timer);
532
- if (this.effectBoxStatusTimer.skipUpdate !== skipUpdate) {
533
- this.effectBoxStatusTimer.skipUpdate = skipUpdate;
534
- console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
535
- this.effectBoxStatusTimerFunc(this.effectBoxStatusTimer.skipUpdate)
615
+ public async effectBoxesStatusChange(skipUpdate = false): Promise<void> {
616
+ if (!this.useBoxesStatus) {
617
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
618
+ clearTimeout(this.effectBoxesStatusTimer.timer);
619
+ if (this.effectBoxesStatusTimer.resolve) {
620
+ this.effectBoxesStatusTimer.resolve(!!this.effectBoxesStatusTimer?.skipUpdate);
621
+ }
622
+ }
623
+ this.effectBoxesStatusTimer=undefined;
624
+ return;
625
+ }
626
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
627
+ if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
628
+ clearTimeout(this.effectBoxesStatusTimer.timer);
629
+ if (this.effectBoxesStatusTimer.resolve) {
630
+ console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
631
+ this.effectBoxesStatusTimer.resolve(!!this.effectBoxesStatusTimer?.skipUpdate);
632
+ }
633
+ this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
634
+ console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
635
+ } else {
636
+ return;
536
637
  }
537
638
  }
538
- if (!this.effectBoxStatusTimer) {
539
- this.effectBoxStatusTimer = {
639
+ if (!this.effectBoxesStatusTimer) {
640
+ this.effectBoxesStatusTimer = {
540
641
  skipUpdate,
541
642
  timer: undefined,
643
+ resolve: undefined,
542
644
  } as {
543
645
  skipUpdate: boolean;
544
646
  timer: number | undefined;
545
647
  }
546
648
  }
547
- console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
548
- this.effectBoxStatusTimer.timer = setTimeout(()=>{
549
- this.effectBoxStatusTimerFunc(skipUpdate)
550
- }, 100) as unknown as number;
649
+ if (this.effectBoxesStatusTimer) {
650
+ const _skipUpdate = await new Promise<boolean>((resolve)=>{
651
+ this.effectBoxesStatusTimer!.resolve = resolve;
652
+ this.effectBoxesStatusTimer!.timer = setTimeout(()=>{
653
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
654
+ console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
655
+ this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer!.skipUpdate);
656
+ }
657
+ }, 100) as unknown as number;
658
+ })
659
+ console.log("effectBoxStatusTimerFunc===>000==>00", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
660
+ this.effectBoxesStatusTimerFunc(_skipUpdate)
661
+ this.effectBoxesStatusTimer = undefined;
662
+ console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
663
+ }
551
664
  }
552
665
 
553
666
  public hasBoxesStatus(): boolean {
667
+ if (!this.useBoxesStatus) {
668
+ return false;
669
+ }
554
670
  return this.boxesStatus$.size > 0;
555
671
  }
556
672
 
557
673
  public hasMinimizedBox(): boolean {
674
+ if (!this.useBoxesStatus) {
675
+ return false;
676
+ }
558
677
  return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
559
678
  }
560
679
 
680
+ public getMinimizedBoxesStatus(): Map<string, TELE_BOX_STATE.Minimized> {
681
+ const minimizedBoxes = new Map<string, TELE_BOX_STATE.Minimized>();
682
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
683
+ if (boxStatus === TELE_BOX_STATE.Minimized) {
684
+ minimizedBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Minimized);
685
+ }
686
+ });
687
+ return minimizedBoxes;
688
+ }
689
+
690
+ public getNotMinimizedBoxesStatus(): Map<string, NotMinimizedBoxState> {
691
+ const notMinimizedBoxes = new Map<string, NotMinimizedBoxState>();
692
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
693
+ if (boxStatus !== TELE_BOX_STATE.Minimized) {
694
+ notMinimizedBoxes.set(boxId, boxStatus as NotMinimizedBoxState);
695
+ }
696
+ });
697
+ return notMinimizedBoxes;
698
+ }
699
+
700
+ public getAllMaximizedBoxesStatus(): Map<string, TELE_BOX_STATE.Maximized> {
701
+ const maximizedBoxes = new Map<string, TELE_BOX_STATE.Maximized>();
702
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
703
+ if (boxStatus === TELE_BOX_STATE.Maximized) {
704
+ maximizedBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Maximized);
705
+ }
706
+ });
707
+ return maximizedBoxes;
708
+ }
709
+
710
+ public getAllNormalBoxesStatus(): Map<string, TELE_BOX_STATE.Normal> {
711
+ const normalBoxes = new Map<string, TELE_BOX_STATE.Normal>();
712
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
713
+ if (boxStatus === TELE_BOX_STATE.Normal) {
714
+ normalBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Normal);
715
+ }
716
+ });
717
+ return normalBoxes;
718
+ }
719
+
720
+ public getLastNotMinimizedBoxStatus(boxId: string): NotMinimizedBoxState | undefined {
721
+ return this.lastNotMinimizedBoxesStatus$.get(boxId);
722
+ }
723
+
561
724
  public setLastNotMinimizedBoxStatus(boxId: string, lastNotMinimizedBoxStatus?: NotMinimizedBoxState, skipUpdate = false): void {
562
725
  if (lastNotMinimizedBoxStatus) {
563
726
  this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
@@ -574,23 +737,117 @@ export class TeleBoxManager {
574
737
  this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
575
738
  }
576
739
 
577
- private effectLastNotMinimizedBoxStatusChange(skipUpdate = false){
740
+ private async effectLastNotMinimizedBoxStatusChange(skipUpdate = false): Promise<void> {
741
+ if (!this.useBoxesStatus) {
742
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
743
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
744
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
745
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate);
746
+ }
747
+ }
748
+ this.effectLastNotMinimizedBoxStatusTimer=undefined;
749
+ return;
750
+ }
751
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
752
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
753
+ if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
754
+ // this.effectLastNotMinimizedBoxStatusFunc(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)
755
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
756
+ console.log("effectLastNotMinimizedBoxStatusFunc===>1111", skipUpdate);
757
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate);
758
+ }
759
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
760
+ console.log("effectLastNotMinimizedBoxStatusFunc===>2222", skipUpdate);
761
+ } else {
762
+ return;
763
+ }
764
+ }
765
+ if (!this.effectLastNotMinimizedBoxStatusTimer) {
766
+ this.effectLastNotMinimizedBoxStatusTimer = {
767
+ skipUpdate,
768
+ timer: undefined,
769
+ resolve: undefined,
770
+ } as {
771
+ skipUpdate: boolean;
772
+ timer: number | undefined;
773
+ }
774
+ }
775
+ if (this.effectLastNotMinimizedBoxStatusTimer) {
776
+ const _skipUpdate = await new Promise<boolean>((resolve)=>{
777
+ this.effectLastNotMinimizedBoxStatusTimer!.resolve = resolve;
778
+ this.effectLastNotMinimizedBoxStatusTimer!.timer = setTimeout(()=>{
779
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
780
+ console.log("effectLastNotMinimizedBoxStatusTimer===>000", skipUpdate);
781
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer!.skipUpdate);
782
+ }
783
+ }, 100) as unknown as number;
784
+ })
785
+ console.log("effectLastNotMinimizedBoxStatusFunc===>000==>00", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
786
+ this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate)
787
+ this.effectLastNotMinimizedBoxStatusTimer = undefined;
788
+ console.log("effectLastNotMinimizedBoxStatusFunc===>000==>11", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
789
+ }
790
+ }
791
+
792
+ private effectLastNotMinimizedBoxStatusFunc(skipUpdate = false){
793
+ if (!this.useBoxesStatus) {
794
+ return;
795
+ }
796
+ console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
578
797
  this.boxes.forEach((box) => {
579
798
  const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
580
- box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
799
+ if(boxStatus){
800
+ box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
801
+ }
581
802
  });
582
803
  }
583
804
 
584
- private getAllMinimizedBoxes(): ReadonlyArray<TeleBox> {
585
- return this.boxes.filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
805
+ private getUnabledBoxesStatusZIndex(): number {
806
+ return this.topBox ? this.topBox.zIndex : 99;
807
+ }
808
+
809
+ // private getTopBoxZIndex(): number {
810
+ // if (!this.useBoxesStatus) {
811
+ // return this.getUnabledBoxesStatusZIndex();
812
+ // }
813
+ // return [...this.boxes].filter((box) => box.boxStatus !== TELE_BOX_STATE.Minimized).reduce((maxZIndex, box) => {
814
+ // return Math.max(maxZIndex, box.zIndex);
815
+ // }, 100);
816
+ // }
817
+
818
+ /** Maximized box zIndex range: 100-299 */
819
+ public getMaxMaximizedBoxZIndex(): number {
820
+ if (!this.useBoxesStatus) {
821
+ return this.getUnabledBoxesStatusZIndex();
822
+ }
823
+ return this.boxes.reduce((maxZIndex, box) => {
824
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
825
+ return Math.max(maxZIndex, box.zIndex);
826
+ }
827
+ return maxZIndex;
828
+ }, 99);
829
+ }
830
+
831
+ /** normal box zIndex range: 300-499 */
832
+ public getMaxNormalBoxZIndex(): number {
833
+ if (!this.useBoxesStatus) {
834
+ return this.getUnabledBoxesStatusZIndex();
835
+ }
836
+ return this.boxes.reduce((maxZIndex, box) => {
837
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
838
+ return Math.max(maxZIndex, box.zIndex);
839
+ }
840
+ return maxZIndex;
841
+ }, 299);
586
842
  }
587
843
 
588
844
  public create(
589
845
  config: TeleBoxManagerCreateConfig = {},
590
846
  smartPosition = true
591
847
  ): ReadonlyTeleBox {
848
+ console.log("create===>", config, this.topBox?.zIndex);
592
849
  const box = new TeleBox({
593
- zIndex: this.topBox ? this.topBox.zIndex + 1 : 100,
850
+ zIndex: this.getMaxNormalBoxZIndex() + 1,
594
851
  ...(smartPosition ? this.smartPosition(config) : config),
595
852
  darkMode: this.darkMode,
596
853
  prefersColorScheme: this.prefersColorScheme,
@@ -605,6 +862,15 @@ export class TeleBoxManager {
605
862
 
606
863
  box.mount(this.root);
607
864
 
865
+ this.boxes$.setValue([...this.boxes, box]);
866
+
867
+ if (box.boxStatus && this.useBoxesStatus) {
868
+ this.setBox(box, {
869
+ status: box.boxStatus,
870
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
871
+ }, true);
872
+ }
873
+
608
874
  if (box.focus) {
609
875
  this.focusBox(box);
610
876
  if (smartPosition) {
@@ -612,44 +878,45 @@ export class TeleBoxManager {
612
878
  }
613
879
  }
614
880
 
615
- this.boxes$.setValue([...this.boxes, box]);
616
-
617
- if (box.boxStatus) {
618
- this.setBoxStatus(box.id, box.boxStatus, true);
619
- this.effectBoxStatusChange(true);
620
- }
621
-
622
- if (box._lastNotMinimizedBoxStatus$.value) {
623
- this.setLastNotMinimizedBoxStatus(box.id, box._lastNotMinimizedBoxStatus$.value, true);
624
- this.effectLastNotMinimizedBoxStatusChange();
625
- }
626
-
627
881
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
628
- if (box.boxStatus) {
882
+ if (this.useBoxesStatus && box.boxStatus) {
629
883
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
630
- this.setBoxStatus(box.id, TELE_BOX_STATE.Normal);
884
+ this.setBox(box.id, {
885
+ status: TELE_BOX_STATE.Normal,
886
+ zIndex: this.getMaxNormalBoxZIndex() + 1
887
+ }, false);
631
888
  } else {
632
- this.boxes.forEach((box) => {
889
+ // 所有normal box都最大化
890
+ [...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
633
891
  if (box.boxStatus === TELE_BOX_STATE.Normal) {
634
- this.setBoxStatus(box.id, TELE_BOX_STATE.Maximized);
892
+ console.log("maximized===>", box.id);
893
+ this.setBox(box.id, {
894
+ status: TELE_BOX_STATE.Maximized,
895
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
896
+ }, false);
635
897
  }
636
898
  });
899
+ this.makeMaximizedTopBoxFocus();
637
900
  }
638
- this.effectBoxStatusChange();
639
- this.makeMaximizedTopBoxFocus();
640
901
  } else {
641
902
  this.setMaximized(!this.maximized);
642
903
  }
643
904
 
644
905
  });
645
906
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
646
- if (box.boxStatus) {
647
- const oldBoxStatus = box.boxStatus;
648
- this.setBoxStatus(box.id, TELE_BOX_STATE.Minimized);
649
- this.effectBoxStatusChange();
650
- if (oldBoxStatus === TELE_BOX_STATE.Maximized) {
651
- this.makeMaximizedTopBoxFocus();
907
+ if (box.boxStatus && this.useBoxesStatus) {
908
+ if (this.topBox === box) {
909
+ if (this.topBox?.focus) {
910
+ this.blurBox(this.topBox);
911
+ }
652
912
  }
913
+ this.setBox(box, {
914
+ status: TELE_BOX_STATE.Minimized,
915
+ zIndex: -1
916
+ }, false, ()=>{
917
+ this.focusTopBox();
918
+ });
919
+
653
920
  } else{
654
921
  this.setMinimized(true);
655
922
  }
@@ -685,12 +952,19 @@ export class TeleBoxManager {
685
952
  });
686
953
  box._zIndex$.reaction((_, __, skipUpdate) => {
687
954
  if (this.boxes.length > 0) {
955
+ console.log("topBox===>_zIndex", this.boxes.map((box) => ({id: box.id, zIndex: box.zIndex, boxStatus: box.boxStatus})));
956
+ let currentTopBox: TeleBox | undefined = undefined;
688
957
  const topBox = this.boxes.reduce((topBox, box) => {
689
958
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
690
959
  return topBox;
691
960
  }
961
+ if (!topBox) {
962
+ topBox = box;
963
+ return topBox;
964
+ }
692
965
  return topBox.zIndex > box.zIndex ? topBox : box;
693
- });
966
+ }, currentTopBox as (TeleBox | undefined));
967
+ console.log("topBox===>_zIndex===>end", topBox?.id);
694
968
  this.topBox$.setValue(topBox);
695
969
  }
696
970
  if (!skipUpdate) {
@@ -736,9 +1010,34 @@ export class TeleBoxManager {
736
1010
  });
737
1011
  }
738
1012
 
1013
+ public setBox(boxOrID: string | TeleBox, options: {
1014
+ status?: TeleBoxState;
1015
+ lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
1016
+ zIndex?: number;
1017
+ }, skipUpdate = false, effectFunc?: () => void){
1018
+ const box = this.getBox(boxOrID)
1019
+ if (box) {
1020
+ const {status, zIndex, lastNotMinimizedBoxStatus} = options;
1021
+ if (status) {
1022
+ this.setBoxStatus(box.id, status, skipUpdate);
1023
+ box.setBoxStatus(status, skipUpdate);
1024
+ this.effectBoxStatusChange();
1025
+ }
1026
+ if (zIndex) {
1027
+ box.setZIndex(zIndex, skipUpdate);
1028
+ }
1029
+ if (lastNotMinimizedBoxStatus) {
1030
+ this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
1031
+ box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
1032
+ }
1033
+ effectFunc && effectFunc();
1034
+ }
1035
+ }
1036
+
739
1037
  public remove(
740
1038
  boxOrID: string | TeleBox,
741
- skipUpdate = false
1039
+ skipUpdate = false,
1040
+ effectFunc?: () => void
742
1041
  ): ReadonlyTeleBox | undefined {
743
1042
  const box = this.getBox(boxOrID);
744
1043
  const index = this.getBoxIndex(boxOrID);
@@ -747,13 +1046,11 @@ export class TeleBoxManager {
747
1046
  const deletedBoxes = boxes.splice(index, 1);
748
1047
  this.boxes$.setValue(boxes);
749
1048
  deletedBoxes.forEach((box) => box.destroy());
750
- if (box) {
1049
+ if (box && this.useBoxesStatus) {
751
1050
  this.setBoxStatus(box.id, undefined, skipUpdate);
752
- this.boxesStatus$.delete(box.id);
753
- this.effectBoxStatusChange(skipUpdate);
754
1051
  this.setLastNotMinimizedBoxStatus(box.id, undefined, skipUpdate);
755
- this.lastNotMinimizedBoxesStatus$.delete(box.id);
756
- this.effectLastNotMinimizedBoxStatusChange();
1052
+ this.effectBoxStatusChange();
1053
+ effectFunc && effectFunc();
757
1054
  }
758
1055
  if (!skipUpdate) {
759
1056
  if (this.boxes.length <= 0) {
@@ -827,10 +1124,10 @@ export class TeleBoxManager {
827
1124
  this.blurBox(box, skipUpdate);
828
1125
  }
829
1126
  });
830
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
831
- this.makeMaximizedBoxFocus(targetBox);
832
- } else {
1127
+ if (!this.useBoxesStatus) {
833
1128
  this.maxTitleBar.focusBox(targetBox);
1129
+ } else if (this.useBoxesStatus && this.maxTitleBar.hasMaximizedBoxInStatus()) {
1130
+ this.makeMaximizedTopBoxFocus();
834
1131
  }
835
1132
  }
836
1133
  }
@@ -851,11 +1148,7 @@ export class TeleBoxManager {
851
1148
  }
852
1149
  }
853
1150
  if (this.maxTitleBar.focusedBox === targetBox) {
854
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
855
- this.makeMaximizedTopBoxFocus();
856
- } else {
857
- this.maxTitleBar.focusBox();
858
- }
1151
+ this.maxTitleBar.focusBox();
859
1152
  }
860
1153
  }
861
1154
  }
@@ -870,11 +1163,7 @@ export class TeleBoxManager {
870
1163
  }
871
1164
  });
872
1165
  if (this.maxTitleBar.focusedBox) {
873
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
874
- this.makeMaximizedBoxBlur();
875
- } else {
876
- this.maxTitleBar.focusBox();
877
- }
1166
+ this.maxTitleBar.focusBox();
878
1167
  }
879
1168
  }
880
1169
 
@@ -882,6 +1171,7 @@ export class TeleBoxManager {
882
1171
 
883
1172
  protected boxes$: Val<TeleBox[]>;
884
1173
  protected topBox$: Val<TeleBox | undefined>;
1174
+ // protected maximizedTopBox$: Val<MaxTitleBarTeleBox | undefined>;
885
1175
 
886
1176
  protected teleBoxMatcher(
887
1177
  config: TeleBoxManagerQueryConfig
@@ -943,13 +1233,11 @@ export class TeleBoxManager {
943
1233
  if (config.footer != null) {
944
1234
  box.mountFooter(config.footer);
945
1235
  }
946
- if (config.boxStatus) {
947
- this.setBoxStatus(box.id, config.boxStatus, skipUpdate);
948
- this.effectBoxStatusChange(skipUpdate);
949
- }
950
- if (config.lastNotMinimizedBoxStatus) {
951
- this.setLastNotMinimizedBoxStatus(box.id, config.lastNotMinimizedBoxStatus, skipUpdate);
952
- this.effectLastNotMinimizedBoxStatusChange();
1236
+ if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
1237
+ this.setBox(box, {
1238
+ status: config.boxStatus,
1239
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
1240
+ }, skipUpdate);
953
1241
  }
954
1242
  }
955
1243
 
@@ -961,13 +1249,17 @@ export class TeleBoxManager {
961
1249
  let vx = 20;
962
1250
  if (this.topBox) {
963
1251
  vx = this.topBox.intrinsicX * this.containerRect.width + 20;
964
-
965
1252
  if (
966
1253
  vx >
967
1254
  this.containerRect.width - width * this.containerRect.width
968
1255
  ) {
969
1256
  vx = 20;
970
1257
  }
1258
+ } else if (this.hasMinimizedBox()) {
1259
+ // 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大x
1260
+ vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
1261
+ return Math.max(maxX, box.intrinsicX * this.containerRect.width + 20);
1262
+ }, vx);
971
1263
  }
972
1264
  x = vx / this.containerRect.width;
973
1265
  }
@@ -985,6 +1277,11 @@ export class TeleBoxManager {
985
1277
  ) {
986
1278
  vy = 20;
987
1279
  }
1280
+ } else if (this.hasMinimizedBox()) {
1281
+ // 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大y
1282
+ vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
1283
+ return Math.max(maxY, box.intrinsicY * this.containerRect.height + 20);
1284
+ }, vy);
988
1285
  }
989
1286
 
990
1287
  y = vy / this.containerRect.height;
@@ -994,32 +1291,19 @@ export class TeleBoxManager {
994
1291
  }
995
1292
 
996
1293
  protected makeBoxTop(box: TeleBox, skipUpdate = false): void {
997
- if (this.topBox) {
1294
+ if (!this.useBoxesStatus && this.topBox) {
998
1295
  if (box !== this.topBox) {
999
- if (!this.hasBoxesStatus()) {
1000
- box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
1001
- return;
1002
- }
1003
- const maxZIndex = this.boxes.reduce((maxZIndex, box) => {
1004
- return Math.max(maxZIndex, box.zIndex);
1005
- }, 0);
1006
- const currentTopBoxZIndex = Math.min(this.topBox.zIndex, box.zIndex);
1007
- const addZIndex = maxZIndex + 1 - currentTopBoxZIndex;
1008
- box.setZIndex(maxZIndex + 1, skipUpdate);
1009
- console.log("makeBoxTop===>", box.id, maxZIndex + 1, addZIndex, this.topBox.id, currentTopBoxZIndex);
1010
- if (box.boxStatus !== TELE_BOX_STATE.Minimized) {
1011
- this.boxes.forEach((b) => {
1012
- if (b.boxStatus === TELE_BOX_STATE.Minimized && b.zIndex >= currentTopBoxZIndex) {
1013
- console.log("makeBoxTop===>111", b.id, b.zIndex + addZIndex);
1014
- b.setZIndex(b.zIndex + addZIndex, skipUpdate);
1015
- }
1016
- });
1017
- }
1296
+ box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
1018
1297
  }
1298
+ } else if (this.useBoxesStatus) {
1299
+ // todo
1019
1300
  }
1020
1301
  }
1021
1302
 
1022
- protected makeMaximizedTopBoxFocus(): void {
1303
+ private getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
1304
+ if (!this.useBoxesStatus) {
1305
+ return undefined;
1306
+ }
1023
1307
  let maximizedBox: MaxTitleBarTeleBox | undefined;
1024
1308
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
1025
1309
  maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
@@ -1028,38 +1312,18 @@ export class TeleBoxManager {
1028
1312
  }
1029
1313
  return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
1030
1314
  }, );
1031
- if (maximizedBox) {
1032
- this.maxTitleBar.focusBox(maximizedBox);
1033
- }
1034
1315
  }
1316
+ return maximizedBox;
1035
1317
  }
1036
1318
 
1037
- protected makeMaximizedBoxFocus(maximizedBox: MaxTitleBarTeleBox, skipUpdate = false): void {
1038
- if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
1039
- const currentZIndex = maximizedBox.zIndex;
1040
- const currentMaximizedTopBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, box) => {
1041
- if (!topBox) {
1042
- return box;
1043
- }
1044
- return topBox.zIndex > box.zIndex ? topBox : box;
1045
- });
1046
- if (currentMaximizedTopBox !== maximizedBox) {
1047
- const addZIndex = currentMaximizedTopBox.zIndex - currentZIndex + 1;
1048
- this.boxes.forEach((box) => {
1049
- if (this.maxTitleBar.MaximizedBoxes.find((b) => b.id === box.id && b.id !== maximizedBox.id)) {
1050
- return;
1051
- }
1052
- if (box.zIndex >= currentZIndex) {
1053
- box.setZIndex(box.zIndex + addZIndex, skipUpdate);
1054
- }
1055
- });
1056
- }
1057
- this.maxTitleBar.focusBox(maximizedBox);
1319
+ protected makeMaximizedTopBoxFocus(): void {
1320
+ if (!this.useBoxesStatus) {
1321
+ return;
1058
1322
  }
1059
- }
1060
-
1061
- protected makeMaximizedBoxBlur(): void {
1062
- this.maxTitleBar.focusBox();
1323
+ const maximizedBox: MaxTitleBarTeleBox | undefined = this.getMaximizedTopBox();
1324
+ console.log("makeMaximizedTopBoxFocus===>", maximizedBox?.id);
1325
+ this.maxTitleBar.focusBox(maximizedBox);
1326
+ console.log("makeMaximizedTopBoxFocus===>end", maximizedBox?.id);
1063
1327
  }
1064
1328
 
1065
1329
  protected getBoxIndex(boxOrID: TeleBox | string): number {
@@ -1068,9 +1332,23 @@ export class TeleBoxManager {
1068
1332
  : this.boxes.findIndex((box) => box === boxOrID);
1069
1333
  }
1070
1334
 
1071
- protected getBox(boxOrID: TeleBox | string): TeleBox | undefined {
1335
+ public getBox(boxOrID: TeleBox | string): TeleBox | undefined {
1072
1336
  return typeof boxOrID === "string"
1073
1337
  ? this.boxes.find((box) => box.id === boxOrID)
1074
1338
  : boxOrID;
1075
1339
  }
1340
+
1341
+ public createMinimizedAppMenu():AppMenu | undefined {
1342
+ if (this.collector?.$appMenuContainer) {
1343
+ return new AppMenu({
1344
+ manager: this,
1345
+ container: this.collector?.$appMenuContainer,
1346
+ theme: this.prefersColorScheme ? 'dark' : 'light',
1347
+ getBoxesStatus: () => {
1348
+ return this.boxesStatus$;
1349
+ }
1350
+ });
1351
+ }
1352
+ return;
1353
+ }
1076
1354
  }