@netless/telebox-insider 1.0.0-alpha.3 → 1.0.0-alpha.30
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/TeleBox/index.d.ts +53 -35
- package/dist/TeleBox/typings.d.ts +22 -10
- package/dist/TeleBox/utils.d.ts +5 -0
- package/dist/TeleBoxCollector/index.d.ts +7 -8
- package/dist/TeleBoxManager/MaxTitleBar/index.d.ts +1 -1
- package/dist/TeleBoxManager/index.d.ts +15 -5
- package/dist/TeleBoxManager/typings.d.ts +50 -6
- package/dist/TeleTitleBar/DefaultTitleBar/index.d.ts +4 -12
- package/dist/TeleTitleBar/typings.d.ts +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/style.css +650 -1
- package/dist/telebox-insider.cjs.js +1647 -1
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +1629 -1
- package/dist/telebox-insider.es.js.map +1 -1
- package/dist/utils.d.ts +0 -1
- package/package.json +3 -3
- package/src/TeleBox/index.ts +403 -290
- package/src/TeleBox/style.scss +13 -25
- package/src/TeleBox/style.shadow.scss +77 -0
- package/src/TeleBox/typings.ts +22 -10
- package/src/TeleBox/utils.ts +32 -0
- package/src/TeleBoxCollector/index.ts +41 -38
- package/src/TeleBoxCollector/style.scss +6 -4
- package/src/TeleBoxManager/MaxTitleBar/index.ts +3 -28
- package/src/TeleBoxManager/MaxTitleBar/style.scss +18 -16
- package/src/TeleBoxManager/index.ts +184 -77
- package/src/TeleBoxManager/style.scss +55 -0
- package/src/TeleBoxManager/typings.ts +69 -7
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +47 -61
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +30 -10
- package/src/TeleTitleBar/typings.ts +2 -2
- package/src/index.ts +0 -2
- package/src/scss/variables.scss +72 -0
- package/src/utils.ts +0 -6
- package/dist/TeleStage/index.d.ts +0 -21
- package/src/TeleStage/index.ts +0 -178
- package/src/TeleStage/style.scss +0 -49
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./style.scss";
|
|
2
|
+
|
|
1
3
|
import shallowequal from "shallowequal";
|
|
2
4
|
import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
|
|
3
5
|
import { SideEffectManager } from "side-effect-manager";
|
|
@@ -6,11 +8,13 @@ import type {
|
|
|
6
8
|
ValEnhancedResult,
|
|
7
9
|
ReadonlyValEnhancedResult,
|
|
8
10
|
} from "value-enhancer";
|
|
11
|
+
import { derive } from "value-enhancer";
|
|
9
12
|
import {
|
|
10
13
|
combine,
|
|
11
14
|
Val,
|
|
12
15
|
withValueEnhancer,
|
|
13
16
|
withReadonlyValueEnhancer,
|
|
17
|
+
ValManager,
|
|
14
18
|
} from "value-enhancer";
|
|
15
19
|
import Emittery from "emittery";
|
|
16
20
|
import type {
|
|
@@ -32,11 +36,13 @@ import type {
|
|
|
32
36
|
TeleBoxManagerConfig,
|
|
33
37
|
TeleBoxManagerCreateConfig,
|
|
34
38
|
TeleBoxManagerEventConfig,
|
|
39
|
+
TeleBoxFullscreen,
|
|
35
40
|
TeleBoxManagerQueryConfig,
|
|
41
|
+
TeleBoxManagerThemeConfig,
|
|
36
42
|
TeleBoxManagerUpdateConfig,
|
|
37
43
|
} from "./typings";
|
|
38
44
|
import { MaxTitleBar } from "./MaxTitleBar";
|
|
39
|
-
import {
|
|
45
|
+
import { calcStageRect } from "../TeleBox/utils";
|
|
40
46
|
|
|
41
47
|
export * from "./typings";
|
|
42
48
|
export * from "./constants";
|
|
@@ -49,16 +55,20 @@ type ReadonlyValConfig = {
|
|
|
49
55
|
root: Val<HTMLElement | null>;
|
|
50
56
|
rootRect: Val<TeleBoxRect>;
|
|
51
57
|
stageRect: ReadonlyVal<TeleBoxRect>;
|
|
58
|
+
minimized: ReadonlyVal<boolean, boolean>;
|
|
59
|
+
maximized: ReadonlyVal<boolean, boolean>;
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
type ValConfig = {
|
|
63
|
+
fullscreen: Val<TeleBoxFullscreen>;
|
|
55
64
|
prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
|
|
56
65
|
readonly: Val<boolean, boolean>;
|
|
57
|
-
minimized: Val<boolean, boolean>;
|
|
58
|
-
maximized: Val<boolean, boolean>;
|
|
59
66
|
fence: Val<boolean, boolean>;
|
|
60
67
|
stageRatio: Val<number, boolean>;
|
|
61
|
-
|
|
68
|
+
containerStyle: Val<string>;
|
|
69
|
+
stageStyle: Val<string>;
|
|
70
|
+
defaultBoxBodyStyle: Val<string | null>;
|
|
71
|
+
defaultBoxStageStyle: Val<string | null>;
|
|
62
72
|
};
|
|
63
73
|
|
|
64
74
|
type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> &
|
|
@@ -69,27 +79,52 @@ export interface TeleBoxManager extends CombinedValEnhancedResult {}
|
|
|
69
79
|
export class TeleBoxManager {
|
|
70
80
|
public constructor({
|
|
71
81
|
root = null,
|
|
82
|
+
fullscreen = false,
|
|
72
83
|
prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
|
|
73
84
|
minimized = false,
|
|
74
85
|
maximized = false,
|
|
75
|
-
fence =
|
|
86
|
+
fence = true,
|
|
76
87
|
collector,
|
|
77
88
|
namespace = "telebox",
|
|
78
89
|
readonly = false,
|
|
79
90
|
stageRatio = -1,
|
|
80
|
-
|
|
91
|
+
containerStyle = "",
|
|
92
|
+
stageStyle = "",
|
|
93
|
+
defaultBoxBodyStyle = null,
|
|
94
|
+
defaultBoxStageStyle = null,
|
|
95
|
+
theme = {},
|
|
81
96
|
}: TeleBoxManagerConfig = {}) {
|
|
82
97
|
this._sideEffect = new SideEffectManager();
|
|
83
98
|
|
|
84
99
|
this.namespace = namespace;
|
|
85
100
|
|
|
101
|
+
const valManager = new ValManager();
|
|
102
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
|
103
|
+
|
|
86
104
|
const root$ = new Val(root);
|
|
87
105
|
const readonly$ = new Val(readonly);
|
|
88
|
-
const minimized$ = new Val(minimized);
|
|
89
|
-
const maximized$ = new Val(maximized);
|
|
90
106
|
const fence$ = new Val(fence);
|
|
107
|
+
const containerStyle$ = new Val(containerStyle);
|
|
108
|
+
const stageStyle$ = new Val(stageStyle);
|
|
91
109
|
const stageRatio$ = new Val(stageRatio);
|
|
92
|
-
const
|
|
110
|
+
const defaultBoxBodyStyle$ = new Val(defaultBoxBodyStyle);
|
|
111
|
+
const defaultBoxStageStyle$ = new Val(defaultBoxStageStyle);
|
|
112
|
+
const fullscreen$ = new Val(fullscreen);
|
|
113
|
+
|
|
114
|
+
const input_minimized$ = new Val(minimized);
|
|
115
|
+
const input_maximized$ = new Val(maximized);
|
|
116
|
+
const maximized$ = combine(
|
|
117
|
+
[input_maximized$, fullscreen$],
|
|
118
|
+
([maximized, fullscreen]) => (fullscreen ? true : maximized)
|
|
119
|
+
);
|
|
120
|
+
const minimized$ = combine(
|
|
121
|
+
[input_minimized$, fullscreen$],
|
|
122
|
+
([minimized, fullscreen]) => (fullscreen ? false : minimized)
|
|
123
|
+
);
|
|
124
|
+
this.setMaximized = (maximized, skipUpdate) =>
|
|
125
|
+
input_maximized$.setValue(maximized, skipUpdate);
|
|
126
|
+
this.setMinimized = (minimized, skipUpdate) =>
|
|
127
|
+
input_minimized$.setValue(minimized, skipUpdate);
|
|
93
128
|
|
|
94
129
|
const rootRect$ = new Val<TeleBoxRect>(
|
|
95
130
|
{
|
|
@@ -106,16 +141,14 @@ export class TeleBoxManager {
|
|
|
106
141
|
if (!root) {
|
|
107
142
|
return () => void 0;
|
|
108
143
|
}
|
|
109
|
-
const observer = new ResizeObserver((
|
|
110
|
-
const rect =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
}
|
|
144
|
+
const observer = new ResizeObserver(() => {
|
|
145
|
+
const rect = root.getBoundingClientRect();
|
|
146
|
+
rootRect$.setValue({
|
|
147
|
+
x: 0,
|
|
148
|
+
y: 0,
|
|
149
|
+
width: rect.width,
|
|
150
|
+
height: rect.height,
|
|
151
|
+
});
|
|
119
152
|
});
|
|
120
153
|
observer.observe(root);
|
|
121
154
|
return () => observer.disconnect();
|
|
@@ -123,6 +156,10 @@ export class TeleBoxManager {
|
|
|
123
156
|
})
|
|
124
157
|
);
|
|
125
158
|
|
|
159
|
+
const stageRect$ = combine([rootRect$, stageRatio$], calcStageRect, {
|
|
160
|
+
compare: shallowequal,
|
|
161
|
+
});
|
|
162
|
+
|
|
126
163
|
this.boxes$ = new Val<TeleBox[]>([]);
|
|
127
164
|
this.topBox$ = new Val<TeleBox | undefined>(undefined);
|
|
128
165
|
this._sideEffect.addDisposer(
|
|
@@ -184,55 +221,36 @@ export class TeleBoxManager {
|
|
|
184
221
|
: TELE_BOX_STATE.Normal
|
|
185
222
|
);
|
|
186
223
|
|
|
187
|
-
this.collector =
|
|
188
|
-
collector ??
|
|
189
|
-
new TeleBoxCollector({
|
|
190
|
-
minimized$: minimized$,
|
|
191
|
-
readonly$: readonly$,
|
|
192
|
-
darkMode$: darkMode$,
|
|
193
|
-
namespace,
|
|
194
|
-
root$,
|
|
195
|
-
rootRect$,
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const teleStage = new TeleStage({
|
|
199
|
-
namespace,
|
|
200
|
-
rootRect$,
|
|
201
|
-
ratio$: stageRatio$,
|
|
202
|
-
root$,
|
|
203
|
-
highlightStage$: combine(
|
|
204
|
-
[highlightStage$, maximized$],
|
|
205
|
-
([highlightStage, maximized]) => highlightStage && !maximized
|
|
206
|
-
),
|
|
207
|
-
});
|
|
208
|
-
this._sideEffect.addDisposer(() => teleStage.destroy());
|
|
209
|
-
|
|
210
224
|
const readonlyValConfig: ReadonlyValConfig = {
|
|
211
225
|
darkMode: darkMode$,
|
|
212
226
|
state: state$,
|
|
213
227
|
root: root$,
|
|
214
228
|
rootRect: rootRect$,
|
|
215
|
-
stageRect:
|
|
229
|
+
stageRect: stageRect$,
|
|
230
|
+
minimized: minimized$,
|
|
231
|
+
maximized: maximized$,
|
|
216
232
|
};
|
|
217
233
|
|
|
218
|
-
withReadonlyValueEnhancer(this, readonlyValConfig);
|
|
234
|
+
withReadonlyValueEnhancer(this, readonlyValConfig, valManager);
|
|
219
235
|
|
|
220
236
|
const valConfig: ValConfig = {
|
|
237
|
+
fullscreen: fullscreen$,
|
|
221
238
|
prefersColorScheme: prefersColorScheme$,
|
|
222
239
|
readonly: readonly$,
|
|
223
240
|
fence: fence$,
|
|
224
|
-
minimized: minimized$,
|
|
225
|
-
maximized: maximized$,
|
|
226
241
|
stageRatio: stageRatio$,
|
|
227
|
-
|
|
242
|
+
containerStyle: containerStyle$,
|
|
243
|
+
stageStyle: stageStyle$,
|
|
244
|
+
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
|
245
|
+
defaultBoxStageStyle: defaultBoxStageStyle$,
|
|
228
246
|
};
|
|
229
247
|
|
|
230
|
-
withValueEnhancer(this, valConfig);
|
|
248
|
+
withValueEnhancer(this, valConfig, valManager);
|
|
231
249
|
|
|
232
250
|
const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
|
|
233
251
|
|
|
234
|
-
const checkFocusBox = (ev:
|
|
235
|
-
if (readonly$.value) {
|
|
252
|
+
const checkFocusBox = (ev: PointerEvent): void => {
|
|
253
|
+
if (!ev.isPrimary || readonly$.value) {
|
|
236
254
|
return;
|
|
237
255
|
}
|
|
238
256
|
|
|
@@ -263,33 +281,108 @@ export class TeleBoxManager {
|
|
|
263
281
|
|
|
264
282
|
this._sideEffect.addEventListener(
|
|
265
283
|
window,
|
|
266
|
-
"
|
|
267
|
-
checkFocusBox,
|
|
268
|
-
true
|
|
269
|
-
);
|
|
270
|
-
this._sideEffect.addEventListener(
|
|
271
|
-
window,
|
|
272
|
-
"touchstart",
|
|
284
|
+
"pointerdown",
|
|
273
285
|
checkFocusBox,
|
|
274
286
|
true
|
|
275
287
|
);
|
|
276
288
|
|
|
289
|
+
this.$container = document.createElement("div");
|
|
290
|
+
this.$container.className = this.wrapClassName("manager-container");
|
|
291
|
+
this.setTheme(theme);
|
|
292
|
+
|
|
293
|
+
this.$stage = document.createElement("div");
|
|
294
|
+
this.$stage.className = this.wrapClassName("manager-stage");
|
|
295
|
+
this.$container.appendChild(this.$stage);
|
|
296
|
+
|
|
297
|
+
this._sideEffect.addDisposer([
|
|
298
|
+
darkMode$.subscribe((darkMode) => {
|
|
299
|
+
this.$container.classList.toggle(
|
|
300
|
+
this.wrapClassName("color-scheme-dark"),
|
|
301
|
+
darkMode
|
|
302
|
+
);
|
|
303
|
+
this.$container.classList.toggle(
|
|
304
|
+
this.wrapClassName("color-scheme-light"),
|
|
305
|
+
!darkMode
|
|
306
|
+
);
|
|
307
|
+
}),
|
|
308
|
+
fullscreen$.subscribe((fullscreen) => {
|
|
309
|
+
this.$container.classList.toggle(
|
|
310
|
+
this.wrapClassName("is-fullscreen"),
|
|
311
|
+
Boolean(fullscreen)
|
|
312
|
+
);
|
|
313
|
+
}),
|
|
314
|
+
combine(
|
|
315
|
+
[this.boxes$, fullscreen$],
|
|
316
|
+
([boxes, fullscreen]) =>
|
|
317
|
+
fullscreen === "no-titlebar" ||
|
|
318
|
+
(fullscreen === true && boxes.length <= 1)
|
|
319
|
+
).subscribe((hideSingleTabTitlebar) => {
|
|
320
|
+
this.$container.classList.toggle(
|
|
321
|
+
this.wrapClassName("hide-fullscreen-titlebar"),
|
|
322
|
+
hideSingleTabTitlebar
|
|
323
|
+
);
|
|
324
|
+
}),
|
|
325
|
+
maximized$.subscribe((maximized) => {
|
|
326
|
+
this.$container.classList.toggle(
|
|
327
|
+
this.wrapClassName("is-maximized"),
|
|
328
|
+
maximized
|
|
329
|
+
);
|
|
330
|
+
}),
|
|
331
|
+
minimized$.subscribe((minimized) => {
|
|
332
|
+
this.$container.classList.toggle(
|
|
333
|
+
this.wrapClassName("is-minimized"),
|
|
334
|
+
minimized
|
|
335
|
+
);
|
|
336
|
+
}),
|
|
337
|
+
containerStyle$.subscribe((containerStyle) => {
|
|
338
|
+
this.$container.style.cssText = containerStyle;
|
|
339
|
+
}),
|
|
340
|
+
stageStyle$.subscribe((stageStyle) => {
|
|
341
|
+
this.$stage.style.cssText = stageStyle;
|
|
342
|
+
this.$stage.style.width = stageRect$.value.width + "px";
|
|
343
|
+
this.$stage.style.height = stageRect$.value.height + "px";
|
|
344
|
+
}),
|
|
345
|
+
stageRect$.subscribe((stageRect) => {
|
|
346
|
+
this.$stage.style.width = stageRect.width + "px";
|
|
347
|
+
this.$stage.style.height = stageRect.height + "px";
|
|
348
|
+
}),
|
|
349
|
+
root$.subscribe((root) => {
|
|
350
|
+
if (root) {
|
|
351
|
+
root.appendChild(this.$container);
|
|
352
|
+
} else if (this.$container.parentElement) {
|
|
353
|
+
this.$container.remove();
|
|
354
|
+
}
|
|
355
|
+
}),
|
|
356
|
+
]);
|
|
357
|
+
|
|
358
|
+
this.collector =
|
|
359
|
+
collector ??
|
|
360
|
+
new TeleBoxCollector({
|
|
361
|
+
minimized$: minimized$,
|
|
362
|
+
readonly$: readonly$,
|
|
363
|
+
darkMode$: darkMode$,
|
|
364
|
+
namespace,
|
|
365
|
+
root: this.$container,
|
|
366
|
+
onClick: () => input_minimized$.setValue(false),
|
|
367
|
+
});
|
|
368
|
+
|
|
277
369
|
this.titleBar = new MaxTitleBar({
|
|
278
370
|
namespace: this.namespace,
|
|
371
|
+
title$: derive(this.topBox$, (topBox) => topBox?.title || ""),
|
|
279
372
|
boxes$: this.boxes$,
|
|
280
373
|
darkMode$: darkMode$,
|
|
281
374
|
readonly$: readonly$,
|
|
282
375
|
state$: state$,
|
|
283
|
-
root$,
|
|
284
376
|
rootRect$: rootRect$,
|
|
377
|
+
root: this.$container,
|
|
285
378
|
onEvent: (event): void => {
|
|
286
379
|
switch (event.type) {
|
|
287
380
|
case TELE_BOX_DELEGATE_EVENT.Maximize: {
|
|
288
|
-
|
|
381
|
+
this.setMaximized(!maximized$.value);
|
|
289
382
|
break;
|
|
290
383
|
}
|
|
291
384
|
case TELE_BOX_DELEGATE_EVENT.Minimize: {
|
|
292
|
-
|
|
385
|
+
this.setMinimized(true);
|
|
293
386
|
break;
|
|
294
387
|
}
|
|
295
388
|
case TELE_BOX_EVENT.Close: {
|
|
@@ -334,6 +427,10 @@ export class TeleBoxManager {
|
|
|
334
427
|
]);
|
|
335
428
|
}
|
|
336
429
|
|
|
430
|
+
public readonly $container: HTMLDivElement;
|
|
431
|
+
|
|
432
|
+
public readonly $stage: HTMLDivElement;
|
|
433
|
+
|
|
337
434
|
public get boxes(): ReadonlyArray<TeleBox> {
|
|
338
435
|
return this.boxes$.value;
|
|
339
436
|
}
|
|
@@ -351,6 +448,9 @@ export class TeleBoxManager {
|
|
|
351
448
|
|
|
352
449
|
public readonly namespace: string;
|
|
353
450
|
|
|
451
|
+
public setMinimized: (minimized: boolean, skipUpdate?: boolean) => void;
|
|
452
|
+
public setMaximized: (maximized: boolean, skipUpdate?: boolean) => void;
|
|
453
|
+
|
|
354
454
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
355
455
|
public setState(state: TeleBoxState, skipUpdate = false): this {
|
|
356
456
|
switch (state) {
|
|
@@ -382,17 +482,18 @@ export class TeleBoxManager {
|
|
|
382
482
|
...config,
|
|
383
483
|
...(smartPosition ? this.smartPosition(config) : {}),
|
|
384
484
|
namespace: this.namespace,
|
|
385
|
-
root
|
|
485
|
+
root: this.$stage,
|
|
386
486
|
darkMode$: this._darkMode$,
|
|
387
487
|
maximized$: this._maximized$,
|
|
388
488
|
minimized$: this._minimized$,
|
|
389
489
|
fence$: this._fence$,
|
|
390
490
|
rootRect$: this._rootRect$,
|
|
391
491
|
managerStageRect$: this._stageRect$,
|
|
392
|
-
|
|
492
|
+
managerStageRatio$: this._stageRatio$,
|
|
393
493
|
readonly$: this._readonly$,
|
|
394
494
|
collectorRect$: this.collector._rect$,
|
|
395
|
-
|
|
495
|
+
defaultBoxBodyStyle$: this._defaultBoxBodyStyle$,
|
|
496
|
+
defaultBoxStageStyle$: this._defaultBoxStageStyle$,
|
|
396
497
|
});
|
|
397
498
|
|
|
398
499
|
if (box.focus) {
|
|
@@ -523,6 +624,15 @@ export class TeleBoxManager {
|
|
|
523
624
|
return deletedBoxes;
|
|
524
625
|
}
|
|
525
626
|
|
|
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
|
+
|
|
526
636
|
/**
|
|
527
637
|
* Mount manager to a container element.
|
|
528
638
|
*/
|
|
@@ -659,12 +769,15 @@ export class TeleBoxManager {
|
|
|
659
769
|
if (config.draggable != null) {
|
|
660
770
|
box._draggable$.setValue(config.draggable, skipUpdate);
|
|
661
771
|
}
|
|
662
|
-
if (config.
|
|
663
|
-
box.
|
|
772
|
+
if (config.boxRatio != null) {
|
|
773
|
+
box._boxRatio$.setValue(config.boxRatio, skipUpdate);
|
|
664
774
|
}
|
|
665
775
|
if (config.zIndex != null) {
|
|
666
776
|
box._zIndex$.setValue(config.zIndex, skipUpdate);
|
|
667
777
|
}
|
|
778
|
+
if (config.stageRatio !== undefined) {
|
|
779
|
+
box.setStageRatio(config.stageRatio, skipUpdate);
|
|
780
|
+
}
|
|
668
781
|
if (config.content != null) {
|
|
669
782
|
box.mountContent(config.content);
|
|
670
783
|
}
|
|
@@ -690,33 +803,27 @@ export class TeleBoxManager {
|
|
|
690
803
|
const topBox = this.topBox;
|
|
691
804
|
|
|
692
805
|
if (x == null) {
|
|
693
|
-
let pxX =
|
|
806
|
+
let pxX = 20;
|
|
694
807
|
if (topBox) {
|
|
695
808
|
const pxPreferredX = topBox.pxIntrinsicCoord.x + 20;
|
|
696
809
|
const pxIntrinsicWidth = width * stageRect.width;
|
|
697
|
-
if (
|
|
698
|
-
pxPreferredX + pxIntrinsicWidth <=
|
|
699
|
-
stageRect.x + stageRect.width
|
|
700
|
-
) {
|
|
810
|
+
if (pxPreferredX + pxIntrinsicWidth <= stageRect.width) {
|
|
701
811
|
pxX = pxPreferredX;
|
|
702
812
|
}
|
|
703
813
|
}
|
|
704
|
-
x =
|
|
814
|
+
x = pxX / stageRect.width;
|
|
705
815
|
}
|
|
706
816
|
|
|
707
817
|
if (y == null) {
|
|
708
|
-
let pxY =
|
|
818
|
+
let pxY = 20;
|
|
709
819
|
if (topBox) {
|
|
710
820
|
const pxPreferredY = topBox.pxIntrinsicCoord.y + 20;
|
|
711
821
|
const pxIntrinsicHeight = height * stageRect.height;
|
|
712
|
-
if (
|
|
713
|
-
pxPreferredY + pxIntrinsicHeight <=
|
|
714
|
-
stageRect.y + stageRect.height
|
|
715
|
-
) {
|
|
822
|
+
if (pxPreferredY + pxIntrinsicHeight <= stageRect.height) {
|
|
716
823
|
pxY = pxPreferredY;
|
|
717
824
|
}
|
|
718
825
|
}
|
|
719
|
-
y =
|
|
826
|
+
y = pxY / stageRect.height;
|
|
720
827
|
}
|
|
721
828
|
|
|
722
829
|
return { x, y, width, height };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import "../scss/variables.scss";
|
|
2
|
+
@import "../scss/mixins.scss";
|
|
3
|
+
|
|
4
|
+
.#{$namespace}-manager-container {
|
|
5
|
+
position: relative;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
@include clr-root();
|
|
13
|
+
@include clr(background, managerContainerBackground);
|
|
14
|
+
|
|
15
|
+
&.#{$namespace}-is-maximized,
|
|
16
|
+
&.#{$namespace}-is-minimized {
|
|
17
|
+
& > .#{$namespace}-manager-stage {
|
|
18
|
+
overflow: visible;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.#{$namespace}-is-fullscreen {
|
|
23
|
+
.#{$namespace}-titlebar-icon-maximize,
|
|
24
|
+
.#{$namespace}-titlebar-icon-minimize {
|
|
25
|
+
display: none !important;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.#{$namespace}-hide-fullscreen-titlebar {
|
|
30
|
+
.#{$namespace}-titlebar {
|
|
31
|
+
display: none !important;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.#{$namespace}-manager-stage {
|
|
37
|
+
position: relative;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
@include clr(background, managerStageBackground);
|
|
40
|
+
@include clr(box-shadow, managerStageShadow);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.#{$namespace}-color-scheme-dark {
|
|
44
|
+
color-scheme: dark;
|
|
45
|
+
|
|
46
|
+
&.#{$namespace}-manager-container {
|
|
47
|
+
@include clr-root-dark();
|
|
48
|
+
@include clr-dark(background, managerContainerBackground);
|
|
49
|
+
|
|
50
|
+
& > .#{$namespace}-manager-stage {
|
|
51
|
+
@include clr-dark(background, managerStageBackground);
|
|
52
|
+
@include clr-dark(box-shadow, managerStageShadow);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -7,6 +7,8 @@ import type { TELE_BOX_MANAGER_EVENT } from "./constants";
|
|
|
7
7
|
export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
|
|
8
8
|
/** Element to mount boxes. */
|
|
9
9
|
readonly root?: HTMLElement | null;
|
|
10
|
+
/** Fullscreen mode. Default false. */
|
|
11
|
+
readonly fullscreen?: TeleBoxFullscreen;
|
|
10
12
|
/** Stage area height/with ratio. No ratio if <= 0. Default -1. */
|
|
11
13
|
readonly stageRatio?: number;
|
|
12
14
|
/** Where the minimized boxes go. */
|
|
@@ -21,8 +23,16 @@ export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
|
|
|
21
23
|
readonly minimized?: boolean;
|
|
22
24
|
/** Is box readonly */
|
|
23
25
|
readonly readonly?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
readonly
|
|
26
|
+
/** Custom styles for telebox manager container */
|
|
27
|
+
readonly containerStyle?: string;
|
|
28
|
+
/** Custom styles for telebox manager stage */
|
|
29
|
+
readonly stageStyle?: string;
|
|
30
|
+
/** Custom `style` attribute value for content area of all boxes. Can be overwritten by box. */
|
|
31
|
+
readonly defaultBoxBodyStyle?: string | null;
|
|
32
|
+
/** Custom `style` attribute value for stage area of all boxes. Can be overwritten by box. */
|
|
33
|
+
readonly defaultBoxStageStyle?: string | null;
|
|
34
|
+
/** Theme variable */
|
|
35
|
+
readonly theme?: TeleBoxManagerThemeConfig;
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
type TeleBoxManagerBoxConfigBaseProps =
|
|
@@ -36,12 +46,22 @@ type TeleBoxManagerBoxConfigBaseProps =
|
|
|
36
46
|
| "y"
|
|
37
47
|
| "resizable"
|
|
38
48
|
| "draggable"
|
|
39
|
-
| "
|
|
40
|
-
| "zIndex"
|
|
49
|
+
| "boxRatio"
|
|
50
|
+
| "zIndex"
|
|
51
|
+
| "stageRatio";
|
|
41
52
|
|
|
42
53
|
export type TeleBoxManagerCreateConfig = Pick<
|
|
43
54
|
TeleBoxConfig,
|
|
44
|
-
|
|
55
|
+
| TeleBoxManagerBoxConfigBaseProps
|
|
56
|
+
| "content"
|
|
57
|
+
| "stage"
|
|
58
|
+
| "footer"
|
|
59
|
+
| "styles"
|
|
60
|
+
| "bodyStyle"
|
|
61
|
+
| "stageStyle"
|
|
62
|
+
| "id"
|
|
63
|
+
| "focus"
|
|
64
|
+
| "enableShadowDOM"
|
|
45
65
|
>;
|
|
46
66
|
|
|
47
67
|
export type TeleBoxManagerQueryConfig = Pick<
|
|
@@ -50,7 +70,8 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
50
70
|
| "visible"
|
|
51
71
|
| "resizable"
|
|
52
72
|
| "draggable"
|
|
53
|
-
| "
|
|
73
|
+
| "boxRatio"
|
|
74
|
+
| "stageRatio"
|
|
54
75
|
| "zIndex"
|
|
55
76
|
| "id"
|
|
56
77
|
| "focus"
|
|
@@ -58,7 +79,7 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
58
79
|
|
|
59
80
|
export type TeleBoxManagerUpdateConfig = Pick<
|
|
60
81
|
TeleBoxConfig,
|
|
61
|
-
TeleBoxManagerBoxConfigBaseProps | "content" | "footer"
|
|
82
|
+
TeleBoxManagerBoxConfigBaseProps | "content" | "stage" | "footer"
|
|
62
83
|
>;
|
|
63
84
|
|
|
64
85
|
type CheckTeleBoxManagerConfig<
|
|
@@ -84,3 +105,44 @@ export type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
|
|
|
84
105
|
}>;
|
|
85
106
|
|
|
86
107
|
export type TeleBoxManagerEvent = keyof TeleBoxManagerEventConfig;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fullscreen mode.
|
|
111
|
+
* - `true`: fullscreen mode. hide titlebar for single tab.
|
|
112
|
+
* - `false`: normal mode.
|
|
113
|
+
* - `"no-titlebar"`: always hide titlebar
|
|
114
|
+
* - `"always-titlebar"`: always show titlebar
|
|
115
|
+
*/
|
|
116
|
+
export type TeleBoxFullscreen = boolean | "no-titlebar" | "always-titlebar";
|
|
117
|
+
|
|
118
|
+
export type TeleBoxManagerThemeConfig = {
|
|
119
|
+
managerContainerBackground?: string | null;
|
|
120
|
+
managerStageBackground?: string | null;
|
|
121
|
+
managerStageShadow?: string | null;
|
|
122
|
+
|
|
123
|
+
boxContainerBackground?: string | null;
|
|
124
|
+
boxStageBackground?: string | null;
|
|
125
|
+
boxStageShadow?: string | null;
|
|
126
|
+
|
|
127
|
+
boxColor?: string | null;
|
|
128
|
+
boxBorder?: string | null;
|
|
129
|
+
boxShadow?: string | null;
|
|
130
|
+
boxFooterColor?: string | null;
|
|
131
|
+
boxFooterBackground?: string | null;
|
|
132
|
+
|
|
133
|
+
titlebarColor?: string | null;
|
|
134
|
+
titlebarBackground?: string | null;
|
|
135
|
+
titlebarBorderBottom?: string | null;
|
|
136
|
+
titlebarTabColor?: string | null;
|
|
137
|
+
titlebarTabFocusColor?: string | null;
|
|
138
|
+
titlebarTabBackground?: string | null;
|
|
139
|
+
titlebarTabDividerColor?: string | null;
|
|
140
|
+
|
|
141
|
+
collectorBackground?: string | null;
|
|
142
|
+
collectorShadow?: string | null;
|
|
143
|
+
|
|
144
|
+
titlebarIconMinimize?: string | null;
|
|
145
|
+
titlebarIconMaximize?: string | null;
|
|
146
|
+
titlebarIconMaximizeActive?: string | null;
|
|
147
|
+
titlebarIconClose?: string | null;
|
|
148
|
+
};
|