@netless/telebox-insider 1.0.0-alpha.34 → 1.0.0-alpha.37
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/TeleBoxManager/index.d.ts +1 -1
- package/dist/TeleBoxManager/typings.d.ts +1 -1
- package/dist/telebox-insider.cjs.js +26 -15
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +26 -15
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBoxManager/MaxTitleBar/index.ts +6 -4
- package/src/TeleBoxManager/index.ts +30 -16
- package/src/TeleBoxManager/typings.ts +1 -1
package/package.json
CHANGED
|
@@ -123,10 +123,12 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
123
123
|
this.$titles,
|
|
124
124
|
"wheel",
|
|
125
125
|
(ev) => {
|
|
126
|
-
(ev.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
if (!ev.deltaX) {
|
|
127
|
+
(ev.currentTarget as HTMLElement).scrollBy({
|
|
128
|
+
left: ev.deltaY > 0 ? 250 : -250,
|
|
129
|
+
behavior: "smooth",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
130
132
|
},
|
|
131
133
|
{ passive: false },
|
|
132
134
|
"max-render-wheel-titles"
|
|
@@ -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
|
|
|
@@ -185,9 +186,15 @@ export class TeleBoxManager {
|
|
|
185
186
|
const handler = (evt: MediaQueryListEvent): void => {
|
|
186
187
|
prefersDark$.setValue(evt.matches);
|
|
187
188
|
};
|
|
188
|
-
prefersDarkMatch.addEventListener
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
if (prefersDarkMatch.addEventListener) {
|
|
190
|
+
prefersDarkMatch.addEventListener("change", handler);
|
|
191
|
+
return () =>
|
|
192
|
+
prefersDarkMatch.removeEventListener("change", handler);
|
|
193
|
+
} else {
|
|
194
|
+
// Old Safari
|
|
195
|
+
prefersDarkMatch.addListener(handler);
|
|
196
|
+
return () => prefersDarkMatch.removeListener(handler);
|
|
197
|
+
}
|
|
191
198
|
});
|
|
192
199
|
}
|
|
193
200
|
|
|
@@ -221,6 +228,10 @@ export class TeleBoxManager {
|
|
|
221
228
|
: TELE_BOX_STATE.Normal
|
|
222
229
|
);
|
|
223
230
|
|
|
231
|
+
const theme$ = new Val<TeleBoxManagerThemeConfig | null>(theme, {
|
|
232
|
+
compare: shallowequal,
|
|
233
|
+
});
|
|
234
|
+
|
|
224
235
|
const readonlyValConfig: ReadonlyValConfig = {
|
|
225
236
|
darkMode: darkMode$,
|
|
226
237
|
state: state$,
|
|
@@ -243,6 +254,7 @@ export class TeleBoxManager {
|
|
|
243
254
|
stageStyle: stageStyle$,
|
|
244
255
|
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
|
245
256
|
defaultBoxStageStyle: defaultBoxStageStyle$,
|
|
257
|
+
theme: theme$,
|
|
246
258
|
};
|
|
247
259
|
|
|
248
260
|
withValueEnhancer(this, valConfig, valManager);
|
|
@@ -334,9 +346,20 @@ export class TeleBoxManager {
|
|
|
334
346
|
minimized
|
|
335
347
|
);
|
|
336
348
|
}),
|
|
337
|
-
containerStyle
|
|
338
|
-
|
|
339
|
-
|
|
349
|
+
combine([containerStyle$, theme$]).subscribe(
|
|
350
|
+
([containerStyle, theme]) => {
|
|
351
|
+
this.$container.style.cssText = containerStyle;
|
|
352
|
+
if (theme) {
|
|
353
|
+
Object.keys(theme).forEach((key) => {
|
|
354
|
+
this.$container.style.setProperty(
|
|
355
|
+
`--tele-${key}`,
|
|
356
|
+
theme[key as keyof TeleBoxManagerThemeConfig] ??
|
|
357
|
+
null
|
|
358
|
+
);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
),
|
|
340
363
|
stageStyle$.subscribe((stageStyle) => {
|
|
341
364
|
this.$stage.style.cssText = stageStyle;
|
|
342
365
|
this.$stage.style.width = stageRect$.value.width + "px";
|
|
@@ -624,15 +647,6 @@ export class TeleBoxManager {
|
|
|
624
647
|
return deletedBoxes;
|
|
625
648
|
}
|
|
626
649
|
|
|
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
650
|
/**
|
|
637
651
|
* Mount manager to a container element.
|
|
638
652
|
*/
|
|
@@ -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 =
|