@netless/telebox-insider 0.3.0-beta.10 → 0.3.0-beta.12
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 +54 -19
- package/dist/telebox-insider.cjs.js +114 -13
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +114 -13
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/constants.ts +2 -0
- package/src/TeleBox/index.ts +34 -1
- package/src/TeleBox/typings.ts +8 -0
- package/src/TeleBoxCollector/index.ts +1 -1
- package/src/TeleBoxManager/MaxTitleBar/index.ts +2 -2
- package/src/TeleBoxManager/index.ts +98 -29
- package/src/TeleBoxManager/typings.ts +4 -1
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +26 -17
- package/src/TeleTitleBar/typings.ts +3 -0
package/package.json
CHANGED
package/src/TeleBox/constants.ts
CHANGED
package/src/TeleBox/index.ts
CHANGED
|
@@ -72,6 +72,12 @@ type ValConfig = {
|
|
|
72
72
|
$userContent: Val<HTMLElement | undefined>;
|
|
73
73
|
$userFooter: Val<HTMLElement | undefined>;
|
|
74
74
|
$userStyles: Val<HTMLStyleElement | undefined>;
|
|
75
|
+
/** Force top. */
|
|
76
|
+
forceTop: Val<boolean, boolean>;
|
|
77
|
+
/** Force normal. */
|
|
78
|
+
forceNormal: Val<boolean, boolean>;
|
|
79
|
+
/** Drag content. */
|
|
80
|
+
isDragContent: Val<boolean, boolean>;
|
|
75
81
|
};
|
|
76
82
|
export interface TeleBox extends ValEnhancedResult<ValConfig> {}
|
|
77
83
|
|
|
@@ -110,7 +116,10 @@ export class TeleBox {
|
|
|
110
116
|
},
|
|
111
117
|
collectorRect,
|
|
112
118
|
boxStatus,
|
|
113
|
-
lastNotMinimizedBoxStatus
|
|
119
|
+
lastNotMinimizedBoxStatus,
|
|
120
|
+
forceTop = false,
|
|
121
|
+
forceNormal = false,
|
|
122
|
+
isDragContent = false,
|
|
114
123
|
}: TeleBoxConfig = {}) {
|
|
115
124
|
this._sideEffect = new SideEffectManager();
|
|
116
125
|
this._valSideEffectBinder = createSideEffectBinder(this._sideEffect);
|
|
@@ -182,6 +191,21 @@ export class TeleBox {
|
|
|
182
191
|
const containerRect$ = createVal(containerRect, shallowequal);
|
|
183
192
|
const collectorRect$ = createVal(collectorRect, shallowequal);
|
|
184
193
|
|
|
194
|
+
const forceTop$ = createVal(forceTop);
|
|
195
|
+
forceTop$.reaction((forceTop, _, skipUpdate) => {
|
|
196
|
+
if (!skipUpdate) {
|
|
197
|
+
this.events.emit(TELE_BOX_EVENT.ForceTop, forceTop || false);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const forceNormal$ = createVal(forceNormal);
|
|
202
|
+
forceNormal$.reaction((forceNormal, _, skipUpdate) => {
|
|
203
|
+
if (!skipUpdate) {
|
|
204
|
+
this.events.emit(TELE_BOX_EVENT.ForceNormal, forceNormal || false);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const isDragContent$ = createVal(isDragContent);
|
|
208
|
+
|
|
185
209
|
const title$ = createVal(title);
|
|
186
210
|
title$.reaction((title, _, skipUpdate) => {
|
|
187
211
|
if (!skipUpdate) {
|
|
@@ -400,6 +424,8 @@ export class TeleBox {
|
|
|
400
424
|
title: title$.value,
|
|
401
425
|
namespace: this.namespace,
|
|
402
426
|
boxStatus: boxStatus$.value,
|
|
427
|
+
forceTop: forceTop$.value,
|
|
428
|
+
forceNormal: forceNormal$.value,
|
|
403
429
|
onDragStart: (event) => this._handleTrackStart?.(event),
|
|
404
430
|
onEvent: (event): void => {
|
|
405
431
|
if (this._delegateEvents.listeners.length > 0) {
|
|
@@ -463,6 +489,9 @@ export class TeleBox {
|
|
|
463
489
|
$userContent: $userContent$,
|
|
464
490
|
$userFooter: $userFooter$,
|
|
465
491
|
$userStyles: $userStyles$,
|
|
492
|
+
forceTop: forceTop$,
|
|
493
|
+
forceNormal: forceNormal$,
|
|
494
|
+
isDragContent: isDragContent$,
|
|
466
495
|
};
|
|
467
496
|
|
|
468
497
|
withValueEnhancer(this, valConfig);
|
|
@@ -989,6 +1018,7 @@ export class TeleBox {
|
|
|
989
1018
|
$titleBar.appendChild(this.titleBar.render());
|
|
990
1019
|
this.$titleBar = $titleBar;
|
|
991
1020
|
|
|
1021
|
+
|
|
992
1022
|
const $contentWrap = document.createElement("div");
|
|
993
1023
|
$contentWrap.className = this.wrapClassName("content-wrap");
|
|
994
1024
|
|
|
@@ -996,6 +1026,9 @@ export class TeleBox {
|
|
|
996
1026
|
$content.className =
|
|
997
1027
|
this.wrapClassName("content") + " tele-fancy-scrollbar";
|
|
998
1028
|
this.$content = $content;
|
|
1029
|
+
if (this.isDragContent) {
|
|
1030
|
+
this.$content.appendChild(this.titleBar.$dragArea);
|
|
1031
|
+
}
|
|
999
1032
|
|
|
1000
1033
|
this._renderSideEffect.add(() => {
|
|
1001
1034
|
let last$userStyles: HTMLStyleElement | undefined;
|
package/src/TeleBox/typings.ts
CHANGED
|
@@ -87,6 +87,12 @@ export interface TeleBoxConfig {
|
|
|
87
87
|
readonly boxStatus?: TeleBoxState;
|
|
88
88
|
/** Last not minimized box status. */
|
|
89
89
|
readonly lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
|
|
90
|
+
/** Force top. */
|
|
91
|
+
readonly forceTop?: boolean;
|
|
92
|
+
/** Force normal. */
|
|
93
|
+
readonly forceNormal?: boolean;
|
|
94
|
+
/** Is drag content. */
|
|
95
|
+
readonly isDragContent?: boolean;
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
type CheckTeleBoxConfig<T extends Record<`${TELE_BOX_EVENT}`, any>> = T;
|
|
@@ -110,6 +116,8 @@ export type TeleBoxEventConfig = CheckTeleBoxConfig<{
|
|
|
110
116
|
destroyed: void;
|
|
111
117
|
box_status: { id: string; boxStatus: TeleBoxState };
|
|
112
118
|
last_not_minimized_box_status: { id: string; lastNotMinimizedBoxStatus?: NotMinimizedBoxState };
|
|
119
|
+
force_normal: boolean;
|
|
120
|
+
force_top: boolean;
|
|
113
121
|
}>;
|
|
114
122
|
|
|
115
123
|
export type TeleBoxEvent = keyof TeleBoxEventConfig;
|
|
@@ -5,7 +5,7 @@ import { DefaultTitleBar, DefaultTitleBarConfig } from "../../TeleTitleBar";
|
|
|
5
5
|
import { TELE_BOX_STATE } from "../../TeleBox/constants";
|
|
6
6
|
import { TeleBoxRect, TeleBoxState } from "../../TeleBox/typings";
|
|
7
7
|
|
|
8
|
-
export type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box">;
|
|
8
|
+
export type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box" | "forceTop" | "forceNormal">;
|
|
9
9
|
|
|
10
10
|
export interface MaxTitleBarConfig extends DefaultTitleBarConfig {
|
|
11
11
|
darkMode: boolean;
|
|
@@ -45,7 +45,7 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
45
45
|
if (this.getBoxesStatus) {
|
|
46
46
|
const boxesStatus = this.getBoxesStatus();
|
|
47
47
|
if (boxesStatus) {
|
|
48
|
-
return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
|
|
48
|
+
return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized && !box.forceTop);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
return [];
|
|
@@ -48,16 +48,16 @@ type ValConfig = {
|
|
|
48
48
|
export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
|
|
49
49
|
|
|
50
50
|
export class TeleBoxManager {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
protected boxesStatus$: Map<string, TeleBoxState>;
|
|
52
|
+
protected lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
|
|
53
|
+
protected appMenu: AppMenu | undefined;
|
|
54
|
+
protected useBoxesStatus: boolean;
|
|
55
|
+
protected effectBoxesStatusTimer?: {
|
|
56
56
|
skipUpdate: boolean;
|
|
57
57
|
timer: number | undefined;
|
|
58
58
|
resolve?: (skipUpdate: boolean) => void;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
protected effectLastNotMinimizedBoxStatusTimer?: {
|
|
61
61
|
skipUpdate: boolean;
|
|
62
62
|
timer: number | undefined;
|
|
63
63
|
resolve?: (skipUpdate: boolean) => void;
|
|
@@ -92,6 +92,9 @@ export class TeleBoxManager {
|
|
|
92
92
|
if (boxes.length > 0) {
|
|
93
93
|
let currentTopBox: TeleBox | undefined = undefined;
|
|
94
94
|
const topBox = boxes.reduce((topBox, box) => {
|
|
95
|
+
if (box.forceTop) {
|
|
96
|
+
return topBox;
|
|
97
|
+
}
|
|
95
98
|
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
|
|
96
99
|
return topBox;
|
|
97
100
|
}
|
|
@@ -487,6 +490,23 @@ export class TeleBoxManager {
|
|
|
487
490
|
return this.topBox$.value;
|
|
488
491
|
}
|
|
489
492
|
|
|
493
|
+
public get forceTopBoxes(): TeleBox | undefined {
|
|
494
|
+
return this.boxes.find((box) => box.forceTop);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
public get maxForceTopBox(): TeleBox | undefined {
|
|
498
|
+
return this.boxes.reduce((maxTopBox, box) => {
|
|
499
|
+
if (box.forceTop && box.zIndex > (maxTopBox?.zIndex ?? 0)) {
|
|
500
|
+
return box;
|
|
501
|
+
}
|
|
502
|
+
return maxTopBox;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
public get forceNormalBoxes(): TeleBox | undefined {
|
|
507
|
+
return this.boxes.find((box) => box.forceNormal);
|
|
508
|
+
}
|
|
509
|
+
|
|
490
510
|
public readonly events = new EventEmitter() as TeleBoxManagerEvents;
|
|
491
511
|
|
|
492
512
|
protected _sideEffect: SideEffectManager;
|
|
@@ -572,7 +592,7 @@ export class TeleBoxManager {
|
|
|
572
592
|
return this.boxesStatus$;
|
|
573
593
|
}
|
|
574
594
|
|
|
575
|
-
|
|
595
|
+
protected effectBoxStatusChange(){
|
|
576
596
|
if (!this.useBoxesStatus) {
|
|
577
597
|
return;
|
|
578
598
|
}
|
|
@@ -590,7 +610,7 @@ export class TeleBoxManager {
|
|
|
590
610
|
}
|
|
591
611
|
}
|
|
592
612
|
|
|
593
|
-
|
|
613
|
+
protected effectBoxesStatusTimerFunc(skipUpdate: boolean){
|
|
594
614
|
if (!this.useBoxesStatus) {
|
|
595
615
|
return;
|
|
596
616
|
}
|
|
@@ -599,7 +619,7 @@ export class TeleBoxManager {
|
|
|
599
619
|
this.boxes.forEach((box) => {
|
|
600
620
|
const boxStatus = this.boxesStatus$.get(box.id);
|
|
601
621
|
if (boxStatus) {
|
|
602
|
-
if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (newTopBox?.zIndex ?? 0)) {
|
|
622
|
+
if (boxStatus !== TELE_BOX_STATE.Minimized && !this.isForceTop(box) && box.zIndex > (newTopBox?.zIndex ?? 0)) {
|
|
603
623
|
newTopBox = box;
|
|
604
624
|
}
|
|
605
625
|
box.setBoxStatus(boxStatus, skipUpdate);
|
|
@@ -734,7 +754,7 @@ export class TeleBoxManager {
|
|
|
734
754
|
this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
|
|
735
755
|
}
|
|
736
756
|
|
|
737
|
-
|
|
757
|
+
protected async effectLastNotMinimizedBoxStatusChange(skipUpdate = false): Promise<void> {
|
|
738
758
|
if (!this.useBoxesStatus) {
|
|
739
759
|
if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
|
|
740
760
|
clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
|
|
@@ -781,7 +801,7 @@ export class TeleBoxManager {
|
|
|
781
801
|
}
|
|
782
802
|
}
|
|
783
803
|
|
|
784
|
-
|
|
804
|
+
protected effectLastNotMinimizedBoxStatusFunc(skipUpdate = false){
|
|
785
805
|
if (!this.useBoxesStatus) {
|
|
786
806
|
return;
|
|
787
807
|
}
|
|
@@ -793,26 +813,17 @@ export class TeleBoxManager {
|
|
|
793
813
|
});
|
|
794
814
|
}
|
|
795
815
|
|
|
796
|
-
|
|
816
|
+
protected getUnabledBoxesStatusZIndex(): number {
|
|
797
817
|
return this.topBox ? this.topBox.zIndex : 99;
|
|
798
818
|
}
|
|
799
819
|
|
|
800
|
-
// private getTopBoxZIndex(): number {
|
|
801
|
-
// if (!this.useBoxesStatus) {
|
|
802
|
-
// return this.getUnabledBoxesStatusZIndex();
|
|
803
|
-
// }
|
|
804
|
-
// return [...this.boxes].filter((box) => box.boxStatus !== TELE_BOX_STATE.Minimized).reduce((maxZIndex, box) => {
|
|
805
|
-
// return Math.max(maxZIndex, box.zIndex);
|
|
806
|
-
// }, 100);
|
|
807
|
-
// }
|
|
808
|
-
|
|
809
820
|
/** Maximized box zIndex range: 100-299 */
|
|
810
821
|
public getMaxMaximizedBoxZIndex(): number {
|
|
811
822
|
if (!this.useBoxesStatus) {
|
|
812
823
|
return this.getUnabledBoxesStatusZIndex();
|
|
813
824
|
}
|
|
814
825
|
return this.boxes.reduce((maxZIndex, box) => {
|
|
815
|
-
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
|
|
826
|
+
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized && !this.isForceTop(box)) {
|
|
816
827
|
return Math.max(maxZIndex, box.zIndex);
|
|
817
828
|
}
|
|
818
829
|
return maxZIndex;
|
|
@@ -825,19 +836,39 @@ export class TeleBoxManager {
|
|
|
825
836
|
return this.getUnabledBoxesStatusZIndex();
|
|
826
837
|
}
|
|
827
838
|
return this.boxes.reduce((maxZIndex, box) => {
|
|
828
|
-
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
|
|
839
|
+
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceTop(box)) {
|
|
829
840
|
return Math.max(maxZIndex, box.zIndex);
|
|
830
841
|
}
|
|
831
842
|
return maxZIndex;
|
|
832
843
|
}, 299);
|
|
833
844
|
}
|
|
834
845
|
|
|
846
|
+
public getMaxForceTopBoxZIndex(): number {
|
|
847
|
+
if (!this.useBoxesStatus) {
|
|
848
|
+
return this.getUnabledBoxesStatusZIndex();
|
|
849
|
+
}
|
|
850
|
+
return this.boxes.reduce((maxZIndex, box) => {
|
|
851
|
+
if (box.boxStatus && this.isForceTop(box)) {
|
|
852
|
+
return Math.max(maxZIndex, box.zIndex);
|
|
853
|
+
}
|
|
854
|
+
return maxZIndex;
|
|
855
|
+
}, 699);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
public isForceNormal(box: TeleBox): boolean {
|
|
859
|
+
return box._forceNormal$.value;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
public isForceTop(box: TeleBox): boolean {
|
|
863
|
+
return box._forceTop$.value;
|
|
864
|
+
}
|
|
865
|
+
|
|
835
866
|
public create(
|
|
836
867
|
config: TeleBoxManagerCreateConfig = {},
|
|
837
868
|
smartPosition = true
|
|
838
869
|
): ReadonlyTeleBox {
|
|
839
870
|
const box = new TeleBox({
|
|
840
|
-
zIndex: this.getMaxNormalBoxZIndex() + 1,
|
|
871
|
+
zIndex: config.forceTop ? this.getMaxForceTopBoxZIndex() + 1 : this.getMaxNormalBoxZIndex() + 1,
|
|
841
872
|
...(smartPosition ? this.smartPosition(config) : config),
|
|
842
873
|
darkMode: this.darkMode,
|
|
843
874
|
prefersColorScheme: this.prefersColorScheme,
|
|
@@ -870,6 +901,9 @@ export class TeleBoxManager {
|
|
|
870
901
|
|
|
871
902
|
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
|
|
872
903
|
if (this.useBoxesStatus && box.boxStatus) {
|
|
904
|
+
if (box._forceNormal$.value) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
873
907
|
if (box.boxStatus === TELE_BOX_STATE.Maximized) {
|
|
874
908
|
this.setBox(box.id, {
|
|
875
909
|
status: TELE_BOX_STATE.Normal,
|
|
@@ -877,7 +911,7 @@ export class TeleBoxManager {
|
|
|
877
911
|
}, false);
|
|
878
912
|
} else {
|
|
879
913
|
// 所有normal box都最大化
|
|
880
|
-
[...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
|
|
914
|
+
[...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box)).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
|
|
881
915
|
if (box.boxStatus === TELE_BOX_STATE.Normal) {
|
|
882
916
|
this.setBox(box.id, {
|
|
883
917
|
status: TELE_BOX_STATE.Maximized,
|
|
@@ -894,6 +928,9 @@ export class TeleBoxManager {
|
|
|
894
928
|
});
|
|
895
929
|
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
|
|
896
930
|
if (box.boxStatus && this.useBoxesStatus) {
|
|
931
|
+
if (box._forceNormal$.value) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
897
934
|
if(box.focus) {
|
|
898
935
|
this.blurBox(box);
|
|
899
936
|
}
|
|
@@ -944,6 +981,9 @@ export class TeleBoxManager {
|
|
|
944
981
|
if (this.boxes.length > 0) {
|
|
945
982
|
let currentTopBox: TeleBox | undefined = undefined;
|
|
946
983
|
const topBox = this.boxes.reduce((topBox, box) => {
|
|
984
|
+
if (this.isForceTop(box)) {
|
|
985
|
+
return topBox;
|
|
986
|
+
}
|
|
947
987
|
if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
|
|
948
988
|
return topBox;
|
|
949
989
|
}
|
|
@@ -1227,6 +1267,12 @@ export class TeleBoxManager {
|
|
|
1227
1267
|
lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
|
|
1228
1268
|
}, skipUpdate);
|
|
1229
1269
|
}
|
|
1270
|
+
if (config.forceTop != null) {
|
|
1271
|
+
box.setForceTop(config.forceTop, skipUpdate);
|
|
1272
|
+
}
|
|
1273
|
+
if (config.forceNormal != null) {
|
|
1274
|
+
box.setForceNormal(config.forceNormal, skipUpdate);
|
|
1275
|
+
}
|
|
1230
1276
|
}
|
|
1231
1277
|
|
|
1232
1278
|
protected smartPosition(config: TeleBoxConfig = {}): TeleBoxConfig {
|
|
@@ -1235,7 +1281,18 @@ export class TeleBoxManager {
|
|
|
1235
1281
|
|
|
1236
1282
|
if (x == null) {
|
|
1237
1283
|
let vx = 20;
|
|
1238
|
-
if (
|
|
1284
|
+
if (config.forceTop) {
|
|
1285
|
+
const forceTopBox = this.maxForceTopBox || this.topBox;
|
|
1286
|
+
if (forceTopBox) {
|
|
1287
|
+
vx = forceTopBox.intrinsicX * this.containerRect.width + 20;
|
|
1288
|
+
if (
|
|
1289
|
+
vx >
|
|
1290
|
+
this.containerRect.width - width * this.containerRect.width
|
|
1291
|
+
) {
|
|
1292
|
+
vx = 20;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
} else if (this.topBox) {
|
|
1239
1296
|
vx = this.topBox.intrinsicX * this.containerRect.width + 20;
|
|
1240
1297
|
if (
|
|
1241
1298
|
vx >
|
|
@@ -1254,8 +1311,20 @@ export class TeleBoxManager {
|
|
|
1254
1311
|
|
|
1255
1312
|
if (y == null) {
|
|
1256
1313
|
let vy = 20;
|
|
1257
|
-
|
|
1258
|
-
|
|
1314
|
+
if (config.forceTop) {
|
|
1315
|
+
const forceTopBox = this.maxForceTopBox || this.topBox;
|
|
1316
|
+
if (forceTopBox) {
|
|
1317
|
+
vy = forceTopBox.intrinsicY * this.containerRect.height + 20;
|
|
1318
|
+
|
|
1319
|
+
if (
|
|
1320
|
+
vy >
|
|
1321
|
+
this.containerRect.height -
|
|
1322
|
+
height * this.containerRect.height
|
|
1323
|
+
) {
|
|
1324
|
+
vy = 20;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
} else if (this.topBox) {
|
|
1259
1328
|
vy = this.topBox.intrinsicY * this.containerRect.height + 20;
|
|
1260
1329
|
|
|
1261
1330
|
if (
|
|
@@ -1288,7 +1357,7 @@ export class TeleBoxManager {
|
|
|
1288
1357
|
}
|
|
1289
1358
|
}
|
|
1290
1359
|
|
|
1291
|
-
|
|
1360
|
+
protected getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
|
|
1292
1361
|
if (!this.useBoxesStatus) {
|
|
1293
1362
|
return undefined;
|
|
1294
1363
|
}
|
|
@@ -38,7 +38,10 @@ type TeleBoxManagerBoxConfigBaseProps =
|
|
|
38
38
|
| "fixRatio"
|
|
39
39
|
| "zIndex"
|
|
40
40
|
| "boxStatus"
|
|
41
|
-
| "lastNotMinimizedBoxStatus"
|
|
41
|
+
| "lastNotMinimizedBoxStatus"
|
|
42
|
+
| "forceTop"
|
|
43
|
+
| "forceNormal"
|
|
44
|
+
| "isDragContent";
|
|
42
45
|
|
|
43
46
|
export type TeleBoxManagerCreateConfig = Pick<
|
|
44
47
|
TeleBoxConfig,
|
|
@@ -27,6 +27,8 @@ export interface DefaultTitleBarConfig extends TeleTitleBarConfig {
|
|
|
27
27
|
|
|
28
28
|
export class DefaultTitleBar implements TeleTitleBar {
|
|
29
29
|
protected boxStatus?: TeleBoxState;
|
|
30
|
+
protected forceTop?: boolean;
|
|
31
|
+
protected forceNormal?: boolean;
|
|
30
32
|
public constructor({
|
|
31
33
|
readonly = false,
|
|
32
34
|
title,
|
|
@@ -36,7 +38,9 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
36
38
|
namespace = "telebox",
|
|
37
39
|
state = TELE_BOX_STATE.Normal,
|
|
38
40
|
boxStatus,
|
|
39
|
-
|
|
41
|
+
forceTop = false,
|
|
42
|
+
forceNormal = false,
|
|
43
|
+
}: DefaultTitleBarConfig = {}) {
|
|
40
44
|
this.readonly = readonly;
|
|
41
45
|
this.onEvent = onEvent;
|
|
42
46
|
this.onDragStart = onDragStart;
|
|
@@ -44,23 +48,29 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
44
48
|
this.title = title;
|
|
45
49
|
this.state = state;
|
|
46
50
|
this.boxStatus = boxStatus;
|
|
51
|
+
this.forceTop = forceTop;
|
|
52
|
+
this.forceNormal = forceNormal;
|
|
47
53
|
|
|
48
|
-
this.buttons = buttons ||
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
iconClassName: this.wrapClassName("titlebar-icon-minimize"),
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: TELE_BOX_DELEGATE_EVENT.Maximize,
|
|
55
|
-
iconClassName: this.wrapClassName("titlebar-icon-maximize"),
|
|
56
|
-
isActive: (state) => state === TELE_BOX_STATE.Maximized,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
54
|
+
this.buttons = buttons || (
|
|
55
|
+
forceNormal ? [
|
|
56
|
+
{
|
|
59
57
|
type: TELE_BOX_DELEGATE_EVENT.Close,
|
|
60
58
|
iconClassName: this.wrapClassName("titlebar-icon-close"),
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
}] : [
|
|
60
|
+
{
|
|
61
|
+
type: TELE_BOX_DELEGATE_EVENT.Minimize,
|
|
62
|
+
iconClassName: this.wrapClassName("titlebar-icon-minimize"),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: TELE_BOX_DELEGATE_EVENT.Maximize,
|
|
66
|
+
iconClassName: this.wrapClassName("titlebar-icon-maximize"),
|
|
67
|
+
isActive: (state) => state === TELE_BOX_STATE.Maximized,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: TELE_BOX_DELEGATE_EVENT.Close,
|
|
71
|
+
iconClassName: this.wrapClassName("titlebar-icon-close"),
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
64
74
|
this.$dragArea = this.renderDragArea();
|
|
65
75
|
}
|
|
66
76
|
|
|
@@ -70,7 +80,7 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
70
80
|
|
|
71
81
|
public $title: HTMLElement | undefined;
|
|
72
82
|
|
|
73
|
-
public $dragArea: HTMLElement;
|
|
83
|
+
public readonly $dragArea: HTMLElement;
|
|
74
84
|
|
|
75
85
|
public setTitle(title: string): void {
|
|
76
86
|
this.title = title;
|
|
@@ -137,7 +147,6 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
137
147
|
|
|
138
148
|
$titleArea.appendChild(this.$title);
|
|
139
149
|
$titleArea.appendChild(this.$dragArea);
|
|
140
|
-
|
|
141
150
|
const $buttonsContainer = document.createElement("div");
|
|
142
151
|
$buttonsContainer.className = this.wrapClassName("titlebar-btns");
|
|
143
152
|
|
|
@@ -12,11 +12,14 @@ export interface TeleTitleBarConfig {
|
|
|
12
12
|
title?: string;
|
|
13
13
|
state?: TeleBoxState;
|
|
14
14
|
namespace?: string;
|
|
15
|
+
forceTop?: boolean;
|
|
16
|
+
forceNormal?: boolean;
|
|
15
17
|
onEvent?: (event: TeleTitleBarEvent) => void;
|
|
16
18
|
onDragStart?: (event: MouseEvent | TouchEvent) => void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export interface TeleTitleBar {
|
|
22
|
+
readonly $dragArea: HTMLElement;
|
|
20
23
|
setTitle(title: string): void;
|
|
21
24
|
|
|
22
25
|
setState(state: TeleBoxState): void;
|