@netless/telebox-insider 1.0.0-alpha.34 → 1.0.0-alpha.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/telebox-insider",
3
- "version": "1.0.0-alpha.34",
3
+ "version": "1.0.0-alpha.35",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "license": "MIT",
@@ -69,6 +69,7 @@ type ValConfig = {
69
69
  stageStyle: Val<string>;
70
70
  defaultBoxBodyStyle: Val<string | null>;
71
71
  defaultBoxStageStyle: Val<string | null>;
72
+ theme: Val<TeleBoxManagerThemeConfig | null>;
72
73
  };
73
74
 
74
75
  type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> &
@@ -92,7 +93,7 @@ export class TeleBoxManager {
92
93
  stageStyle = "",
93
94
  defaultBoxBodyStyle = null,
94
95
  defaultBoxStageStyle = null,
95
- theme = {},
96
+ theme = null,
96
97
  }: TeleBoxManagerConfig = {}) {
97
98
  this._sideEffect = new SideEffectManager();
98
99
 
@@ -221,6 +222,10 @@ export class TeleBoxManager {
221
222
  : TELE_BOX_STATE.Normal
222
223
  );
223
224
 
225
+ const theme$ = new Val<TeleBoxManagerThemeConfig | null>(theme, {
226
+ compare: shallowequal,
227
+ });
228
+
224
229
  const readonlyValConfig: ReadonlyValConfig = {
225
230
  darkMode: darkMode$,
226
231
  state: state$,
@@ -243,6 +248,7 @@ export class TeleBoxManager {
243
248
  stageStyle: stageStyle$,
244
249
  defaultBoxBodyStyle: defaultBoxBodyStyle$,
245
250
  defaultBoxStageStyle: defaultBoxStageStyle$,
251
+ theme: theme$,
246
252
  };
247
253
 
248
254
  withValueEnhancer(this, valConfig, valManager);
@@ -334,9 +340,20 @@ export class TeleBoxManager {
334
340
  minimized
335
341
  );
336
342
  }),
337
- containerStyle$.subscribe((containerStyle) => {
338
- this.$container.style.cssText = containerStyle;
339
- }),
343
+ combine([containerStyle$, theme$]).subscribe(
344
+ ([containerStyle, theme]) => {
345
+ this.$container.style.cssText = containerStyle;
346
+ if (theme) {
347
+ Object.keys(theme).forEach((key) => {
348
+ this.$container.style.setProperty(
349
+ `--tele-${key}`,
350
+ theme[key as keyof TeleBoxManagerThemeConfig] ??
351
+ null
352
+ );
353
+ });
354
+ }
355
+ }
356
+ ),
340
357
  stageStyle$.subscribe((stageStyle) => {
341
358
  this.$stage.style.cssText = stageStyle;
342
359
  this.$stage.style.width = stageRect$.value.width + "px";
@@ -624,15 +641,6 @@ export class TeleBoxManager {
624
641
  return deletedBoxes;
625
642
  }
626
643
 
627
- public setTheme(theme: TeleBoxManagerThemeConfig): void {
628
- Object.keys(theme).forEach((key) => {
629
- this.$container.style.setProperty(
630
- `--tele-${key}`,
631
- theme[key as keyof TeleBoxManagerThemeConfig] ?? null
632
- );
633
- });
634
- }
635
-
636
644
  /**
637
645
  * Mount manager to a container element.
638
646
  */
@@ -32,7 +32,7 @@ export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
32
32
  /** Custom `style` attribute value for stage area of all boxes. Can be overwritten by box. */
33
33
  readonly defaultBoxStageStyle?: string | null;
34
34
  /** Theme variable */
35
- readonly theme?: TeleBoxManagerThemeConfig;
35
+ readonly theme?: TeleBoxManagerThemeConfig | null;
36
36
  }
37
37
 
38
38
  type TeleBoxManagerBoxConfigBaseProps =