@netless/telebox-insider 0.3.1 → 0.3.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -996,8 +996,10 @@ declare class TeleBoxManager {
996
996
  destroy(skipUpdate?: boolean): void;
997
997
  wrapClassName(className: string): string;
998
998
  private lazyFocusRequestHandler?;
999
+ private closeRequestHandler?;
999
1000
  private committedFocusDepth;
1000
1001
  setLazyFocusRequestHandler(handler?: (boxId: string) => boolean): void;
1002
+ setCloseRequestHandler(handler?: (boxId: string) => boolean): void;
1001
1003
  focusBox(boxOrID: string | TeleBox, skipUpdate?: boolean): void;
1002
1004
  focusBoxCommitted(boxOrID: string | TeleBox, skipUpdate?: boolean): void;
1003
1005
  focusTopBox(): void;
@@ -3330,6 +3330,7 @@ class TeleBoxManager {
3330
3330
  return this.boxesStatus$;
3331
3331
  },
3332
3332
  onEvent: (event) => {
3333
+ var _a;
3333
3334
  switch (event.type) {
3334
3335
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
3335
3336
  if (forceMaximized$.value && this.state === TELE_BOX_STATE.Maximized) {
@@ -3396,13 +3397,16 @@ class TeleBoxManager {
3396
3397
  break;
3397
3398
  }
3398
3399
  case TELE_BOX_EVENT.Close: {
3400
+ const targetBox = this.hasBoxesStatus() ? this.maxTitleBar.focusedBox || this.getMaximizedTopBox() : this.topBox;
3401
+ if (targetBox && ((_a = this.closeRequestHandler) == null ? void 0 : _a.call(this, targetBox.id)))
3402
+ break;
3399
3403
  if (this.hasBoxesStatus()) {
3400
- let targetBox = this.maxTitleBar.focusedBox;
3401
- if (!targetBox) {
3402
- targetBox = this.getMaximizedTopBox();
3404
+ let targetBox2 = this.maxTitleBar.focusedBox;
3405
+ if (!targetBox2) {
3406
+ targetBox2 = this.getMaximizedTopBox();
3403
3407
  }
3404
- if (targetBox == null ? void 0 : targetBox.id) {
3405
- const box = this.getBox(targetBox.id);
3408
+ if (targetBox2 == null ? void 0 : targetBox2.id) {
3409
+ const box = this.getBox(targetBox2.id);
3406
3410
  if (box) {
3407
3411
  let isFocusChanged = false;
3408
3412
  if (box.focus) {
@@ -3929,6 +3933,9 @@ class TeleBoxManager {
3929
3933
  }
3930
3934
  });
3931
3935
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
3936
+ var _a;
3937
+ if ((_a = this.closeRequestHandler) == null ? void 0 : _a.call(this, box.id))
3938
+ return;
3932
3939
  if (this.useBoxesStatus && box.focus) {
3933
3940
  this.blurBox(box);
3934
3941
  }
@@ -4095,6 +4102,9 @@ class TeleBoxManager {
4095
4102
  setLazyFocusRequestHandler(handler) {
4096
4103
  this.lazyFocusRequestHandler = handler;
4097
4104
  }
4105
+ setCloseRequestHandler(handler) {
4106
+ this.closeRequestHandler = handler;
4107
+ }
4098
4108
  focusBox(boxOrID, skipUpdate = false) {
4099
4109
  var _a;
4100
4110
  const targetBox = this.getBox(boxOrID);