@netless/telebox-insider 0.2.7 → 0.2.11

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.
@@ -17,7 +17,11 @@ import type {
17
17
  TeleBoxManagerUpdateConfig,
18
18
  } from "./typings";
19
19
  import { MaxTitleBar } from "./MaxTitleBar";
20
- import { TELE_BOX_DELEGATE_EVENT } from "..";
20
+ import {
21
+ TeleBoxColorScheme,
22
+ TELE_BOX_COLOR_SCHEME,
23
+ TELE_BOX_DELEGATE_EVENT,
24
+ } from "..";
21
25
  import { SideEffectManager } from "side-effect-manager";
22
26
  import {
23
27
  createSideEffectBinder,
@@ -30,6 +34,7 @@ export * from "./typings";
30
34
  export * from "./constants";
31
35
 
32
36
  type ValConfig = {
37
+ prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
33
38
  containerRect: Val<TeleBoxRect, boolean>;
34
39
  collector: Val<TeleBoxCollector | null>;
35
40
  readonly: Val<boolean, boolean>;
@@ -42,6 +47,7 @@ export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
42
47
  export class TeleBoxManager {
43
48
  public constructor({
44
49
  root = document.body,
50
+ prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
45
51
  minimized = false,
46
52
  maximized = false,
47
53
  fence = true,
@@ -63,6 +69,58 @@ export class TeleBoxManager {
63
69
  this.namespace = namespace;
64
70
  this.zIndex = zIndex;
65
71
 
72
+ this.boxes$ = createVal<TeleBox[]>([]);
73
+ this.topBox$ = this.boxes$.derive((boxes) => {
74
+ if (boxes.length > 0) {
75
+ const topBox = boxes.reduce((topBox, box) =>
76
+ topBox.zIndex > box.zIndex ? topBox : box
77
+ );
78
+ return topBox;
79
+ }
80
+ return;
81
+ });
82
+
83
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
84
+ const prefersDark$ = createVal(false);
85
+
86
+ if (prefersDark) {
87
+ prefersDark$.setValue(prefersDark.matches);
88
+ this._sideEffect.add(() => {
89
+ const handler = (evt: MediaQueryListEvent): void => {
90
+ prefersDark$.setValue(evt.matches);
91
+ };
92
+ prefersDark.addListener(handler);
93
+ return () => prefersDark.removeListener(handler);
94
+ });
95
+ }
96
+
97
+ const prefersColorScheme$ = createVal(prefersColorScheme);
98
+ prefersColorScheme$.reaction((prefersColorScheme, _, skipUpdate) => {
99
+ this.boxes.forEach((box) =>
100
+ box.setPrefersColorScheme(prefersColorScheme, skipUpdate)
101
+ );
102
+ if (!skipUpdate) {
103
+ this.events.emit(
104
+ TELE_BOX_MANAGER_EVENT.PrefersColorScheme,
105
+ prefersColorScheme
106
+ );
107
+ }
108
+ });
109
+
110
+ this._darkMode$ = combine(
111
+ [prefersDark$, prefersColorScheme$],
112
+ ([prefersDark, prefersColorScheme]) =>
113
+ prefersColorScheme === "auto"
114
+ ? prefersDark
115
+ : prefersColorScheme === "dark"
116
+ );
117
+ this._darkMode$.reaction((darkMode, _, skipUpdate) => {
118
+ this.boxes.forEach((box) => box.setDarkMode(darkMode, skipUpdate));
119
+ if (!skipUpdate) {
120
+ this.events.emit(TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
121
+ }
122
+ });
123
+
66
124
  const readonly$ = createVal(readonly);
67
125
  readonly$.reaction((readonly, _, skipUpdate) => {
68
126
  this.boxes.forEach((box) => box.setReadonly(readonly, skipUpdate));
@@ -123,6 +181,7 @@ export class TeleBoxManager {
123
181
  if (collector) {
124
182
  collector.setVisible(minimized$.value);
125
183
  collector.setReadonly(readonly$.value);
184
+ collector.setDarkMode(this._darkMode$.value);
126
185
  this._sideEffect.add(() => {
127
186
  collector.onClick = () => {
128
187
  if (!readonly$.value) {
@@ -136,6 +195,9 @@ export class TeleBoxManager {
136
195
  readonly$.subscribe((readonly) =>
137
196
  collector$.value?.setReadonly(readonly)
138
197
  );
198
+ this._darkMode$.subscribe((darkMode) => {
199
+ collector$.value?.setDarkMode(darkMode);
200
+ });
139
201
 
140
202
  minimized$.subscribe((minimized, _, skipUpdate) => {
141
203
  collector$.value?.setVisible(minimized);
@@ -170,6 +232,8 @@ export class TeleBoxManager {
170
232
  }
171
233
  });
172
234
 
235
+ const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
236
+
173
237
  const checkFocusBox = (ev: MouseEvent | TouchEvent): void => {
174
238
  if (readonly$.value) {
175
239
  return;
@@ -185,11 +249,14 @@ export class TeleBoxManager {
185
249
  el;
186
250
  el = el.parentElement
187
251
  ) {
252
+ if (el.classList && el.classList.contains(closeBtnClassName)) {
253
+ return;
254
+ }
188
255
  const id = el.dataset?.teleBoxID;
189
256
  if (id) {
190
- const box = this.boxes.find((box) => box.id === id);
257
+ const box = this.getBox(id);
191
258
  if (box) {
192
- this.focusBox({ focus: true, box });
259
+ this.focusBox(box);
193
260
  return;
194
261
  }
195
262
  }
@@ -210,11 +277,11 @@ export class TeleBoxManager {
210
277
  );
211
278
 
212
279
  this.maxTitleBar = new MaxTitleBar({
280
+ darkMode: this.darkMode,
213
281
  readonly: readonly$.value,
214
282
  namespace: this.namespace,
215
283
  state: state$.value,
216
- boxes: this.boxes,
217
- focusedBox: this._focusedBox,
284
+ boxes: this.boxes$.value,
218
285
  containerRect: containerRect$.value,
219
286
  onEvent: (event): void => {
220
287
  switch (event.type) {
@@ -227,12 +294,7 @@ export class TeleBoxManager {
227
294
  break;
228
295
  }
229
296
  case TELE_BOX_EVENT.Close: {
230
- const box =
231
- this._focusedBox ??
232
- this.boxes[this.boxes.length - 1];
233
- if (box) {
234
- this.remove(box.id);
235
- }
297
+ this.removeTopBox();
236
298
  break;
237
299
  }
238
300
  default: {
@@ -244,8 +306,15 @@ export class TeleBoxManager {
244
306
  readonly$.subscribe((readonly) =>
245
307
  this.maxTitleBar.setReadonly(readonly)
246
308
  );
309
+ this._darkMode$.subscribe((darkMode) => {
310
+ this.maxTitleBar.setDarkMode(darkMode);
311
+ });
312
+ this.boxes$.reaction((boxes) => {
313
+ this.maxTitleBar.setBoxes(boxes);
314
+ });
247
315
 
248
316
  const valConfig: ValConfig = {
317
+ prefersColorScheme: prefersColorScheme$,
249
318
  containerRect: containerRect$,
250
319
  collector: collector$,
251
320
  readonly: readonly$,
@@ -261,6 +330,14 @@ export class TeleBoxManager {
261
330
  this.root.appendChild(this.maxTitleBar.render());
262
331
  }
263
332
 
333
+ public get boxes(): ReadonlyArray<TeleBox> {
334
+ return this.boxes$.value;
335
+ }
336
+
337
+ public get topBox(): TeleBox | undefined {
338
+ return this.topBox$.value;
339
+ }
340
+
264
341
  public readonly events = new EventEmitter() as TeleBoxManagerEvents;
265
342
 
266
343
  protected _sideEffect: SideEffectManager;
@@ -271,6 +348,12 @@ export class TeleBoxManager {
271
348
 
272
349
  public zIndex: number;
273
350
 
351
+ public _darkMode$: Val<boolean, boolean>;
352
+
353
+ public get darkMode(): boolean {
354
+ return this._darkMode$.value;
355
+ }
356
+
274
357
  public _state$: Val<TeleBoxState, boolean>;
275
358
 
276
359
  public get state(): TeleBoxState {
@@ -299,16 +382,30 @@ export class TeleBoxManager {
299
382
  return this;
300
383
  }
301
384
 
302
- public create(config?: TeleBoxManagerCreateConfig): ReadonlyTeleBox {
303
- const box = new TeleBox(this.wrapCreateConfig(config));
385
+ public create(
386
+ config: TeleBoxManagerCreateConfig = {},
387
+ smartPosition = true
388
+ ): ReadonlyTeleBox {
389
+ const box = new TeleBox({
390
+ zIndex: this.zIndex,
391
+ ...(smartPosition ? this.smartPosition(config) : config),
392
+ darkMode: this.darkMode,
393
+ prefersColorScheme: this.prefersColorScheme,
394
+ maximized: this.maximized,
395
+ minimized: this.minimized,
396
+ fence: this.fence,
397
+ namespace: this.namespace,
398
+ containerRect: this.containerRect,
399
+ readonly: this.readonly,
400
+ });
401
+
304
402
  box.mount(this.root);
305
- this.boxes.push(box);
306
403
 
307
404
  if (box.focus) {
308
- this.focusBox({ focus: true, box, increaseZIndex: false });
405
+ this.focusBox(box);
309
406
  }
310
407
 
311
- this.maxTitleBar.setBoxes(this.boxes);
408
+ this.boxes$.setValue([...this.boxes, box]);
312
409
 
313
410
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
314
411
  this.setMaximized(!this.maximized);
@@ -317,8 +414,7 @@ export class TeleBoxManager {
317
414
  this.setMinimized(true);
318
415
  });
319
416
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
320
- this.focusBox({ focus: false, box });
321
- this.remove(box.id);
417
+ this.remove(box);
322
418
  });
323
419
  box.events.on(TELE_BOX_EVENT.Move, () => {
324
420
  this.events.emit(TELE_BOX_MANAGER_EVENT.Move, box);
@@ -375,16 +471,16 @@ export class TeleBoxManager {
375
471
  }
376
472
 
377
473
  public remove(
378
- boxID: string,
474
+ boxOrID: string | TeleBox,
379
475
  skipUpdate = false
380
476
  ): ReadonlyTeleBox | undefined {
381
- const index = this.boxes.findIndex((box) => box.id === boxID);
477
+ const index = this.getBoxIndex(boxOrID);
382
478
  if (index >= 0) {
383
- const boxes = this.boxes.splice(index, 1);
384
- this.maxTitleBar.setBoxes(this.boxes);
385
- const box = boxes[0];
386
- this.focusBox({ focus: false, box });
387
- box.destroy();
479
+ const boxes = this.boxes.slice();
480
+ const deletedBox = boxes.splice(index, 1)[0];
481
+ this.boxes$.setValue(boxes);
482
+ this.focusTopBox();
483
+ deletedBox.destroy();
388
484
  if (!skipUpdate) {
389
485
  if (this.boxes.length <= 0) {
390
486
  this.setMaximized(false);
@@ -392,40 +488,35 @@ export class TeleBoxManager {
392
488
  }
393
489
  this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, boxes);
394
490
  }
395
- return box;
491
+ return deletedBox;
396
492
  }
397
493
  return;
398
494
  }
399
495
 
400
- public removeAll(skipUpdate = false): ReadonlyTeleBox[] {
401
- if (this._focusedBox) {
402
- const box = this._focusedBox;
403
- this._focusedBox = void 0;
404
- if (!skipUpdate) {
405
- this.events.emit(
406
- TELE_BOX_MANAGER_EVENT.Focused,
407
- undefined,
408
- box
409
- );
410
- }
496
+ public removeTopBox(): ReadonlyTeleBox | undefined {
497
+ if (this.topBox) {
498
+ return this.remove(this.topBox);
411
499
  }
412
- const boxes = this.boxes.splice(0, this.boxes.length);
413
- this.maxTitleBar.setBoxes(this.boxes);
414
- boxes.forEach((box) => box.destroy());
500
+ return;
501
+ }
502
+
503
+ public removeAll(skipUpdate = false): ReadonlyTeleBox[] {
504
+ const deletedBoxes = this.boxes$.value;
505
+ this.boxes$.setValue([]);
506
+ deletedBoxes.forEach((box) => box.destroy());
415
507
  if (!skipUpdate) {
416
508
  if (this.boxes.length <= 0) {
417
509
  this.setMaximized(false);
418
510
  this.setMinimized(false);
419
511
  }
420
- this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, boxes);
512
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
421
513
  }
422
- return boxes;
514
+ return deletedBoxes;
423
515
  }
424
516
 
425
517
  public destroy(skipUpdate = false): void {
426
518
  this.events.removeAllListeners();
427
519
  this._sideEffect.flushAll();
428
- this._focusedBox = void 0;
429
520
  this.removeAll(skipUpdate);
430
521
 
431
522
  Object.keys(this).forEach((key) => {
@@ -440,13 +531,70 @@ export class TeleBoxManager {
440
531
  return `${this.namespace}-${className}`;
441
532
  }
442
533
 
443
- protected maxTitleBar: MaxTitleBar;
534
+ public focusBox(boxOrID: string | TeleBox, skipUpdate = false): void {
535
+ const targetBox = this.getBox(boxOrID);
536
+ if (targetBox) {
537
+ this.boxes.forEach((box) => {
538
+ if (targetBox === box) {
539
+ let focusChanged = false;
540
+ if (!targetBox.focus) {
541
+ focusChanged = true;
542
+ targetBox.setFocus(true, skipUpdate);
543
+ }
544
+ this.makeBoxTop(targetBox, skipUpdate);
545
+ if (focusChanged && !skipUpdate) {
546
+ this.events.emit(
547
+ TELE_BOX_MANAGER_EVENT.Focused,
548
+ targetBox
549
+ );
550
+ }
551
+ } else if (box.focus) {
552
+ this.blurBox(box, skipUpdate);
553
+ }
554
+ });
555
+ this.maxTitleBar.focusBox(targetBox);
556
+ }
557
+ }
444
558
 
445
- protected _focusedBox: TeleBox | undefined;
559
+ public focusTopBox(): void {
560
+ if (this.topBox && !this.topBox.focus) {
561
+ return this.focusBox(this.topBox);
562
+ }
563
+ }
446
564
 
447
- protected boxes: TeleBox[] = [];
565
+ public blurBox(boxOrID: string | TeleBox, skipUpdate = false): void {
566
+ const targetBox = this.getBox(boxOrID);
567
+ if (targetBox) {
568
+ if (targetBox.focus) {
569
+ targetBox.setFocus(false, skipUpdate);
570
+ if (!skipUpdate) {
571
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, targetBox);
572
+ }
573
+ }
574
+ if (this.maxTitleBar.focusedBox === targetBox) {
575
+ this.maxTitleBar.focusBox();
576
+ }
577
+ }
578
+ }
448
579
 
449
- protected lastState: TeleBoxState | undefined;
580
+ public blurAll(skipUpdate = false): void {
581
+ this.boxes.forEach((box) => {
582
+ if (box.focus) {
583
+ box.setFocus(false, skipUpdate);
584
+ if (!skipUpdate) {
585
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, box);
586
+ }
587
+ }
588
+ });
589
+ if (this.maxTitleBar.focusedBox) {
590
+ this.maxTitleBar.focusBox();
591
+ }
592
+ }
593
+
594
+ protected maxTitleBar: MaxTitleBar;
595
+
596
+ protected boxes$: Val<TeleBox[]>;
597
+ protected topBox$: Val<TeleBox | undefined>;
450
598
 
451
599
  protected teleBoxMatcher(
452
600
  config: TeleBoxManagerQueryConfig
@@ -499,9 +647,6 @@ export class TeleBoxManager {
499
647
  if (config.fixRatio != null) {
500
648
  box.setFixRatio(config.fixRatio, skipUpdate);
501
649
  }
502
- if (config.focus != null) {
503
- this.focusBox({ focus: config.focus, box, skipUpdate });
504
- }
505
650
  if (config.content != null) {
506
651
  box.mountContent(config.content);
507
652
  }
@@ -510,117 +655,69 @@ export class TeleBoxManager {
510
655
  }
511
656
  }
512
657
 
513
- protected focusBox({
514
- focus,
515
- box,
516
- skipUpdate = false,
517
- increaseZIndex = true,
518
- }: {
519
- focus: boolean;
520
- box: TeleBox;
521
- skipUpdate?: boolean;
522
- increaseZIndex?: boolean;
523
- }): void {
524
- box.setFocus(focus, skipUpdate);
525
- if (box.focus) {
526
- if (this._focusedBox !== box) {
527
- const lastFocusedBox = this._focusedBox;
528
- if (this._focusedBox) {
529
- this._focusedBox.setFocus(false, skipUpdate);
530
- }
531
- this._focusedBox = box;
532
- if (increaseZIndex) {
533
- box.setZIndex(++this.zIndex);
534
- }
535
- if (!skipUpdate) {
536
- this.events.emit(
537
- TELE_BOX_MANAGER_EVENT.Focused,
538
- box,
539
- lastFocusedBox
540
- );
541
- }
542
- }
543
- } else {
544
- if (this._focusedBox === box) {
545
- this._focusedBox = void 0;
658
+ protected smartPosition(config: TeleBoxConfig = {}): TeleBoxConfig {
659
+ let { x, y } = config;
660
+ const { width = 0.5, height = 0.5 } = config;
546
661
 
547
- if (!skipUpdate) {
548
- this.events.emit(
549
- TELE_BOX_MANAGER_EVENT.Focused,
550
- undefined,
551
- box
552
- );
662
+ if (x == null) {
663
+ let vx = 20;
664
+ if (this.topBox) {
665
+ vx = this.topBox.intrinsicX * this.containerRect.width + 20;
666
+
667
+ if (
668
+ vx >
669
+ this.containerRect.width - width * this.containerRect.width
670
+ ) {
671
+ vx = 20;
553
672
  }
554
673
  }
674
+ x = vx / this.containerRect.width;
555
675
  }
556
- this.maxTitleBar.focusBox(this._focusedBox);
557
- }
558
676
 
559
- protected getInitialPosition(
560
- width: number,
561
- height: number
562
- ): { x: number; y: number } {
563
- const upMostBox =
564
- this.boxes.length > 0 &&
565
- this.boxes.reduce((box1, box2) =>
566
- box1.zIndex > box2.zIndex ? box1 : box2
567
- );
677
+ if (y == null) {
678
+ let vy = 20;
568
679
 
569
- let x = 20;
570
- let y = 20;
680
+ if (this.topBox) {
681
+ vy = this.topBox.intrinsicY * this.containerRect.height + 20;
571
682
 
572
- if (upMostBox) {
573
- x = upMostBox.intrinsicX * this.containerRect.width + 20;
574
- y = upMostBox.intrinsicY * this.containerRect.height + 20;
575
-
576
- if (
577
- x >
578
- this.containerRect.width -
579
- width * this.containerRect.width ||
580
- y >
683
+ if (
684
+ vy >
581
685
  this.containerRect.height -
582
686
  height * this.containerRect.height
583
- ) {
584
- x = 20;
585
- y = 20;
687
+ ) {
688
+ vy = 20;
689
+ }
586
690
  }
691
+
692
+ y = vy / this.containerRect.height;
587
693
  }
588
694
 
589
- return {
590
- x: x / this.containerRect.width,
591
- y: y / this.containerRect.height,
592
- };
695
+ return { ...config, x, y, width, height };
593
696
  }
594
697
 
595
- protected wrapCreateConfig(config: TeleBoxConfig = {}): TeleBoxConfig {
596
- let { x, y } = config;
597
- const { width = 0.5, height = 0.5 } = config;
598
-
599
- if (x == null || y == null) {
600
- const initialPos = this.getInitialPosition(width, height);
601
-
602
- if (x == null) {
603
- x = initialPos.x;
604
- }
605
-
606
- if (y == null) {
607
- y = initialPos.y;
698
+ protected makeBoxTop(box: TeleBox, skipUpdate = false): void {
699
+ if (box !== this.topBox) {
700
+ const maxIndex = this.boxes.reduce(
701
+ (max, box) => Math.max(max, box.zIndex),
702
+ 0
703
+ );
704
+ box.setZIndex(maxIndex + 1, skipUpdate);
705
+ this.topBox$.setValue(box);
706
+ if (!skipUpdate) {
707
+ this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
608
708
  }
609
709
  }
710
+ }
610
711
 
611
- return {
612
- ...config,
613
- x,
614
- y,
615
- width,
616
- height,
617
- maximized: this.maximized,
618
- minimized: this.minimized,
619
- fence: this.fence,
620
- zIndex: this.zIndex,
621
- namespace: this.namespace,
622
- containerRect: this.containerRect,
623
- readonly: this.readonly,
624
- };
712
+ protected getBoxIndex(boxOrID: TeleBox | string): number {
713
+ return typeof boxOrID === "string"
714
+ ? this.boxes.findIndex((box) => box.id === boxOrID)
715
+ : this.boxes.findIndex((box) => box === boxOrID);
716
+ }
717
+
718
+ protected getBox(boxOrID: TeleBox | string): TeleBox | undefined {
719
+ return typeof boxOrID === "string"
720
+ ? this.boxes.find((box) => box.id === boxOrID)
721
+ : boxOrID;
625
722
  }
626
723
  }
@@ -1,4 +1,5 @@
1
1
  import type EventEmitter from "eventemitter3";
2
+ import { TeleBoxColorScheme } from "..";
2
3
  import type { ReadonlyTeleBox, TeleBoxState } from "../TeleBox";
3
4
  import type { TeleBoxConfig } from "../TeleBox/typings";
4
5
  import type { TeleBoxCollector } from "../TeleBoxCollector";
@@ -7,6 +8,7 @@ import type { TELE_BOX_MANAGER_EVENT } from "./constants";
7
8
  export interface TeleBoxManagerConfig
8
9
  extends Pick<
9
10
  TeleBoxConfig,
11
+ | "prefersColorScheme"
10
12
  | "fence"
11
13
  | "containerRect"
12
14
  | "maximized"
@@ -33,16 +35,16 @@ type TeleBoxManagerBoxConfigBaseProps =
33
35
  | "resizable"
34
36
  | "draggable"
35
37
  | "fixRatio"
36
- | "focus";
38
+ | "zIndex";
37
39
 
38
40
  export type TeleBoxManagerCreateConfig = Pick<
39
41
  TeleBoxConfig,
40
- TeleBoxManagerBoxConfigBaseProps | "content" | "footer" | "id"
42
+ TeleBoxManagerBoxConfigBaseProps | "content" | "footer" | "id" | "focus"
41
43
  >;
42
44
 
43
45
  export type TeleBoxManagerQueryConfig = Pick<
44
46
  TeleBoxConfig,
45
- TeleBoxManagerBoxConfigBaseProps | "id"
47
+ TeleBoxManagerBoxConfigBaseProps | "id" | "focus"
46
48
  >;
47
49
 
48
50
  export type TeleBoxManagerUpdateConfig = Pick<
@@ -55,8 +57,8 @@ type CheckTeleBoxManagerConfig<
55
57
  > = T;
56
58
 
57
59
  export type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
58
- /** current focused box and last focused box */
59
- focused: [ReadonlyTeleBox | undefined, ReadonlyTeleBox | undefined];
60
+ focused: [ReadonlyTeleBox | undefined];
61
+ blurred: [ReadonlyTeleBox | undefined];
60
62
  created: [ReadonlyTeleBox];
61
63
  removed: [ReadonlyTeleBox[]];
62
64
  state: [TeleBoxState];
@@ -67,6 +69,9 @@ export type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
67
69
  intrinsic_move: [ReadonlyTeleBox];
68
70
  intrinsic_resize: [ReadonlyTeleBox];
69
71
  visual_resize: [ReadonlyTeleBox];
72
+ z_index: [ReadonlyTeleBox];
73
+ prefers_color_scheme: [TeleBoxColorScheme];
74
+ dark_mode: [boolean];
70
75
  }>;
71
76
 
72
77
  export type TeleBoxManagerEvent = keyof TeleBoxManagerEventConfig;
@@ -16,6 +16,12 @@ export type TeleBoxReactProps = TeleBoxConfig & {
16
16
  export const TeleBoxReact: FC<TeleBoxReactProps> = (props) => {
17
17
  const [teleBox] = useState(() => new TeleBox(props));
18
18
 
19
+ useUpdateEffect(() => {
20
+ if (props.prefersColorScheme != null) {
21
+ teleBox.setPrefersColorScheme(props.prefersColorScheme);
22
+ }
23
+ }, [teleBox, props.prefersColorScheme]);
24
+
19
25
  useUpdateEffect(() => {
20
26
  if (props.minWidth != null) {
21
27
  teleBox.setMinWidth(props.minWidth);
@@ -52,6 +58,18 @@ export const TeleBoxReact: FC<TeleBoxReactProps> = (props) => {
52
58
  }
53
59
  }, [teleBox, props.visible]);
54
60
 
61
+ useUpdateEffect(() => {
62
+ if (props.minimized != null) {
63
+ teleBox.setMinimized(props.minimized, true);
64
+ }
65
+ }, [teleBox, props.minimized]);
66
+
67
+ useUpdateEffect(() => {
68
+ if (props.maximized != null) {
69
+ teleBox.setMaximized(props.maximized, true);
70
+ }
71
+ }, [teleBox, props.maximized]);
72
+
55
73
  useUpdateEffect(() => {
56
74
  if (props.state != null) {
57
75
  teleBox.setState(props.state, true);
@@ -71,3 +71,17 @@
71
71
  .#{$namespace}-titlebar-icon-close {
72
72
  background: center / cover no-repeat url("./icons/close.svg");
73
73
  }
74
+
75
+ .#{$namespace}-color-scheme-dark {
76
+ color-scheme: dark;
77
+
78
+ .#{$namespace}-title {
79
+ color: #e9e9e9;
80
+ }
81
+
82
+ .#{$namespace}-titlebar {
83
+ color: #e9e9e9;
84
+ background: #43434d;
85
+ border-bottom: none;
86
+ }
87
+ }