@netless/telebox-insider 0.2.11 → 0.2.15

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/telebox-insider",
3
- "version": "0.2.11",
3
+ "version": "0.2.15",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "license": "MIT",
@@ -59,7 +59,6 @@ export class TeleBoxManager {
59
59
  },
60
60
  collector,
61
61
  namespace = "telebox",
62
- zIndex = 100,
63
62
  readonly = false,
64
63
  }: TeleBoxManagerConfig = {}) {
65
64
  this._sideEffect = new SideEffectManager();
@@ -67,7 +66,6 @@ export class TeleBoxManager {
67
66
 
68
67
  this.root = root;
69
68
  this.namespace = namespace;
70
- this.zIndex = zIndex;
71
69
 
72
70
  this.boxes$ = createVal<TeleBox[]>([]);
73
71
  this.topBox$ = this.boxes$.derive((boxes) => {
@@ -346,8 +344,6 @@ export class TeleBoxManager {
346
344
 
347
345
  public readonly namespace: string;
348
346
 
349
- public zIndex: number;
350
-
351
347
  public _darkMode$: Val<boolean, boolean>;
352
348
 
353
349
  public get darkMode(): boolean {
@@ -387,7 +383,7 @@ export class TeleBoxManager {
387
383
  smartPosition = true
388
384
  ): ReadonlyTeleBox {
389
385
  const box = new TeleBox({
390
- zIndex: this.zIndex,
386
+ zIndex: this.topBox ? this.topBox.zIndex + 1 : 100,
391
387
  ...(smartPosition ? this.smartPosition(config) : config),
392
388
  darkMode: this.darkMode,
393
389
  prefersColorScheme: this.prefersColorScheme,
@@ -477,18 +473,18 @@ export class TeleBoxManager {
477
473
  const index = this.getBoxIndex(boxOrID);
478
474
  if (index >= 0) {
479
475
  const boxes = this.boxes.slice();
480
- const deletedBox = boxes.splice(index, 1)[0];
476
+ const deletedBoxes = boxes.splice(index, 1);
481
477
  this.boxes$.setValue(boxes);
482
478
  this.focusTopBox();
483
- deletedBox.destroy();
479
+ deletedBoxes.forEach((box) => box.destroy());
484
480
  if (!skipUpdate) {
485
481
  if (this.boxes.length <= 0) {
486
482
  this.setMaximized(false);
487
483
  this.setMinimized(false);
488
484
  }
489
- this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, boxes);
485
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
490
486
  }
491
- return deletedBox;
487
+ return deletedBoxes[0];
492
488
  }
493
489
  return;
494
490
  }
@@ -647,6 +643,9 @@ export class TeleBoxManager {
647
643
  if (config.fixRatio != null) {
648
644
  box.setFixRatio(config.fixRatio, skipUpdate);
649
645
  }
646
+ if (config.zIndex != null) {
647
+ box.setZIndex(config.zIndex);
648
+ }
650
649
  if (config.content != null) {
651
650
  box.mountContent(config.content);
652
651
  }
@@ -696,15 +695,13 @@ export class TeleBoxManager {
696
695
  }
697
696
 
698
697
  protected makeBoxTop(box: TeleBox, skipUpdate = false): void {
699
- if (box !== this.topBox) {
700
- const maxIndex = this.boxes.reduce(
701
- (max, box) => Math.max(max, box.zIndex),
702
- 0
703
- );
704
- box.setZIndex(maxIndex + 1, skipUpdate);
705
- this.topBox$.setValue(box);
706
- if (!skipUpdate) {
707
- this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
698
+ if (this.topBox) {
699
+ if (box !== this.topBox) {
700
+ box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
701
+ this.topBox$.setValue(box);
702
+ if (!skipUpdate) {
703
+ this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
704
+ }
708
705
  }
709
706
  }
710
707
  }
@@ -14,7 +14,6 @@ export interface TeleBoxManagerConfig
14
14
  | "maximized"
15
15
  | "minimized"
16
16
  | "namespace"
17
- | "zIndex"
18
17
  | "readonly"
19
18
  > {
20
19
  /** Element to mount boxes. */