@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.
@@ -29,6 +29,7 @@ declare type ValConfig = {
29
29
  stageStyle: Val<string>;
30
30
  defaultBoxBodyStyle: Val<string | null>;
31
31
  defaultBoxStageStyle: Val<string | null>;
32
+ theme: Val<TeleBoxManagerThemeConfig | null>;
32
33
  };
33
34
  declare type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> & ReadonlyValEnhancedResult<ReadonlyValConfig>;
34
35
  export interface TeleBoxManager extends CombinedValEnhancedResult {
@@ -86,7 +87,6 @@ export declare class TeleBoxManager {
86
87
  remove(boxOrID: string | TeleBox, skipUpdate?: boolean): ReadonlyTeleBox | undefined;
87
88
  removeTopBox(): ReadonlyTeleBox | undefined;
88
89
  removeAll(skipUpdate?: boolean): ReadonlyTeleBox[];
89
- setTheme(theme: TeleBoxManagerThemeConfig): void;
90
90
  /**
91
91
  * Mount manager to a container element.
92
92
  */
@@ -31,7 +31,7 @@ export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
31
31
  /** Custom `style` attribute value for stage area of all boxes. Can be overwritten by box. */
32
32
  readonly defaultBoxStageStyle?: string | null;
33
33
  /** Theme variable */
34
- readonly theme?: TeleBoxManagerThemeConfig;
34
+ readonly theme?: TeleBoxManagerThemeConfig | null;
35
35
  }
36
36
  declare type TeleBoxManagerBoxConfigBaseProps = "title" | "visible" | "width" | "height" | "minWidth" | "minHeight" | "x" | "y" | "resizable" | "draggable" | "boxRatio" | "zIndex" | "stageRatio";
37
37
  export declare type TeleBoxManagerCreateConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "content" | "stage" | "footer" | "styles" | "bodyStyle" | "stageStyle" | "id" | "focus" | "enableShadowDOM">;
@@ -1109,7 +1109,7 @@ class TeleBoxManager {
1109
1109
  stageStyle = "",
1110
1110
  defaultBoxBodyStyle = null,
1111
1111
  defaultBoxStageStyle = null,
1112
- theme = {}
1112
+ theme = null
1113
1113
  } = {}) {
1114
1114
  this.events = new Emittery__default["default"]();
1115
1115
  this._sideEffect = new sideEffectManager.SideEffectManager();
@@ -1188,6 +1188,9 @@ class TeleBoxManager {
1188
1188
  }));
1189
1189
  const darkMode$ = valueEnhancer.combine([prefersDark$, prefersColorScheme$], ([prefersDark, prefersColorScheme2]) => prefersColorScheme2 === "auto" ? prefersDark : prefersColorScheme2 === "dark");
1190
1190
  const state$ = valueEnhancer.combine([minimized$, maximized$], ([minimized2, maximized2]) => minimized2 ? TELE_BOX_STATE.Minimized : maximized2 ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal);
1191
+ const theme$ = new valueEnhancer.Val(theme, {
1192
+ compare: shallowequal__default["default"]
1193
+ });
1191
1194
  const readonlyValConfig = {
1192
1195
  darkMode: darkMode$,
1193
1196
  state: state$,
@@ -1207,7 +1210,8 @@ class TeleBoxManager {
1207
1210
  containerStyle: containerStyle$,
1208
1211
  stageStyle: stageStyle$,
1209
1212
  defaultBoxBodyStyle: defaultBoxBodyStyle$,
1210
- defaultBoxStageStyle: defaultBoxStageStyle$
1213
+ defaultBoxStageStyle: defaultBoxStageStyle$,
1214
+ theme: theme$
1211
1215
  };
1212
1216
  valueEnhancer.withValueEnhancer(this, valConfig, valManager);
1213
1217
  const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
@@ -1259,8 +1263,14 @@ class TeleBoxManager {
1259
1263
  minimized$.subscribe((minimized2) => {
1260
1264
  this.$container.classList.toggle(this.wrapClassName("is-minimized"), minimized2);
1261
1265
  }),
1262
- containerStyle$.subscribe((containerStyle2) => {
1266
+ valueEnhancer.combine([containerStyle$, theme$]).subscribe(([containerStyle2, theme2]) => {
1263
1267
  this.$container.style.cssText = containerStyle2;
1268
+ if (theme2) {
1269
+ Object.keys(theme2).forEach((key) => {
1270
+ var _a;
1271
+ this.$container.style.setProperty(`--tele-${key}`, (_a = theme2[key]) != null ? _a : null);
1272
+ });
1273
+ }
1264
1274
  }),
1265
1275
  stageStyle$.subscribe((stageStyle2) => {
1266
1276
  this.$stage.style.cssText = stageStyle2;
@@ -1477,12 +1487,6 @@ class TeleBoxManager {
1477
1487
  }
1478
1488
  return deletedBoxes;
1479
1489
  }
1480
- setTheme(theme) {
1481
- Object.keys(theme).forEach((key) => {
1482
- var _a;
1483
- this.$container.style.setProperty(`--tele-${key}`, (_a = theme[key]) != null ? _a : null);
1484
- });
1485
- }
1486
1490
  mount(root) {
1487
1491
  this._root$.setValue(root);
1488
1492
  }