@netless/telebox-insider 0.3.0-beta.8 → 0.3.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
@@ -284,7 +284,9 @@ declare enum TELE_BOX_EVENT {
284
284
  Readonly = "readonly",
285
285
  Destroyed = "destroyed",
286
286
  BoxStatus = "box_status",
287
- LastNotMinimizedBoxStatus = "last_not_minimized_box_status"
287
+ LastNotMinimizedBoxStatus = "last_not_minimized_box_status",
288
+ ForceTop = "force_top",
289
+ ForceNormal = "force_normal"
288
290
  }
289
291
  declare enum TELE_BOX_DELEGATE_EVENT {
290
292
  Close = "close",
@@ -381,6 +383,12 @@ interface TeleBoxConfig {
381
383
  readonly boxStatus?: TeleBoxState;
382
384
  /** Last not minimized box status. */
383
385
  readonly lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
386
+ /** Force top. */
387
+ readonly forceTop?: boolean;
388
+ /** Force normal. */
389
+ readonly forceNormal?: boolean;
390
+ /** Is drag content. */
391
+ readonly isDragContent?: boolean;
384
392
  }
385
393
  type CheckTeleBoxConfig<T extends Record<`${TELE_BOX_EVENT}`, any>> = T;
386
394
  type TeleBoxEventConfig = CheckTeleBoxConfig<{
@@ -423,6 +431,8 @@ type TeleBoxEventConfig = CheckTeleBoxConfig<{
423
431
  id: string;
424
432
  lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
425
433
  };
434
+ force_normal: boolean;
435
+ force_top: boolean;
426
436
  }>;
427
437
  type TeleBoxEvent = keyof TeleBoxEventConfig;
428
438
  interface TeleBoxEvents extends EventEmitter<TeleBoxEvent> {
@@ -460,10 +470,13 @@ interface TeleTitleBarConfig {
460
470
  title?: string;
461
471
  state?: TeleBoxState;
462
472
  namespace?: string;
473
+ forceTop?: boolean;
474
+ forceNormal?: boolean;
463
475
  onEvent?: (event: TeleTitleBarEvent) => void;
464
476
  onDragStart?: (event: MouseEvent | TouchEvent) => void;
465
477
  }
466
478
  interface TeleTitleBar {
479
+ readonly $dragArea: HTMLElement;
467
480
  setTitle(title: string): void;
468
481
  setState(state: TeleBoxState): void;
469
482
  setReadonly(readonly: boolean): void;
@@ -482,11 +495,13 @@ interface DefaultTitleBarConfig extends TeleTitleBarConfig {
482
495
  }
483
496
  declare class DefaultTitleBar implements TeleTitleBar {
484
497
  protected boxStatus?: TeleBoxState;
485
- constructor({ readonly, title, buttons, onEvent, onDragStart, namespace, state, boxStatus, }?: DefaultTitleBarConfig);
498
+ protected forceTop?: boolean;
499
+ protected forceNormal?: boolean;
500
+ constructor({ readonly, title, buttons, onEvent, onDragStart, namespace, state, boxStatus, forceTop, forceNormal, }?: DefaultTitleBarConfig);
486
501
  readonly namespace: string;
487
502
  $titleBar: HTMLElement | undefined;
488
503
  $title: HTMLElement | undefined;
489
- $dragArea: HTMLElement;
504
+ readonly $dragArea: HTMLElement;
490
505
  setTitle(title: string): void;
491
506
  setState(state: TeleBoxState): void;
492
507
  setBoxStatus(boxStatus?: TeleBoxState): void;
@@ -546,11 +561,17 @@ type ValConfig$1 = {
546
561
  $userContent: Val<HTMLElement | undefined>;
547
562
  $userFooter: Val<HTMLElement | undefined>;
548
563
  $userStyles: Val<HTMLStyleElement | undefined>;
564
+ /** Force top. */
565
+ forceTop: Val<boolean, boolean>;
566
+ /** Force normal. */
567
+ forceNormal: Val<boolean, boolean>;
568
+ /** Drag content. */
569
+ isDragContent: Val<boolean, boolean>;
549
570
  };
550
571
  interface TeleBox extends ValEnhancedResult<ValConfig$1> {
551
572
  }
552
573
  declare class TeleBox {
553
- constructor({ id, title, prefersColorScheme, darkMode, visible, width, height, minWidth, minHeight, x, y, minimized, maximized, readonly, resizable, draggable, fence, fixRatio, focus, zIndex, namespace, titleBar, content, footer, styles, containerRect, collectorRect, boxStatus, lastNotMinimizedBoxStatus }?: TeleBoxConfig);
574
+ constructor({ id, title, prefersColorScheme, darkMode, visible, width, height, minWidth, minHeight, x, y, minimized, maximized, readonly, resizable, draggable, fence, fixRatio, focus, zIndex, namespace, titleBar, content, footer, styles, containerRect, collectorRect, boxStatus, lastNotMinimizedBoxStatus, forceTop, forceNormal, isDragContent, }?: TeleBoxConfig);
554
575
  readonly id: string;
555
576
  /** ClassName Prefix. For CSS styling. Default "telebox" */
556
577
  readonly namespace: string;
@@ -703,6 +724,7 @@ interface TeleBoxCollectorConfig {
703
724
  getBoxesStatus?: () => Map<string, TeleBoxState>;
704
725
  }
705
726
  declare class TeleBoxCollector {
727
+ static readonly kind = "TeleBoxCollector";
706
728
  getBoxesStatus?: () => Map<string, TeleBoxState>;
707
729
  constructor({ visible, readonly, darkMode, namespace, styles, onClick, getBoxesStatus }: TeleBoxCollectorConfig);
708
730
  get boxesStatus(): Map<string, TeleBoxState> | undefined;
@@ -722,7 +744,7 @@ declare class TeleBoxCollector {
722
744
  * Unmount collector from the root element.
723
745
  */
724
746
  unmount(): this;
725
- private hasMinimizedBox;
747
+ protected hasMinimizedBox(): boolean;
726
748
  updateBoxesStatus(): void;
727
749
  setVisible(visible: boolean): this;
728
750
  setReadonly(readonly: boolean): this;
@@ -765,7 +787,7 @@ interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "prefersColorScheme"
765
787
  /** Whether to use boxes status. */
766
788
  useBoxesStatus?: boolean;
767
789
  }
768
- type TeleBoxManagerBoxConfigBaseProps = "title" | "visible" | "width" | "height" | "minWidth" | "minHeight" | "x" | "y" | "resizable" | "draggable" | "fixRatio" | "zIndex" | "boxStatus" | "lastNotMinimizedBoxStatus";
790
+ type TeleBoxManagerBoxConfigBaseProps = "title" | "visible" | "width" | "height" | "minWidth" | "minHeight" | "x" | "y" | "resizable" | "draggable" | "fixRatio" | "zIndex" | "boxStatus" | "lastNotMinimizedBoxStatus" | "forceTop" | "forceNormal" | "isDragContent";
769
791
  type TeleBoxManagerCreateConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "content" | "footer" | "id" | "focus">;
770
792
  type TeleBoxManagerQueryConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "id" | "focus">;
771
793
  type TeleBoxManagerUpdateConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "content" | "footer">;
@@ -803,7 +825,7 @@ interface TeleBoxManagerEvents extends EventEmitter<TeleBoxManagerEvent> {
803
825
  emit<U extends TeleBoxManagerEvent>(event: U, ...value: TeleBoxManagerEventConfig[U]): boolean;
804
826
  }
805
827
 
806
- type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box">;
828
+ type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box" | "forceTop" | "forceNormal">;
807
829
  interface MaxTitleBarConfig extends DefaultTitleBarConfig {
808
830
  darkMode: boolean;
809
831
  boxes: MaxTitleBarTeleBox[];
@@ -885,15 +907,27 @@ type ValConfig = {
885
907
  interface TeleBoxManager extends ValEnhancedResult<ValConfig> {
886
908
  }
887
909
  declare class TeleBoxManager {
888
- private boxesStatus$;
889
- private lastNotMinimizedBoxesStatus$;
890
- private appMenu;
891
- private useBoxesStatus;
892
- private effectBoxesStatusTimer?;
893
- private effectLastNotMinimizedBoxStatusTimer?;
910
+ static readonly kind = "TeleBoxManager";
911
+ protected boxesStatus$: Map<string, TeleBoxState>;
912
+ protected lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
913
+ protected appMenu: AppMenu | undefined;
914
+ protected useBoxesStatus: boolean;
915
+ protected effectBoxesStatusTimer?: {
916
+ skipUpdate: boolean;
917
+ timer: number | undefined;
918
+ resolve?: (skipUpdate: boolean) => void;
919
+ };
920
+ protected effectLastNotMinimizedBoxStatusTimer?: {
921
+ skipUpdate: boolean;
922
+ timer: number | undefined;
923
+ resolve?: (skipUpdate: boolean) => void;
924
+ };
894
925
  constructor({ root, prefersColorScheme, minimized, maximized, fence, containerRect, collector, namespace, readonly, useBoxesStatus, }?: TeleBoxManagerConfig);
895
926
  get boxes(): ReadonlyArray<TeleBox>;
896
927
  get topBox(): TeleBox | undefined;
928
+ get forceTopBoxes(): TeleBox | undefined;
929
+ get maxForceTopBox(): TeleBox | undefined;
930
+ get forceNormalBoxes(): TeleBox | undefined;
897
931
  readonly events: TeleBoxManagerEvents;
898
932
  protected _sideEffect: SideEffectManager;
899
933
  protected root: HTMLElement;
@@ -912,8 +946,8 @@ declare class TeleBoxManager {
912
946
  get lastNotMinimizedBoxesStatus(): ReadonlyMap<string, NotMinimizedBoxState>;
913
947
  setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate?: boolean): void;
914
948
  getBoxesStatus(): Map<string, TeleBoxState>;
915
- private effectBoxStatusChange;
916
- private effectBoxesStatusTimerFunc;
949
+ protected effectBoxStatusChange(): void;
950
+ protected effectBoxesStatusTimerFunc(skipUpdate: boolean): void;
917
951
  effectBoxesStatusChange(skipUpdate?: boolean): Promise<void>;
918
952
  hasBoxesStatus(): boolean;
919
953
  hasMinimizedBox(): boolean;
@@ -924,13 +958,16 @@ declare class TeleBoxManager {
924
958
  getLastNotMinimizedBoxStatus(boxId: string): NotMinimizedBoxState | undefined;
925
959
  setLastNotMinimizedBoxStatus(boxId: string, lastNotMinimizedBoxStatus?: NotMinimizedBoxState, skipUpdate?: boolean): void;
926
960
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus: Map<string, NotMinimizedBoxState>, skipUpdate?: boolean): void;
927
- private effectLastNotMinimizedBoxStatusChange;
928
- private effectLastNotMinimizedBoxStatusFunc;
929
- private getUnabledBoxesStatusZIndex;
961
+ protected effectLastNotMinimizedBoxStatusChange(skipUpdate?: boolean): Promise<void>;
962
+ protected effectLastNotMinimizedBoxStatusFunc(skipUpdate?: boolean): void;
963
+ protected getUnabledBoxesStatusZIndex(): number;
930
964
  /** Maximized box zIndex range: 100-299 */
931
965
  getMaxMaximizedBoxZIndex(): number;
932
966
  /** normal box zIndex range: 300-499 */
933
967
  getMaxNormalBoxZIndex(): number;
968
+ getMaxForceTopBoxZIndex(): number;
969
+ isForceNormal(box: TeleBox): boolean;
970
+ isForceTop(box: TeleBox): boolean;
934
971
  create(config?: TeleBoxManagerCreateConfig, smartPosition?: boolean): ReadonlyTeleBox;
935
972
  query(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox[];
936
973
  queryOne(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox | undefined;
@@ -957,7 +994,7 @@ declare class TeleBoxManager {
957
994
  protected updateBox(box: TeleBox, config: TeleBoxManagerUpdateConfig, skipUpdate?: boolean): void;
958
995
  protected smartPosition(config?: TeleBoxConfig): TeleBoxConfig;
959
996
  protected makeBoxTop(box: TeleBox, skipUpdate?: boolean): void;
960
- private getMaximizedTopBox;
997
+ protected getMaximizedTopBox(): MaxTitleBarTeleBox | undefined;
961
998
  protected makeMaximizedTopBoxFocus(): void;
962
999
  protected getBoxIndex(boxOrID: TeleBox | string): number;
963
1000
  getBox(boxOrID: TeleBox | string): TeleBox | undefined;
package/dist/style.css CHANGED
@@ -408,7 +408,7 @@
408
408
  position: absolute;
409
409
  top: 0;
410
410
  left: 0;
411
- z-index: 1000;
411
+ z-index: 299;
412
412
  }
413
413
  .telebox-max-titlebar .telebox-title {
414
414
  display: none;
@@ -1185,6 +1185,8 @@ var TELE_BOX_EVENT = /* @__PURE__ */ ((TELE_BOX_EVENT2) => {
1185
1185
  TELE_BOX_EVENT2["Destroyed"] = "destroyed";
1186
1186
  TELE_BOX_EVENT2["BoxStatus"] = "box_status";
1187
1187
  TELE_BOX_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
1188
+ TELE_BOX_EVENT2["ForceTop"] = "force_top";
1189
+ TELE_BOX_EVENT2["ForceNormal"] = "force_normal";
1188
1190
  return TELE_BOX_EVENT2;
1189
1191
  })(TELE_BOX_EVENT || {});
1190
1192
  var TELE_BOX_DELEGATE_EVENT = /* @__PURE__ */ ((TELE_BOX_DELEGATE_EVENT2) => {
@@ -1239,7 +1241,9 @@ class DefaultTitleBar {
1239
1241
  onDragStart,
1240
1242
  namespace = "telebox",
1241
1243
  state = TELE_BOX_STATE.Normal,
1242
- boxStatus
1244
+ boxStatus,
1245
+ forceTop = false,
1246
+ forceNormal = false
1243
1247
  } = {}) {
1244
1248
  this.$btns = [];
1245
1249
  this.sideEffect = new o();
@@ -1313,7 +1317,14 @@ class DefaultTitleBar {
1313
1317
  this.title = title;
1314
1318
  this.state = state;
1315
1319
  this.boxStatus = boxStatus;
1316
- this.buttons = buttons || [
1320
+ this.forceTop = forceTop;
1321
+ this.forceNormal = forceNormal;
1322
+ this.buttons = buttons || (forceNormal ? [
1323
+ {
1324
+ type: TELE_BOX_DELEGATE_EVENT.Close,
1325
+ iconClassName: this.wrapClassName("titlebar-icon-close")
1326
+ }
1327
+ ] : [
1317
1328
  {
1318
1329
  type: TELE_BOX_DELEGATE_EVENT.Minimize,
1319
1330
  iconClassName: this.wrapClassName("titlebar-icon-minimize")
@@ -1327,7 +1338,7 @@ class DefaultTitleBar {
1327
1338
  type: TELE_BOX_DELEGATE_EVENT.Close,
1328
1339
  iconClassName: this.wrapClassName("titlebar-icon-close")
1329
1340
  }
1330
- ];
1341
+ ]);
1331
1342
  this.$dragArea = this.renderDragArea();
1332
1343
  }
1333
1344
  setTitle(title) {
@@ -1500,7 +1511,10 @@ class TeleBox {
1500
1511
  },
1501
1512
  collectorRect,
1502
1513
  boxStatus,
1503
- lastNotMinimizedBoxStatus
1514
+ lastNotMinimizedBoxStatus,
1515
+ forceTop = false,
1516
+ forceNormal = false,
1517
+ isDragContent = false
1504
1518
  } = {}) {
1505
1519
  this._renderSideEffect = new o();
1506
1520
  this.handleTrackStart = (ev) => {
@@ -1567,6 +1581,19 @@ class TeleBox {
1567
1581
  });
1568
1582
  const containerRect$ = createVal(containerRect, shallowequal);
1569
1583
  const collectorRect$ = createVal(collectorRect, shallowequal);
1584
+ const forceTop$ = createVal(forceTop);
1585
+ forceTop$.reaction((forceTop2, _, skipUpdate) => {
1586
+ if (!skipUpdate) {
1587
+ this.events.emit(TELE_BOX_EVENT.ForceTop, forceTop2 || false);
1588
+ }
1589
+ });
1590
+ const forceNormal$ = createVal(forceNormal);
1591
+ forceNormal$.reaction((forceNormal2, _, skipUpdate) => {
1592
+ if (!skipUpdate) {
1593
+ this.events.emit(TELE_BOX_EVENT.ForceNormal, forceNormal2 || false);
1594
+ }
1595
+ });
1596
+ const isDragContent$ = createVal(isDragContent);
1570
1597
  const title$ = createVal(title);
1571
1598
  title$.reaction((title2, _, skipUpdate) => {
1572
1599
  if (!skipUpdate) {
@@ -1744,6 +1771,8 @@ class TeleBox {
1744
1771
  title: title$.value,
1745
1772
  namespace: this.namespace,
1746
1773
  boxStatus: boxStatus$.value,
1774
+ forceTop: forceTop$.value,
1775
+ forceNormal: forceNormal$.value,
1747
1776
  onDragStart: (event) => {
1748
1777
  var _a;
1749
1778
  return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
@@ -1807,7 +1836,10 @@ class TeleBox {
1807
1836
  maximized: maximized$,
1808
1837
  $userContent: $userContent$,
1809
1838
  $userFooter: $userFooter$,
1810
- $userStyles: $userStyles$
1839
+ $userStyles: $userStyles$,
1840
+ forceTop: forceTop$,
1841
+ forceNormal: forceNormal$,
1842
+ isDragContent: isDragContent$
1811
1843
  };
1812
1844
  i(this, valConfig);
1813
1845
  this._state$ = state$;
@@ -2144,6 +2176,9 @@ class TeleBox {
2144
2176
  const $content = document.createElement("div");
2145
2177
  $content.className = this.wrapClassName("content") + " tele-fancy-scrollbar";
2146
2178
  this.$content = $content;
2179
+ if (this.isDragContent) {
2180
+ this.$content.appendChild(this.titleBar.$dragArea);
2181
+ }
2147
2182
  this._renderSideEffect.add(() => {
2148
2183
  let last$userStyles;
2149
2184
  return this._$userStyles$.subscribe(($userStyles) => {
@@ -2573,6 +2608,7 @@ class TeleBoxCollector {
2573
2608
  return `${this.namespace}-${className}`;
2574
2609
  }
2575
2610
  }
2611
+ TeleBoxCollector.kind = "TeleBoxCollector";
2576
2612
  var TELE_BOX_MANAGER_EVENT = /* @__PURE__ */ ((TELE_BOX_MANAGER_EVENT2) => {
2577
2613
  TELE_BOX_MANAGER_EVENT2["Focused"] = "focused";
2578
2614
  TELE_BOX_MANAGER_EVENT2["Blurred"] = "blurred";
@@ -2621,7 +2657,7 @@ class MaxTitleBar extends DefaultTitleBar {
2621
2657
  if (this.getBoxesStatus) {
2622
2658
  const boxesStatus = this.getBoxesStatus();
2623
2659
  if (boxesStatus) {
2624
- return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
2660
+ return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized && !box.forceTop);
2625
2661
  }
2626
2662
  }
2627
2663
  return [];
@@ -2900,7 +2936,6 @@ class AppMenu {
2900
2936
  createMinimizedItem(appId) {
2901
2937
  const appItem = document.createElement("div");
2902
2938
  appItem.classList.add(this.c("app-menu-item"));
2903
- console.log("appId=====>", appId);
2904
2939
  appItem.setAttribute(`data-${this.c("app-id")}`, appId);
2905
2940
  const titleDiv = document.createElement("div");
2906
2941
  titleDiv.classList.add(this.c("app-menu-item-title"));
@@ -2962,9 +2997,11 @@ class TeleBoxManager {
2962
2997
  this.boxes$ = createVal([]);
2963
2998
  this.topBox$ = this.boxes$.derive((boxes) => {
2964
2999
  if (boxes.length > 0) {
2965
- console.log("topBox===>topBox$===>000");
2966
3000
  let currentTopBox = void 0;
2967
3001
  const topBox = boxes.reduce((topBox2, box) => {
3002
+ if (box.forceTop) {
3003
+ return topBox2;
3004
+ }
2968
3005
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
2969
3006
  return topBox2;
2970
3007
  }
@@ -2974,7 +3011,6 @@ class TeleBoxManager {
2974
3011
  }
2975
3012
  return topBox2.zIndex > box.zIndex ? topBox2 : box;
2976
3013
  }, currentTopBox);
2977
- console.log("topBox===>topBox$===>end", topBox == null ? void 0 : topBox.id);
2978
3014
  return topBox;
2979
3015
  }
2980
3016
  return;
@@ -3171,7 +3207,6 @@ class TeleBoxManager {
3171
3207
  this.makeMaximizedTopBoxFocus();
3172
3208
  }
3173
3209
  }
3174
- console.log("checkFocusBox===>", box.id);
3175
3210
  this.focusBox(box);
3176
3211
  return;
3177
3212
  }
@@ -3234,7 +3269,7 @@ class TeleBoxManager {
3234
3269
  const box = this.getBox(targetBox.id);
3235
3270
  if (box) {
3236
3271
  let isFocusChanged = false;
3237
- if (this.topBox === box) {
3272
+ if (box.focus) {
3238
3273
  this.blurBox(box);
3239
3274
  isFocusChanged = true;
3240
3275
  }
@@ -3264,7 +3299,7 @@ class TeleBoxManager {
3264
3299
  const box = this.getBox(targetBox.id);
3265
3300
  if (box) {
3266
3301
  let isFocusChanged = false;
3267
- if (this.topBox === box) {
3302
+ if (box.focus) {
3268
3303
  this.blurBox(box);
3269
3304
  isFocusChanged = true;
3270
3305
  }
@@ -3317,6 +3352,21 @@ class TeleBoxManager {
3317
3352
  get topBox() {
3318
3353
  return this.topBox$.value;
3319
3354
  }
3355
+ get forceTopBoxes() {
3356
+ return this.boxes.find((box) => box.forceTop);
3357
+ }
3358
+ get maxForceTopBox() {
3359
+ return this.boxes.reduce((maxTopBox, box) => {
3360
+ var _a;
3361
+ if (box.forceTop && box.zIndex > ((_a = maxTopBox == null ? void 0 : maxTopBox.zIndex) != null ? _a : 0)) {
3362
+ return box;
3363
+ }
3364
+ return maxTopBox;
3365
+ }, void 0);
3366
+ }
3367
+ get forceNormalBoxes() {
3368
+ return this.boxes.find((box) => box.forceNormal);
3369
+ }
3320
3370
  get darkMode() {
3321
3371
  return this._darkMode$.value;
3322
3372
  }
@@ -3403,7 +3453,7 @@ class TeleBoxManager {
3403
3453
  var _a;
3404
3454
  const boxStatus = this.boxesStatus$.get(box.id);
3405
3455
  if (boxStatus) {
3406
- if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > ((_a = newTopBox == null ? void 0 : newTopBox.zIndex) != null ? _a : 0)) {
3456
+ if (boxStatus !== TELE_BOX_STATE.Minimized && !this.isForceTop(box) && box.zIndex > ((_a = newTopBox == null ? void 0 : newTopBox.zIndex) != null ? _a : 0)) {
3407
3457
  newTopBox = box;
3408
3458
  }
3409
3459
  box.setBoxStatus(boxStatus, skipUpdate);
@@ -3412,15 +3462,13 @@ class TeleBoxManager {
3412
3462
  this.effectBoxStatusChange();
3413
3463
  if (newTopBox && curTopBox !== newTopBox) {
3414
3464
  this.topBox$.setValue(newTopBox);
3415
- this.focusBox(newTopBox, skipUpdate);
3416
3465
  }
3417
3466
  if (!newTopBox && curTopBox) {
3418
3467
  this.topBox$.setValue(void 0);
3419
- this.blurBox(curTopBox, skipUpdate);
3420
3468
  }
3421
3469
  }
3422
3470
  async effectBoxesStatusChange(skipUpdate = false) {
3423
- var _a, _b, _c, _d, _e, _f;
3471
+ var _a, _b;
3424
3472
  if (!this.useBoxesStatus) {
3425
3473
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3426
3474
  clearTimeout(this.effectBoxesStatusTimer.timer);
@@ -3435,11 +3483,9 @@ class TeleBoxManager {
3435
3483
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3436
3484
  clearTimeout(this.effectBoxesStatusTimer.timer);
3437
3485
  if (this.effectBoxesStatusTimer.resolve) {
3438
- console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
3439
3486
  this.effectBoxesStatusTimer.resolve(!!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate));
3440
3487
  }
3441
3488
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3442
- console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
3443
3489
  } else {
3444
3490
  return;
3445
3491
  }
@@ -3455,17 +3501,13 @@ class TeleBoxManager {
3455
3501
  const _skipUpdate = await new Promise((resolve) => {
3456
3502
  this.effectBoxesStatusTimer.resolve = resolve;
3457
3503
  this.effectBoxesStatusTimer.timer = setTimeout(() => {
3458
- var _a2, _b2;
3459
3504
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3460
- console.log("effectBoxStatusTimerFunc===>000", skipUpdate, { id: (_a2 = this.topBox$.value) == null ? void 0 : _a2.id, zIndex: (_b2 = this.topBox$.value) == null ? void 0 : _b2.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3461
3505
  this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3462
3506
  }
3463
3507
  }, 100);
3464
3508
  });
3465
- console.log("effectBoxStatusTimerFunc===>000==>00", skipUpdate, { id: (_c = this.topBox$.value) == null ? void 0 : _c.id, zIndex: (_d = this.topBox$.value) == null ? void 0 : _d.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3466
3509
  this.effectBoxesStatusTimerFunc(_skipUpdate);
3467
3510
  this.effectBoxesStatusTimer = void 0;
3468
- console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, { id: (_e = this.topBox$.value) == null ? void 0 : _e.id, zIndex: (_f = this.topBox$.value) == null ? void 0 : _f.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
3469
3511
  }
3470
3512
  }
3471
3513
  hasBoxesStatus() {
@@ -3549,11 +3591,9 @@ class TeleBoxManager {
3549
3591
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3550
3592
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3551
3593
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3552
- console.log("effectLastNotMinimizedBoxStatusFunc===>1111", skipUpdate);
3553
3594
  this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate));
3554
3595
  }
3555
3596
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3556
- console.log("effectLastNotMinimizedBoxStatusFunc===>2222", skipUpdate);
3557
3597
  } else {
3558
3598
  return;
3559
3599
  }
@@ -3570,22 +3610,18 @@ class TeleBoxManager {
3570
3610
  this.effectLastNotMinimizedBoxStatusTimer.resolve = resolve;
3571
3611
  this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(() => {
3572
3612
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3573
- console.log("effectLastNotMinimizedBoxStatusTimer===>000", skipUpdate);
3574
3613
  this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate);
3575
3614
  }
3576
3615
  }, 100);
3577
3616
  });
3578
- 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 })));
3579
3617
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3580
3618
  this.effectLastNotMinimizedBoxStatusTimer = void 0;
3581
- 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 })));
3582
3619
  }
3583
3620
  }
3584
3621
  effectLastNotMinimizedBoxStatusFunc(skipUpdate = false) {
3585
3622
  if (!this.useBoxesStatus) {
3586
3623
  return;
3587
3624
  }
3588
- console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
3589
3625
  this.boxes.forEach((box) => {
3590
3626
  const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
3591
3627
  if (boxStatus) {
@@ -3601,7 +3637,7 @@ class TeleBoxManager {
3601
3637
  return this.getUnabledBoxesStatusZIndex();
3602
3638
  }
3603
3639
  return this.boxes.reduce((maxZIndex, box) => {
3604
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3640
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized && !this.isForceTop(box)) {
3605
3641
  return Math.max(maxZIndex, box.zIndex);
3606
3642
  }
3607
3643
  return maxZIndex;
@@ -3612,17 +3648,32 @@ class TeleBoxManager {
3612
3648
  return this.getUnabledBoxesStatusZIndex();
3613
3649
  }
3614
3650
  return this.boxes.reduce((maxZIndex, box) => {
3615
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3651
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceTop(box)) {
3616
3652
  return Math.max(maxZIndex, box.zIndex);
3617
3653
  }
3618
3654
  return maxZIndex;
3619
3655
  }, 299);
3620
3656
  }
3657
+ getMaxForceTopBoxZIndex() {
3658
+ if (!this.useBoxesStatus) {
3659
+ return this.getUnabledBoxesStatusZIndex();
3660
+ }
3661
+ return this.boxes.reduce((maxZIndex, box) => {
3662
+ if (box.boxStatus && this.isForceTop(box)) {
3663
+ return Math.max(maxZIndex, box.zIndex);
3664
+ }
3665
+ return maxZIndex;
3666
+ }, 699);
3667
+ }
3668
+ isForceNormal(box) {
3669
+ return box._forceNormal$.value;
3670
+ }
3671
+ isForceTop(box) {
3672
+ return box._forceTop$.value;
3673
+ }
3621
3674
  create(config = {}, smartPosition = true) {
3622
- var _a;
3623
- console.log("create===>", config, (_a = this.topBox) == null ? void 0 : _a.zIndex);
3624
3675
  const box = new TeleBox({
3625
- zIndex: this.getMaxNormalBoxZIndex() + 1,
3676
+ zIndex: config.forceTop ? this.getMaxForceTopBoxZIndex() + 1 : this.getMaxNormalBoxZIndex() + 1,
3626
3677
  ...smartPosition ? this.smartPosition(config) : config,
3627
3678
  darkMode: this.darkMode,
3628
3679
  prefersColorScheme: this.prefersColorScheme,
@@ -3650,15 +3701,17 @@ class TeleBoxManager {
3650
3701
  }
3651
3702
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
3652
3703
  if (this.useBoxesStatus && box.boxStatus) {
3704
+ if (box._forceNormal$.value) {
3705
+ return;
3706
+ }
3653
3707
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
3654
3708
  this.setBox(box.id, {
3655
3709
  status: TELE_BOX_STATE.Normal,
3656
3710
  zIndex: this.getMaxNormalBoxZIndex() + 1
3657
3711
  }, false);
3658
3712
  } else {
3659
- [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3713
+ [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box2)).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3660
3714
  if (box2.boxStatus === TELE_BOX_STATE.Normal) {
3661
- console.log("maximized===>", box2.id);
3662
3715
  this.setBox(box2.id, {
3663
3716
  status: TELE_BOX_STATE.Maximized,
3664
3717
  zIndex: this.getMaxMaximizedBoxZIndex() + 1
@@ -3672,12 +3725,12 @@ class TeleBoxManager {
3672
3725
  }
3673
3726
  });
3674
3727
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
3675
- var _a2;
3676
3728
  if (box.boxStatus && this.useBoxesStatus) {
3677
- if (this.topBox === box) {
3678
- if ((_a2 = this.topBox) == null ? void 0 : _a2.focus) {
3679
- this.blurBox(this.topBox);
3680
- }
3729
+ if (box._forceNormal$.value) {
3730
+ return;
3731
+ }
3732
+ if (box.focus) {
3733
+ this.blurBox(box);
3681
3734
  }
3682
3735
  this.setBox(box, {
3683
3736
  status: TELE_BOX_STATE.Minimized,
@@ -3690,6 +3743,9 @@ class TeleBoxManager {
3690
3743
  }
3691
3744
  });
3692
3745
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
3746
+ if (this.useBoxesStatus && box.focus) {
3747
+ this.blurBox(box);
3748
+ }
3693
3749
  this.remove(box);
3694
3750
  this.focusTopBox();
3695
3751
  });
@@ -3720,9 +3776,11 @@ class TeleBoxManager {
3720
3776
  });
3721
3777
  box._zIndex$.reaction((_, __, skipUpdate) => {
3722
3778
  if (this.boxes.length > 0) {
3723
- console.log("topBox===>_zIndex", this.boxes.map((box2) => ({ id: box2.id, zIndex: box2.zIndex, boxStatus: box2.boxStatus })));
3724
3779
  let currentTopBox = void 0;
3725
3780
  const topBox = this.boxes.reduce((topBox2, box2) => {
3781
+ if (this.isForceTop(box2)) {
3782
+ return topBox2;
3783
+ }
3726
3784
  if (box2.boxStatus && box2.boxStatus === TELE_BOX_STATE.Minimized) {
3727
3785
  return topBox2;
3728
3786
  }
@@ -3732,7 +3790,6 @@ class TeleBoxManager {
3732
3790
  }
3733
3791
  return topBox2.zIndex > box2.zIndex ? topBox2 : box2;
3734
3792
  }, currentTopBox);
3735
- console.log("topBox===>_zIndex===>end", topBox == null ? void 0 : topBox.id);
3736
3793
  this.topBox$.setValue(topBox);
3737
3794
  }
3738
3795
  if (!skipUpdate) {
@@ -3953,13 +4010,27 @@ class TeleBoxManager {
3953
4010
  lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
3954
4011
  }, skipUpdate);
3955
4012
  }
4013
+ if (config.forceTop != null) {
4014
+ box.setForceTop(config.forceTop, skipUpdate);
4015
+ }
4016
+ if (config.forceNormal != null) {
4017
+ box.setForceNormal(config.forceNormal, skipUpdate);
4018
+ }
3956
4019
  }
3957
4020
  smartPosition(config = {}) {
3958
4021
  let { x, y } = config;
3959
4022
  const { width = 0.5, height = 0.5 } = config;
3960
4023
  if (x == null) {
3961
4024
  let vx = 20;
3962
- if (this.topBox) {
4025
+ if (config.forceTop) {
4026
+ const forceTopBox = this.maxForceTopBox || this.topBox;
4027
+ if (forceTopBox) {
4028
+ vx = forceTopBox.intrinsicX * this.containerRect.width + 20;
4029
+ if (vx > this.containerRect.width - width * this.containerRect.width) {
4030
+ vx = 20;
4031
+ }
4032
+ }
4033
+ } else if (this.topBox) {
3963
4034
  vx = this.topBox.intrinsicX * this.containerRect.width + 20;
3964
4035
  if (vx > this.containerRect.width - width * this.containerRect.width) {
3965
4036
  vx = 20;
@@ -3973,7 +4044,15 @@ class TeleBoxManager {
3973
4044
  }
3974
4045
  if (y == null) {
3975
4046
  let vy = 20;
3976
- if (this.topBox) {
4047
+ if (config.forceTop) {
4048
+ const forceTopBox = this.maxForceTopBox || this.topBox;
4049
+ if (forceTopBox) {
4050
+ vy = forceTopBox.intrinsicY * this.containerRect.height + 20;
4051
+ if (vy > this.containerRect.height - height * this.containerRect.height) {
4052
+ vy = 20;
4053
+ }
4054
+ }
4055
+ } else if (this.topBox) {
3977
4056
  vy = this.topBox.intrinsicY * this.containerRect.height + 20;
3978
4057
  if (vy > this.containerRect.height - height * this.containerRect.height) {
3979
4058
  vy = 20;
@@ -4015,9 +4094,7 @@ class TeleBoxManager {
4015
4094
  return;
4016
4095
  }
4017
4096
  const maximizedBox = this.getMaximizedTopBox();
4018
- console.log("makeMaximizedTopBoxFocus===>", maximizedBox == null ? void 0 : maximizedBox.id);
4019
4097
  this.maxTitleBar.focusBox(maximizedBox);
4020
- console.log("makeMaximizedTopBoxFocus===>end", maximizedBox == null ? void 0 : maximizedBox.id);
4021
4098
  }
4022
4099
  getBoxIndex(boxOrID) {
4023
4100
  return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
@@ -4040,6 +4117,7 @@ class TeleBoxManager {
4040
4117
  return;
4041
4118
  }
4042
4119
  }
4120
+ TeleBoxManager.kind = "TeleBoxManager";
4043
4121
  exports.DefaultTitleBar = DefaultTitleBar;
4044
4122
  exports.TELE_BOX_COLOR_SCHEME = TELE_BOX_COLOR_SCHEME;
4045
4123
  exports.TELE_BOX_DELEGATE_EVENT = TELE_BOX_DELEGATE_EVENT;