@netless/telebox-insider 0.3.1-beta.0 → 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 +8 -1
- package/dist/telebox-insider.cjs.js +69 -12
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +69 -12
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/index.ts +7 -2
- package/src/TeleBoxManager/index.ts +59 -3
- package/src/TeleTitleBar/typings.ts +1 -1
package/package.json
CHANGED
package/src/TeleBox/index.ts
CHANGED
|
@@ -267,7 +267,11 @@ export class TeleBox {
|
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
-
const maximized$ = createVal(
|
|
270
|
+
const maximized$ = createVal(
|
|
271
|
+
maximized || forceMaximized,
|
|
272
|
+
(next, previous) =>
|
|
273
|
+
next === previous || (forceMaximized$.value && !next)
|
|
274
|
+
);
|
|
271
275
|
maximized$.reaction((maximized, _, skipUpdate) => {
|
|
272
276
|
if (!skipUpdate) {
|
|
273
277
|
this.events.emit(TELE_BOX_EVENT.Maximized, maximized);
|
|
@@ -489,7 +493,8 @@ export class TeleBox {
|
|
|
489
493
|
this.titleBar.setReadonly(readonly);
|
|
490
494
|
});
|
|
491
495
|
forceMaximized$.reaction((forceMaximized) => {
|
|
492
|
-
|
|
496
|
+
if (forceMaximized) maximized$.setValue(true);
|
|
497
|
+
this.titleBar.setForceMaximized?.(forceMaximized);
|
|
493
498
|
});
|
|
494
499
|
boxStatus$.reaction((boxStatus) => {
|
|
495
500
|
this.titleBar.setBoxStatus(boxStatus);
|
|
@@ -167,13 +167,18 @@ export class TeleBoxManager {
|
|
|
167
167
|
|
|
168
168
|
const minimized$ = createVal(minimized);
|
|
169
169
|
|
|
170
|
-
const maximized$ = createVal(maximized);
|
|
171
170
|
const forceMaximized$ = createVal(forceMaximized);
|
|
171
|
+
const maximized$ = createVal(
|
|
172
|
+
maximized || forceMaximized,
|
|
173
|
+
(next, previous) =>
|
|
174
|
+
next === previous || (forceMaximized$.value && !next)
|
|
175
|
+
);
|
|
172
176
|
forceMaximized$.reaction((forceMaximized, _, skipUpdate) => {
|
|
177
|
+
if (forceMaximized) maximized$.setValue(true, skipUpdate);
|
|
173
178
|
this.boxes.forEach((box) =>
|
|
174
179
|
box.setForceMaximized(forceMaximized, skipUpdate)
|
|
175
180
|
);
|
|
176
|
-
this.maxTitleBar?.setForceMaximized(forceMaximized);
|
|
181
|
+
this.maxTitleBar?.setForceMaximized?.(forceMaximized);
|
|
177
182
|
});
|
|
178
183
|
maximized$.reaction((maximized, _, skipUpdate) => {
|
|
179
184
|
this.boxes.forEach((box) =>
|
|
@@ -328,6 +333,7 @@ export class TeleBoxManager {
|
|
|
328
333
|
if (id) {
|
|
329
334
|
const box = this.getBox(id);
|
|
330
335
|
if (box) {
|
|
336
|
+
if (this.lazyFocusRequestHandler?.(box.id)) return;
|
|
331
337
|
if (!this.useBoxesStatus) {
|
|
332
338
|
this.makeBoxTop(box);
|
|
333
339
|
} else {
|
|
@@ -364,7 +370,7 @@ export class TeleBoxManager {
|
|
|
364
370
|
this.makeMaximizedTopBoxFocus();
|
|
365
371
|
}
|
|
366
372
|
}
|
|
367
|
-
this.
|
|
373
|
+
this.focusBoxCommitted(box);
|
|
368
374
|
return;
|
|
369
375
|
}
|
|
370
376
|
}
|
|
@@ -467,6 +473,10 @@ export class TeleBoxManager {
|
|
|
467
473
|
break;
|
|
468
474
|
}
|
|
469
475
|
case TELE_BOX_EVENT.Close: {
|
|
476
|
+
const targetBox = this.hasBoxesStatus()
|
|
477
|
+
? this.maxTitleBar.focusedBox || this.getMaximizedTopBox()
|
|
478
|
+
: this.topBox;
|
|
479
|
+
if (targetBox && this.closeRequestHandler?.(targetBox.id)) break;
|
|
470
480
|
if (this.hasBoxesStatus()) {
|
|
471
481
|
let targetBox = this.maxTitleBar.focusedBox;
|
|
472
482
|
if (!targetBox) {
|
|
@@ -582,6 +592,22 @@ export class TeleBoxManager {
|
|
|
582
592
|
return this._state$.value;
|
|
583
593
|
}
|
|
584
594
|
|
|
595
|
+
public setUseBoxesStatus(useBoxesStatus: boolean): void {
|
|
596
|
+
if (this.useBoxesStatus === useBoxesStatus) return;
|
|
597
|
+
this.useBoxesStatus = useBoxesStatus;
|
|
598
|
+
this.boxes.forEach((box) =>
|
|
599
|
+
box.setBoxStatus(useBoxesStatus ? this.boxesStatus$.get(box.id) : undefined, true)
|
|
600
|
+
);
|
|
601
|
+
this.boxes$.setValue([...this.boxes]);
|
|
602
|
+
if (useBoxesStatus) {
|
|
603
|
+
this.appMenu ||= this.createMinimizedAppMenu();
|
|
604
|
+
this.effectBoxStatusChange();
|
|
605
|
+
} else {
|
|
606
|
+
this.appMenu?.render(new Map());
|
|
607
|
+
this.collector?.setVisible(false);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
585
611
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
586
612
|
public setState(state: TeleBoxState, skipUpdate = false): this {
|
|
587
613
|
if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
|
|
@@ -1021,6 +1047,9 @@ export class TeleBoxManager {
|
|
|
1021
1047
|
? this.getMaxForceTopBoxZIndex() + 1
|
|
1022
1048
|
: this.getMaxNormalBoxZIndex() + 1,
|
|
1023
1049
|
...(smartPosition ? this.smartPosition(config) : config),
|
|
1050
|
+
...(!this.useBoxesStatus
|
|
1051
|
+
? { boxStatus: undefined, lastNotMinimizedBoxStatus: undefined }
|
|
1052
|
+
: {}),
|
|
1024
1053
|
darkMode: this.darkMode,
|
|
1025
1054
|
prefersColorScheme: this.prefersColorScheme,
|
|
1026
1055
|
maximized: this.maximized,
|
|
@@ -1124,6 +1153,7 @@ export class TeleBoxManager {
|
|
|
1124
1153
|
}
|
|
1125
1154
|
});
|
|
1126
1155
|
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
|
|
1156
|
+
if (this.closeRequestHandler?.(box.id)) return;
|
|
1127
1157
|
if (this.useBoxesStatus && box.focus) {
|
|
1128
1158
|
this.blurBox(box);
|
|
1129
1159
|
}
|
|
@@ -1329,9 +1359,26 @@ export class TeleBoxManager {
|
|
|
1329
1359
|
return `${this.namespace}-${className}`;
|
|
1330
1360
|
}
|
|
1331
1361
|
|
|
1362
|
+
private lazyFocusRequestHandler?: (boxId: string) => boolean;
|
|
1363
|
+
private closeRequestHandler?: (boxId: string) => boolean;
|
|
1364
|
+
private committedFocusDepth = 0;
|
|
1365
|
+
|
|
1366
|
+
public setLazyFocusRequestHandler(handler?: (boxId: string) => boolean): void {
|
|
1367
|
+
this.lazyFocusRequestHandler = handler;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
public setCloseRequestHandler(handler?: (boxId: string) => boolean): void {
|
|
1371
|
+
this.closeRequestHandler = handler;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1332
1374
|
public focusBox(boxOrID: string | TeleBox, skipUpdate = false): void {
|
|
1333
1375
|
const targetBox = this.getBox(boxOrID);
|
|
1334
1376
|
if (targetBox) {
|
|
1377
|
+
if (
|
|
1378
|
+
!skipUpdate &&
|
|
1379
|
+
!this.committedFocusDepth &&
|
|
1380
|
+
this.lazyFocusRequestHandler?.(targetBox.id)
|
|
1381
|
+
) return;
|
|
1335
1382
|
this.boxes.forEach((box) => {
|
|
1336
1383
|
if (targetBox === box) {
|
|
1337
1384
|
let focusChanged = false;
|
|
@@ -1360,6 +1407,15 @@ export class TeleBoxManager {
|
|
|
1360
1407
|
}
|
|
1361
1408
|
}
|
|
1362
1409
|
|
|
1410
|
+
public focusBoxCommitted(boxOrID: string | TeleBox, skipUpdate = false): void {
|
|
1411
|
+
this.committedFocusDepth = (this.committedFocusDepth ?? 0) + 1;
|
|
1412
|
+
try {
|
|
1413
|
+
this.focusBox(boxOrID, skipUpdate);
|
|
1414
|
+
} finally {
|
|
1415
|
+
this.committedFocusDepth -= 1;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1363
1419
|
public focusTopBox(): void {
|
|
1364
1420
|
if (this.topBox && !this.topBox.focus) {
|
|
1365
1421
|
return this.focusBox(this.topBox);
|