@netless/telebox-insider 1.0.0-alpha.16 → 1.0.0-alpha.19
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 +14 -13
- package/dist/TeleBox/typings.d.ts +12 -8
- package/dist/TeleBox/utils.d.ts +5 -0
- package/dist/TeleBoxManager/index.d.ts +6 -2
- package/dist/TeleBoxManager/typings.d.ts +6 -4
- package/dist/style.css +1 -1
- package/dist/telebox-insider.cjs.js +1 -1
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +1 -1
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +67 -67
- package/src/TeleBox/index.ts +147 -133
- package/src/TeleBox/style.scss +14 -2
- package/src/TeleBox/typings.ts +12 -8
- package/src/TeleBox/utils.ts +32 -0
- package/src/TeleBoxManager/index.ts +79 -38
- package/src/TeleBoxManager/style.scss +39 -0
- package/src/TeleBoxManager/typings.ts +8 -6
- package/src/scss/variables.scss +9 -0
- package/dist/TeleStage/index.d.ts +0 -21
- package/src/TeleStage/index.ts +0 -174
- 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";
|
|
@@ -38,7 +40,7 @@ import type {
|
|
|
38
40
|
TeleBoxManagerUpdateConfig,
|
|
39
41
|
} from "./typings";
|
|
40
42
|
import { MaxTitleBar } from "./MaxTitleBar";
|
|
41
|
-
import {
|
|
43
|
+
import { calcStageRect } from "../TeleBox/utils";
|
|
42
44
|
|
|
43
45
|
export * from "./typings";
|
|
44
46
|
export * from "./constants";
|
|
@@ -60,7 +62,8 @@ type ValConfig = {
|
|
|
60
62
|
maximized: Val<boolean, boolean>;
|
|
61
63
|
fence: Val<boolean, boolean>;
|
|
62
64
|
stageRatio: Val<number, boolean>;
|
|
63
|
-
|
|
65
|
+
containerStyle: Val<string>;
|
|
66
|
+
stageStyle: Val<string>;
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> &
|
|
@@ -74,12 +77,13 @@ export class TeleBoxManager {
|
|
|
74
77
|
prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
|
|
75
78
|
minimized = false,
|
|
76
79
|
maximized = false,
|
|
77
|
-
fence =
|
|
80
|
+
fence = true,
|
|
78
81
|
collector,
|
|
79
82
|
namespace = "telebox",
|
|
80
83
|
readonly = false,
|
|
81
84
|
stageRatio = -1,
|
|
82
|
-
|
|
85
|
+
containerStyle = "",
|
|
86
|
+
stageStyle = "",
|
|
83
87
|
}: TeleBoxManagerConfig = {}) {
|
|
84
88
|
this._sideEffect = new SideEffectManager();
|
|
85
89
|
|
|
@@ -93,8 +97,9 @@ export class TeleBoxManager {
|
|
|
93
97
|
const minimized$ = new Val(minimized);
|
|
94
98
|
const maximized$ = new Val(maximized);
|
|
95
99
|
const fence$ = new Val(fence);
|
|
100
|
+
const containerStyle$ = new Val(containerStyle);
|
|
101
|
+
const stageStyle$ = new Val(stageStyle);
|
|
96
102
|
const stageRatio$ = new Val(stageRatio);
|
|
97
|
-
const highlightStage$ = new Val(highlightStage);
|
|
98
103
|
|
|
99
104
|
const rootRect$ = new Val<TeleBoxRect>(
|
|
100
105
|
{
|
|
@@ -126,6 +131,10 @@ export class TeleBoxManager {
|
|
|
126
131
|
})
|
|
127
132
|
);
|
|
128
133
|
|
|
134
|
+
const stageRect$ = combine([rootRect$, stageRatio$], calcStageRect, {
|
|
135
|
+
compare: shallowequal,
|
|
136
|
+
});
|
|
137
|
+
|
|
129
138
|
this.boxes$ = new Val<TeleBox[]>([]);
|
|
130
139
|
this.topBox$ = new Val<TeleBox | undefined>(undefined);
|
|
131
140
|
this._sideEffect.addDisposer(
|
|
@@ -197,25 +206,12 @@ export class TeleBoxManager {
|
|
|
197
206
|
root$,
|
|
198
207
|
});
|
|
199
208
|
|
|
200
|
-
const teleStage = new TeleStage({
|
|
201
|
-
namespace,
|
|
202
|
-
rootRect$,
|
|
203
|
-
ratio$: stageRatio$,
|
|
204
|
-
root$,
|
|
205
|
-
highlightStage$: combine(
|
|
206
|
-
[highlightStage$, maximized$, minimized$],
|
|
207
|
-
([highlightStage, maximized, minimized]) =>
|
|
208
|
-
highlightStage && (minimized || !maximized)
|
|
209
|
-
),
|
|
210
|
-
});
|
|
211
|
-
this._sideEffect.addDisposer(() => teleStage.destroy());
|
|
212
|
-
|
|
213
209
|
const readonlyValConfig: ReadonlyValConfig = {
|
|
214
210
|
darkMode: darkMode$,
|
|
215
211
|
state: state$,
|
|
216
212
|
root: root$,
|
|
217
213
|
rootRect: rootRect$,
|
|
218
|
-
stageRect:
|
|
214
|
+
stageRect: stageRect$,
|
|
219
215
|
};
|
|
220
216
|
|
|
221
217
|
withReadonlyValueEnhancer(this, readonlyValConfig, valManager);
|
|
@@ -227,7 +223,8 @@ export class TeleBoxManager {
|
|
|
227
223
|
minimized: minimized$,
|
|
228
224
|
maximized: maximized$,
|
|
229
225
|
stageRatio: stageRatio$,
|
|
230
|
-
|
|
226
|
+
containerStyle: containerStyle$,
|
|
227
|
+
stageStyle: stageStyle$,
|
|
231
228
|
};
|
|
232
229
|
|
|
233
230
|
withValueEnhancer(this, valConfig, valManager);
|
|
@@ -336,8 +333,57 @@ export class TeleBoxManager {
|
|
|
336
333
|
}
|
|
337
334
|
}),
|
|
338
335
|
]);
|
|
336
|
+
|
|
337
|
+
this.$container = document.createElement("div");
|
|
338
|
+
this.$container.className = this.wrapClassName("manager-container");
|
|
339
|
+
|
|
340
|
+
this.$stage = document.createElement("div");
|
|
341
|
+
this.$stage.className = this.wrapClassName("manager-stage");
|
|
342
|
+
this.$container.appendChild(this.$stage);
|
|
343
|
+
|
|
344
|
+
this._sideEffect.addDisposer([
|
|
345
|
+
darkMode$.subscribe((darkMode) => {
|
|
346
|
+
this.$container.classList.toggle(
|
|
347
|
+
this.wrapClassName("color-scheme-dark"),
|
|
348
|
+
darkMode
|
|
349
|
+
);
|
|
350
|
+
this.$container.classList.toggle(
|
|
351
|
+
this.wrapClassName("color-scheme-light"),
|
|
352
|
+
!darkMode
|
|
353
|
+
);
|
|
354
|
+
}),
|
|
355
|
+
maximized$.subscribe((maximized) => {
|
|
356
|
+
this.$container.classList.toggle("is-maximized", maximized);
|
|
357
|
+
}),
|
|
358
|
+
minimized$.subscribe((minimized) => {
|
|
359
|
+
this.$container.classList.toggle("is-minimized", minimized);
|
|
360
|
+
}),
|
|
361
|
+
containerStyle$.subscribe((containerStyle) => {
|
|
362
|
+
this.$container.style.cssText = containerStyle;
|
|
363
|
+
}),
|
|
364
|
+
stageStyle$.subscribe((stageStyle) => {
|
|
365
|
+
this.$stage.style.cssText = stageStyle;
|
|
366
|
+
this.$stage.style.width = stageRect$.value.width + "px";
|
|
367
|
+
this.$stage.style.height = stageRect$.value.height + "px";
|
|
368
|
+
}),
|
|
369
|
+
stageRect$.subscribe((stageRect) => {
|
|
370
|
+
this.$stage.style.width = stageRect.width + "px";
|
|
371
|
+
this.$stage.style.height = stageRect.height + "px";
|
|
372
|
+
}),
|
|
373
|
+
root$.subscribe((root) => {
|
|
374
|
+
if (root) {
|
|
375
|
+
root.appendChild(this.$container);
|
|
376
|
+
} else if (this.$container.parentElement) {
|
|
377
|
+
this.$container.remove();
|
|
378
|
+
}
|
|
379
|
+
}),
|
|
380
|
+
]);
|
|
339
381
|
}
|
|
340
382
|
|
|
383
|
+
public readonly $container: HTMLDivElement;
|
|
384
|
+
|
|
385
|
+
public readonly $stage: HTMLDivElement;
|
|
386
|
+
|
|
341
387
|
public get boxes(): ReadonlyArray<TeleBox> {
|
|
342
388
|
return this.boxes$.value;
|
|
343
389
|
}
|
|
@@ -386,7 +432,7 @@ export class TeleBoxManager {
|
|
|
386
432
|
...config,
|
|
387
433
|
...(smartPosition ? this.smartPosition(config) : {}),
|
|
388
434
|
namespace: this.namespace,
|
|
389
|
-
root
|
|
435
|
+
root: this.$stage,
|
|
390
436
|
darkMode$: this._darkMode$,
|
|
391
437
|
maximized$: this._maximized$,
|
|
392
438
|
minimized$: this._minimized$,
|
|
@@ -396,7 +442,8 @@ export class TeleBoxManager {
|
|
|
396
442
|
managerStageRatio$: this._stageRatio$,
|
|
397
443
|
readonly$: this._readonly$,
|
|
398
444
|
collectorRect$: this.collector._rect$,
|
|
399
|
-
|
|
445
|
+
managerContainerStyle$: this._containerStyle$,
|
|
446
|
+
managerStageStyle$: this._stageStyle$,
|
|
400
447
|
});
|
|
401
448
|
|
|
402
449
|
if (box.focus) {
|
|
@@ -663,14 +710,14 @@ export class TeleBoxManager {
|
|
|
663
710
|
if (config.draggable != null) {
|
|
664
711
|
box._draggable$.setValue(config.draggable, skipUpdate);
|
|
665
712
|
}
|
|
666
|
-
if (config.
|
|
667
|
-
box.
|
|
713
|
+
if (config.boxRatio != null) {
|
|
714
|
+
box._boxRatio$.setValue(config.boxRatio, skipUpdate);
|
|
668
715
|
}
|
|
669
716
|
if (config.zIndex != null) {
|
|
670
717
|
box._zIndex$.setValue(config.zIndex, skipUpdate);
|
|
671
718
|
}
|
|
672
|
-
if (config.
|
|
673
|
-
box.
|
|
719
|
+
if (config.contentStageRatio !== undefined) {
|
|
720
|
+
box.setContentStageRatio(config.contentStageRatio, skipUpdate);
|
|
674
721
|
}
|
|
675
722
|
if (config.content != null) {
|
|
676
723
|
box.mountContent(config.content);
|
|
@@ -697,33 +744,27 @@ export class TeleBoxManager {
|
|
|
697
744
|
const topBox = this.topBox;
|
|
698
745
|
|
|
699
746
|
if (x == null) {
|
|
700
|
-
let pxX =
|
|
747
|
+
let pxX = 20;
|
|
701
748
|
if (topBox) {
|
|
702
749
|
const pxPreferredX = topBox.pxIntrinsicCoord.x + 20;
|
|
703
750
|
const pxIntrinsicWidth = width * stageRect.width;
|
|
704
|
-
if (
|
|
705
|
-
pxPreferredX + pxIntrinsicWidth <=
|
|
706
|
-
stageRect.x + stageRect.width
|
|
707
|
-
) {
|
|
751
|
+
if (pxPreferredX + pxIntrinsicWidth <= stageRect.width) {
|
|
708
752
|
pxX = pxPreferredX;
|
|
709
753
|
}
|
|
710
754
|
}
|
|
711
|
-
x =
|
|
755
|
+
x = pxX / stageRect.width;
|
|
712
756
|
}
|
|
713
757
|
|
|
714
758
|
if (y == null) {
|
|
715
|
-
let pxY =
|
|
759
|
+
let pxY = 20;
|
|
716
760
|
if (topBox) {
|
|
717
761
|
const pxPreferredY = topBox.pxIntrinsicCoord.y + 20;
|
|
718
762
|
const pxIntrinsicHeight = height * stageRect.height;
|
|
719
|
-
if (
|
|
720
|
-
pxPreferredY + pxIntrinsicHeight <=
|
|
721
|
-
stageRect.y + stageRect.height
|
|
722
|
-
) {
|
|
763
|
+
if (pxPreferredY + pxIntrinsicHeight <= stageRect.height) {
|
|
723
764
|
pxY = pxPreferredY;
|
|
724
765
|
}
|
|
725
766
|
}
|
|
726
|
-
y =
|
|
767
|
+
y = pxY / stageRect.height;
|
|
727
768
|
}
|
|
728
769
|
|
|
729
770
|
return { x, y, width, height };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import "../scss/variables.scss";
|
|
2
|
+
|
|
3
|
+
.#{$namespace}-manager-container {
|
|
4
|
+
position: relative;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
background: $color-container-background;
|
|
12
|
+
|
|
13
|
+
&.is-maximized,
|
|
14
|
+
&.is-minimized {
|
|
15
|
+
& > .#{$namespace}-manager-stage {
|
|
16
|
+
overflow: visible;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.#{$namespace}-manager-stage {
|
|
22
|
+
position: relative;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
background: $color-stage-background;
|
|
25
|
+
box-shadow: $color-stage-shadow;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.#{$namespace}-color-scheme-dark {
|
|
29
|
+
color-scheme: dark;
|
|
30
|
+
|
|
31
|
+
&.#{$namespace}-manager-container {
|
|
32
|
+
background: $color-container-background-dark;
|
|
33
|
+
|
|
34
|
+
& > .#{$namespace}-manager-stage {
|
|
35
|
+
background: $color-stage-background-dark;
|
|
36
|
+
box-shadow: $color-stage-shadow-dark;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -21,8 +21,10 @@ export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
|
|
|
21
21
|
readonly minimized?: boolean;
|
|
22
22
|
/** Is box readonly */
|
|
23
23
|
readonly readonly?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
readonly
|
|
24
|
+
/** Extra styles for telebox manager container */
|
|
25
|
+
readonly containerStyle?: string;
|
|
26
|
+
/** Extra styles for telebox manager stage */
|
|
27
|
+
readonly stageStyle?: string;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
type TeleBoxManagerBoxConfigBaseProps =
|
|
@@ -36,9 +38,9 @@ type TeleBoxManagerBoxConfigBaseProps =
|
|
|
36
38
|
| "y"
|
|
37
39
|
| "resizable"
|
|
38
40
|
| "draggable"
|
|
39
|
-
| "
|
|
41
|
+
| "boxRatio"
|
|
40
42
|
| "zIndex"
|
|
41
|
-
| "
|
|
43
|
+
| "contentStageRatio";
|
|
42
44
|
|
|
43
45
|
export type TeleBoxManagerCreateConfig = Pick<
|
|
44
46
|
TeleBoxConfig,
|
|
@@ -56,8 +58,8 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
56
58
|
| "visible"
|
|
57
59
|
| "resizable"
|
|
58
60
|
| "draggable"
|
|
59
|
-
| "
|
|
60
|
-
| "
|
|
61
|
+
| "boxRatio"
|
|
62
|
+
| "contentStageRatio"
|
|
61
63
|
| "zIndex"
|
|
62
64
|
| "id"
|
|
63
65
|
| "focus"
|
package/src/scss/variables.scss
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
$namespace: "telebox";
|
|
2
|
+
|
|
2
3
|
$base-z-index: 100;
|
|
3
4
|
$max-titlebar-z-index: $base-z-index + 5000;
|
|
4
5
|
$stage-z-index: $max-titlebar-z-index + 10;
|
|
5
6
|
$collector-z-index: $stage-z-index + 10;
|
|
7
|
+
|
|
8
|
+
$color-container-background: #f9f9f9;
|
|
9
|
+
$color-stage-background: #fff;
|
|
10
|
+
$color-stage-shadow: 0px 0px 16px rgba(0, 0, 0, 0.08);
|
|
11
|
+
|
|
12
|
+
$color-container-background-dark: #25282e;
|
|
13
|
+
$color-stage-background-dark: #272a30;
|
|
14
|
+
$color-stage-shadow-dark: 0px 0px 16px rgba(0, 0, 0, 0.24);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import "./style.scss";
|
|
2
|
-
import type { ReadonlyVal } from "value-enhancer";
|
|
3
|
-
import type { TeleBoxRect } from "../TeleBox/typings";
|
|
4
|
-
export interface TeleStageConfig {
|
|
5
|
-
namespace: string;
|
|
6
|
-
root$: ReadonlyVal<HTMLElement | null>;
|
|
7
|
-
rootRect$: ReadonlyVal<TeleBoxRect>;
|
|
8
|
-
ratio$: ReadonlyVal<number>;
|
|
9
|
-
highlightStage$: ReadonlyVal<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export declare class TeleStage {
|
|
12
|
-
private readonly _sideEffect;
|
|
13
|
-
readonly namespace: string;
|
|
14
|
-
readonly stageRect$: ReadonlyVal<TeleBoxRect>;
|
|
15
|
-
readonly highlightStage$: ReadonlyVal<boolean>;
|
|
16
|
-
$boxStage?: HTMLDivElement;
|
|
17
|
-
constructor({ namespace, rootRect$, ratio$, highlightStage$, root$, }: TeleStageConfig);
|
|
18
|
-
private render;
|
|
19
|
-
destroy(): void;
|
|
20
|
-
wrapClassName(className: string): string;
|
|
21
|
-
}
|
package/src/TeleStage/index.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import "./style.scss";
|
|
2
|
-
|
|
3
|
-
import shallowequal from "shallowequal";
|
|
4
|
-
import { SideEffectManager } from "side-effect-manager";
|
|
5
|
-
import type { ReadonlyVal } from "value-enhancer";
|
|
6
|
-
import { combine } from "value-enhancer";
|
|
7
|
-
import type { TeleBoxRect } from "../TeleBox/typings";
|
|
8
|
-
|
|
9
|
-
export interface TeleStageConfig {
|
|
10
|
-
namespace: string;
|
|
11
|
-
root$: ReadonlyVal<HTMLElement | null>;
|
|
12
|
-
rootRect$: ReadonlyVal<TeleBoxRect>;
|
|
13
|
-
ratio$: ReadonlyVal<number>;
|
|
14
|
-
highlightStage$: ReadonlyVal<boolean>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class TeleStage {
|
|
18
|
-
private readonly _sideEffect = new SideEffectManager();
|
|
19
|
-
|
|
20
|
-
public readonly namespace: string;
|
|
21
|
-
public readonly stageRect$: ReadonlyVal<TeleBoxRect>;
|
|
22
|
-
public readonly highlightStage$: ReadonlyVal<boolean>;
|
|
23
|
-
|
|
24
|
-
public $boxStage?: HTMLDivElement;
|
|
25
|
-
|
|
26
|
-
constructor({
|
|
27
|
-
namespace,
|
|
28
|
-
rootRect$,
|
|
29
|
-
ratio$,
|
|
30
|
-
highlightStage$,
|
|
31
|
-
root$,
|
|
32
|
-
}: TeleStageConfig) {
|
|
33
|
-
this.namespace = namespace;
|
|
34
|
-
this.highlightStage$ = highlightStage$;
|
|
35
|
-
|
|
36
|
-
this.stageRect$ = combine(
|
|
37
|
-
[rootRect$, ratio$],
|
|
38
|
-
([rootRect, ratio]) => {
|
|
39
|
-
if (ratio <= 0 || rootRect.width <= 0 || rootRect.height <= 0) {
|
|
40
|
-
return rootRect;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const preferredHeight = rootRect.width * ratio;
|
|
44
|
-
if (preferredHeight === rootRect.height) {
|
|
45
|
-
return rootRect;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (preferredHeight < rootRect.height) {
|
|
49
|
-
return {
|
|
50
|
-
x: 0,
|
|
51
|
-
y: (rootRect.height - preferredHeight) / 2,
|
|
52
|
-
width: rootRect.width,
|
|
53
|
-
height: preferredHeight,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const preferredWidth = rootRect.height / ratio;
|
|
58
|
-
return {
|
|
59
|
-
x: (rootRect.width - preferredWidth) / 2,
|
|
60
|
-
y: 0,
|
|
61
|
-
width: preferredWidth,
|
|
62
|
-
height: rootRect.height,
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
{ compare: shallowequal }
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
this._sideEffect.addDisposer(
|
|
69
|
-
combine([root$, highlightStage$]).subscribe(
|
|
70
|
-
([root, highlightStage]) => {
|
|
71
|
-
if (root && highlightStage) {
|
|
72
|
-
root.appendChild(this.render());
|
|
73
|
-
} else if (this.$boxStage?.parentNode) {
|
|
74
|
-
this.$boxStage.remove();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
private render(): HTMLDivElement {
|
|
82
|
-
if (this.$boxStage) {
|
|
83
|
-
return this.$boxStage;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const $boxStage = document.createElement("div");
|
|
87
|
-
$boxStage.className = this.wrapClassName("box-stage-container");
|
|
88
|
-
const $boxStageMask1 = document.createElement("div");
|
|
89
|
-
$boxStageMask1.className = this.wrapClassName("box-stage-mask");
|
|
90
|
-
const $boxStageMask2 = document.createElement("div");
|
|
91
|
-
$boxStageMask2.className = this.wrapClassName("box-stage-mask");
|
|
92
|
-
const $boxStageFrame = document.createElement("div");
|
|
93
|
-
$boxStageFrame.className = this.wrapClassName("box-stage-frame");
|
|
94
|
-
|
|
95
|
-
const [
|
|
96
|
-
$topLeftCorner,
|
|
97
|
-
$topRightCorner,
|
|
98
|
-
$bottomLeftCorner,
|
|
99
|
-
$bottomRightCorner,
|
|
100
|
-
] = [
|
|
101
|
-
"M0 8V0h8v2H2v6H0Z",
|
|
102
|
-
"M8 8V0H0v2h6v6h2Z",
|
|
103
|
-
"M0 0v8h8V6H2V0H0Z",
|
|
104
|
-
"M8 0v8H0V6h6V0h2Z",
|
|
105
|
-
].map((path, i) => {
|
|
106
|
-
const $svg = document.createElementNS(
|
|
107
|
-
"http://www.w3.org/2000/svg",
|
|
108
|
-
"svg"
|
|
109
|
-
);
|
|
110
|
-
$svg.setAttribute("viewBox", "0 0 8 8");
|
|
111
|
-
$svg.setAttribute(
|
|
112
|
-
"class",
|
|
113
|
-
`${this.wrapClassName("box-stage-frame-corner")} is-${i}`
|
|
114
|
-
);
|
|
115
|
-
const $path = document.createElementNS(
|
|
116
|
-
"http://www.w3.org/2000/svg",
|
|
117
|
-
"path"
|
|
118
|
-
);
|
|
119
|
-
$path.setAttribute("d", path);
|
|
120
|
-
$path.setAttribute("fill", "#3381FF");
|
|
121
|
-
$svg.appendChild($path);
|
|
122
|
-
return $svg;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
$boxStageFrame.appendChild($topLeftCorner);
|
|
126
|
-
$boxStageFrame.appendChild($bottomLeftCorner);
|
|
127
|
-
$boxStageFrame.appendChild($topRightCorner);
|
|
128
|
-
$boxStageFrame.appendChild($bottomRightCorner);
|
|
129
|
-
|
|
130
|
-
$boxStage.appendChild($boxStageMask1);
|
|
131
|
-
$boxStage.appendChild($boxStageFrame);
|
|
132
|
-
$boxStage.appendChild($boxStageMask2);
|
|
133
|
-
|
|
134
|
-
this._sideEffect.addDisposer(
|
|
135
|
-
this.highlightStage$.subscribe((highlightStage) => {
|
|
136
|
-
$boxStage.classList.toggle("is-active", highlightStage);
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
this._sideEffect.addDisposer(
|
|
141
|
-
combine([this.highlightStage$, this.stageRect$]).subscribe(
|
|
142
|
-
([highlightStage, stageRect]) => {
|
|
143
|
-
if (!highlightStage) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (stageRect.x > 0) {
|
|
147
|
-
$boxStage.style.flexDirection = "row";
|
|
148
|
-
$boxStageMask1.style.width = `${stageRect.x}px`;
|
|
149
|
-
$boxStageMask1.style.height = "";
|
|
150
|
-
$boxStageMask2.style.width = `${stageRect.x}px`;
|
|
151
|
-
$boxStageMask2.style.height = "";
|
|
152
|
-
} else if (stageRect.y > 0) {
|
|
153
|
-
$boxStage.style.flexDirection = "column";
|
|
154
|
-
$boxStageMask1.style.width = "";
|
|
155
|
-
$boxStageMask1.style.height = `${stageRect.y}px`;
|
|
156
|
-
$boxStageMask2.style.width = "";
|
|
157
|
-
$boxStageMask2.style.height = `${stageRect.y}px`;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
this.$boxStage = $boxStage;
|
|
164
|
-
return $boxStage;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
public destroy(): void {
|
|
168
|
-
this._sideEffect.flushAll();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public wrapClassName(className: string): string {
|
|
172
|
-
return `${this.namespace}-${className}`;
|
|
173
|
-
}
|
|
174
|
-
}
|
package/src/TeleStage/style.scss
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
@import "../scss/variables.scss";
|
|
2
|
-
|
|
3
|
-
.#{$namespace}-box-stage-container {
|
|
4
|
-
display: none;
|
|
5
|
-
position: absolute;
|
|
6
|
-
z-index: $stage-z-index;
|
|
7
|
-
top: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
width: 100%;
|
|
10
|
-
height: 100%;
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
pointer-events: none;
|
|
13
|
-
|
|
14
|
-
&.is-active {
|
|
15
|
-
display: flex;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.#{$namespace}-box-stage-mask {
|
|
20
|
-
background: rgba(0, 0, 0, 0.05);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.#{$namespace}-box-stage-frame {
|
|
24
|
-
flex: 1;
|
|
25
|
-
position: relative;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.#{$namespace}-box-stage-frame-corner {
|
|
29
|
-
position: absolute;
|
|
30
|
-
width: 8px;
|
|
31
|
-
height: 8px;
|
|
32
|
-
|
|
33
|
-
&.is-0 {
|
|
34
|
-
top: 0;
|
|
35
|
-
left: 0;
|
|
36
|
-
}
|
|
37
|
-
&.is-1 {
|
|
38
|
-
top: 0;
|
|
39
|
-
right: 0;
|
|
40
|
-
}
|
|
41
|
-
&.is-2 {
|
|
42
|
-
bottom: 0;
|
|
43
|
-
left: 0;
|
|
44
|
-
}
|
|
45
|
-
&.is-3 {
|
|
46
|
-
bottom: 0;
|
|
47
|
-
right: 0;
|
|
48
|
-
}
|
|
49
|
-
}
|