@netless/telebox-insider 0.3.1-beta.0 → 0.3.1
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 +6 -1
- package/dist/telebox-insider.cjs.js +54 -7
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +54 -7
- 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 +49 -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
|
}
|
|
@@ -582,6 +588,22 @@ export class TeleBoxManager {
|
|
|
582
588
|
return this._state$.value;
|
|
583
589
|
}
|
|
584
590
|
|
|
591
|
+
public setUseBoxesStatus(useBoxesStatus: boolean): void {
|
|
592
|
+
if (this.useBoxesStatus === useBoxesStatus) return;
|
|
593
|
+
this.useBoxesStatus = useBoxesStatus;
|
|
594
|
+
this.boxes.forEach((box) =>
|
|
595
|
+
box.setBoxStatus(useBoxesStatus ? this.boxesStatus$.get(box.id) : undefined, true)
|
|
596
|
+
);
|
|
597
|
+
this.boxes$.setValue([...this.boxes]);
|
|
598
|
+
if (useBoxesStatus) {
|
|
599
|
+
this.appMenu ||= this.createMinimizedAppMenu();
|
|
600
|
+
this.effectBoxStatusChange();
|
|
601
|
+
} else {
|
|
602
|
+
this.appMenu?.render(new Map());
|
|
603
|
+
this.collector?.setVisible(false);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
585
607
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
586
608
|
public setState(state: TeleBoxState, skipUpdate = false): this {
|
|
587
609
|
if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
|
|
@@ -1021,6 +1043,9 @@ export class TeleBoxManager {
|
|
|
1021
1043
|
? this.getMaxForceTopBoxZIndex() + 1
|
|
1022
1044
|
: this.getMaxNormalBoxZIndex() + 1,
|
|
1023
1045
|
...(smartPosition ? this.smartPosition(config) : config),
|
|
1046
|
+
...(!this.useBoxesStatus
|
|
1047
|
+
? { boxStatus: undefined, lastNotMinimizedBoxStatus: undefined }
|
|
1048
|
+
: {}),
|
|
1024
1049
|
darkMode: this.darkMode,
|
|
1025
1050
|
prefersColorScheme: this.prefersColorScheme,
|
|
1026
1051
|
maximized: this.maximized,
|
|
@@ -1329,9 +1354,21 @@ export class TeleBoxManager {
|
|
|
1329
1354
|
return `${this.namespace}-${className}`;
|
|
1330
1355
|
}
|
|
1331
1356
|
|
|
1357
|
+
private lazyFocusRequestHandler?: (boxId: string) => boolean;
|
|
1358
|
+
private committedFocusDepth = 0;
|
|
1359
|
+
|
|
1360
|
+
public setLazyFocusRequestHandler(handler?: (boxId: string) => boolean): void {
|
|
1361
|
+
this.lazyFocusRequestHandler = handler;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1332
1364
|
public focusBox(boxOrID: string | TeleBox, skipUpdate = false): void {
|
|
1333
1365
|
const targetBox = this.getBox(boxOrID);
|
|
1334
1366
|
if (targetBox) {
|
|
1367
|
+
if (
|
|
1368
|
+
!skipUpdate &&
|
|
1369
|
+
!this.committedFocusDepth &&
|
|
1370
|
+
this.lazyFocusRequestHandler?.(targetBox.id)
|
|
1371
|
+
) return;
|
|
1335
1372
|
this.boxes.forEach((box) => {
|
|
1336
1373
|
if (targetBox === box) {
|
|
1337
1374
|
let focusChanged = false;
|
|
@@ -1360,6 +1397,15 @@ export class TeleBoxManager {
|
|
|
1360
1397
|
}
|
|
1361
1398
|
}
|
|
1362
1399
|
|
|
1400
|
+
public focusBoxCommitted(boxOrID: string | TeleBox, skipUpdate = false): void {
|
|
1401
|
+
this.committedFocusDepth = (this.committedFocusDepth ?? 0) + 1;
|
|
1402
|
+
try {
|
|
1403
|
+
this.focusBox(boxOrID, skipUpdate);
|
|
1404
|
+
} finally {
|
|
1405
|
+
this.committedFocusDepth -= 1;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1363
1409
|
public focusTopBox(): void {
|
|
1364
1410
|
if (this.topBox && !this.topBox.focus) {
|
|
1365
1411
|
return this.focusBox(this.topBox);
|