@netless/telebox-insider 1.0.0-alpha.3 → 1.0.0-alpha.32
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 +62 -38
- package/dist/TeleBox/typings.d.ts +28 -16
- 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 +1659 -1
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +1641 -1
- package/dist/telebox-insider.es.js.map +1 -1
- package/dist/utils.d.ts +0 -1
- package/package.json +67 -67
- package/src/TeleBox/index.ts +443 -300
- package/src/TeleBox/style.scss +13 -25
- package/src/TeleBox/style.shadow.scss +77 -0
- package/src/TeleBox/typings.ts +28 -16
- 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 +187 -80
- 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
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
TeleTitleBarEvent,
|
|
15
15
|
} from "../typings";
|
|
16
16
|
import { preventEvent } from "../../utils";
|
|
17
|
-
import {
|
|
17
|
+
import type { ReadonlyVal } from "value-enhancer";
|
|
18
18
|
|
|
19
19
|
export type DefaultTitleBarButton = TeleTitleBarEvent & {
|
|
20
20
|
readonly iconClassName: string;
|
|
@@ -29,7 +29,7 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
29
29
|
public constructor({
|
|
30
30
|
readonly$,
|
|
31
31
|
state$,
|
|
32
|
-
title
|
|
32
|
+
title$,
|
|
33
33
|
buttons,
|
|
34
34
|
onEvent,
|
|
35
35
|
onDragStart,
|
|
@@ -37,7 +37,7 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
37
37
|
}: DefaultTitleBarConfig) {
|
|
38
38
|
this.readonly$ = readonly$;
|
|
39
39
|
this.state$ = state$;
|
|
40
|
-
this.title$ =
|
|
40
|
+
this.title$ = title$;
|
|
41
41
|
this.onEvent = onEvent;
|
|
42
42
|
this.onDragStart = onDragStart;
|
|
43
43
|
this.namespace = namespace;
|
|
@@ -67,14 +67,6 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
67
67
|
|
|
68
68
|
public $dragArea: HTMLElement;
|
|
69
69
|
|
|
70
|
-
public get title(): string {
|
|
71
|
-
return this.title$.value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public setTitle(title: string): void {
|
|
75
|
-
this.title$.setValue(title);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
public render(): HTMLElement {
|
|
79
71
|
if (!this.$titleBar) {
|
|
80
72
|
this.$titleBar = document.createElement("div");
|
|
@@ -170,15 +162,9 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
170
162
|
$dragArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
|
171
163
|
this.sideEffect.addEventListener(
|
|
172
164
|
$dragArea,
|
|
173
|
-
"
|
|
165
|
+
"pointerdown",
|
|
174
166
|
this.handleTitleBarClick
|
|
175
167
|
);
|
|
176
|
-
this.sideEffect.addEventListener(
|
|
177
|
-
$dragArea,
|
|
178
|
-
"touchstart",
|
|
179
|
-
this.handleTitleBarTouch,
|
|
180
|
-
{ passive: true }
|
|
181
|
-
);
|
|
182
168
|
return $dragArea;
|
|
183
169
|
}
|
|
184
170
|
|
|
@@ -205,7 +191,7 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
205
191
|
|
|
206
192
|
protected readonly$: TeleTitleBarConfig["readonly$"];
|
|
207
193
|
|
|
208
|
-
protected title$:
|
|
194
|
+
protected title$: ReadonlyVal<string>;
|
|
209
195
|
|
|
210
196
|
protected buttons: ReadonlyArray<DefaultTitleBarButton>;
|
|
211
197
|
|
|
@@ -219,8 +205,8 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
219
205
|
clientY: -100,
|
|
220
206
|
};
|
|
221
207
|
|
|
222
|
-
protected handleTitleBarClick = (ev:
|
|
223
|
-
if (this.readonly$.value) {
|
|
208
|
+
protected handleTitleBarClick = (ev: PointerEvent): void => {
|
|
209
|
+
if (!ev.isPrimary || this.readonly$.value) {
|
|
224
210
|
return;
|
|
225
211
|
}
|
|
226
212
|
|
|
@@ -253,44 +239,44 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
253
239
|
this.lastTitleBarClick.clientY = ev.clientY;
|
|
254
240
|
};
|
|
255
241
|
|
|
256
|
-
protected lastTitleBarTouch = {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
protected handleTitleBarTouch = (ev: TouchEvent): void => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
};
|
|
242
|
+
// protected lastTitleBarTouch = {
|
|
243
|
+
// timestamp: 0,
|
|
244
|
+
// clientX: -100,
|
|
245
|
+
// clientY: -100,
|
|
246
|
+
// };
|
|
247
|
+
|
|
248
|
+
// protected handleTitleBarTouch = (ev: TouchEvent): void => {
|
|
249
|
+
// if (this.readonly$.value) {
|
|
250
|
+
// return;
|
|
251
|
+
// }
|
|
252
|
+
|
|
253
|
+
// if ((ev.target as HTMLElement).dataset?.teleTitleBarNoDblClick) {
|
|
254
|
+
// return; // btns
|
|
255
|
+
// }
|
|
256
|
+
|
|
257
|
+
// preventEvent(ev);
|
|
258
|
+
|
|
259
|
+
// const now = Date.now();
|
|
260
|
+
// const {
|
|
261
|
+
// clientX = this.lastTitleBarTouch.clientX + 100,
|
|
262
|
+
// clientY = this.lastTitleBarTouch.clientY + 100,
|
|
263
|
+
// } = ev.touches[0] || {};
|
|
264
|
+
|
|
265
|
+
// if (now - this.lastTitleBarTouch.timestamp <= 500) {
|
|
266
|
+
// if (
|
|
267
|
+
// Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 10 &&
|
|
268
|
+
// Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 10
|
|
269
|
+
// ) {
|
|
270
|
+
// // double click
|
|
271
|
+
// if (this.onEvent) {
|
|
272
|
+
// this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
|
|
273
|
+
// }
|
|
274
|
+
// }
|
|
275
|
+
// } else if (this.onDragStart) {
|
|
276
|
+
// this.onDragStart(ev);
|
|
277
|
+
// }
|
|
278
|
+
// this.lastTitleBarTouch.timestamp = now;
|
|
279
|
+
// this.lastTitleBarTouch.clientX = clientX;
|
|
280
|
+
// this.lastTitleBarTouch.clientY = clientY;
|
|
281
|
+
// };
|
|
296
282
|
}
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
height: 26px;
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
|
-
background: #fff;
|
|
12
11
|
user-select: none;
|
|
13
|
-
border-bottom: 1px solid #eeeef7;
|
|
14
12
|
touch-action: manipulation;
|
|
13
|
+
|
|
14
|
+
@include clr(color, titlebarColor);
|
|
15
|
+
@include clr(background-color, titlebarBackground);
|
|
16
|
+
@include clr(border-bottom, titlebarBorderBottom);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.#{$namespace}-title-area {
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
|
|
27
29
|
.#{$namespace}-title {
|
|
28
30
|
@include no-user-select;
|
|
31
|
+
@include clr(color, titlebarColor);
|
|
29
32
|
|
|
30
33
|
overflow: hidden;
|
|
31
34
|
margin: 0;
|
|
@@ -36,7 +39,6 @@
|
|
|
36
39
|
white-space: nowrap;
|
|
37
40
|
word-break: keep-all;
|
|
38
41
|
text-overflow: ellipsis;
|
|
39
|
-
color: #191919;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
.#{$namespace}-drag-area {
|
|
@@ -47,6 +49,8 @@
|
|
|
47
49
|
bottom: 0;
|
|
48
50
|
margin: auto;
|
|
49
51
|
z-index: 10;
|
|
52
|
+
// enable pointermove event on touch devices
|
|
53
|
+
touch-action: none;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
.#{$namespace}-titlebar-btns {
|
|
@@ -85,31 +89,47 @@
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
.#{$namespace}-titlebar-icon-minimize {
|
|
88
|
-
background: center / cover no-repeat
|
|
92
|
+
background: center / cover no-repeat;
|
|
93
|
+
background-image: url("./icons/minimize.svg");
|
|
94
|
+
background-image: var(
|
|
95
|
+
--tele-titlebarIconMinimize,
|
|
96
|
+
url("./icons/minimize.svg")
|
|
97
|
+
);
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
.#{$namespace}-titlebar-icon-maximize {
|
|
92
|
-
background: center / cover no-repeat
|
|
101
|
+
background: center / cover no-repeat;
|
|
102
|
+
background-image: url("./icons/maximize.svg");
|
|
103
|
+
background-image: var(
|
|
104
|
+
--tele-titlebarIconMaximize,
|
|
105
|
+
url("./icons/maximize.svg")
|
|
106
|
+
);
|
|
93
107
|
|
|
94
108
|
&.is-active {
|
|
95
109
|
background-image: url("./icons/maximize-active.svg");
|
|
110
|
+
background-image: var(
|
|
111
|
+
--tele-titlebarIconMaximizeActive,
|
|
112
|
+
url("./icons/maximize-active.svg")
|
|
113
|
+
);
|
|
96
114
|
}
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
.#{$namespace}-titlebar-icon-close {
|
|
100
|
-
background: center / cover no-repeat
|
|
118
|
+
background: center / cover no-repeat;
|
|
119
|
+
background-image: url("./icons/close.svg");
|
|
120
|
+
background-image: var(--tele-titlebarIconClose, url("./icons/close.svg"));
|
|
101
121
|
}
|
|
102
122
|
|
|
103
123
|
.#{$namespace}-color-scheme-dark {
|
|
104
124
|
color-scheme: dark;
|
|
105
125
|
|
|
106
126
|
.#{$namespace}-title {
|
|
107
|
-
color
|
|
127
|
+
@include clr-dark(color, titlebarColor);
|
|
108
128
|
}
|
|
109
129
|
|
|
110
130
|
.#{$namespace}-titlebar {
|
|
111
|
-
color
|
|
112
|
-
background
|
|
113
|
-
border-bottom
|
|
131
|
+
@include clr-dark(color, titlebarColor);
|
|
132
|
+
@include clr-dark(background-color, titlebarBackground);
|
|
133
|
+
@include clr-dark(border-bottom, titlebarBorderBottom);
|
|
114
134
|
}
|
|
115
135
|
}
|
|
@@ -10,11 +10,11 @@ export type TeleTitleBarEvent<U = keyof TeleBoxDelegateEventConfig> =
|
|
|
10
10
|
|
|
11
11
|
export interface TeleTitleBarConfig {
|
|
12
12
|
readonly$: ReadonlyVal<boolean, boolean>;
|
|
13
|
-
title
|
|
13
|
+
title$: ReadonlyVal<string, boolean>;
|
|
14
14
|
state$: ReadonlyVal<TeleBoxState, boolean>;
|
|
15
15
|
namespace?: string;
|
|
16
16
|
onEvent?: (event: TeleTitleBarEvent) => void;
|
|
17
|
-
onDragStart?: (event:
|
|
17
|
+
onDragStart?: (event: PointerEvent) => void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface TeleTitleBar {
|
package/src/index.ts
CHANGED
package/src/scss/variables.scss
CHANGED
|
@@ -1,2 +1,74 @@
|
|
|
1
1
|
$namespace: "telebox";
|
|
2
|
+
|
|
2
3
|
$base-z-index: 100;
|
|
4
|
+
$max-titlebar-z-index: $base-z-index + 5000;
|
|
5
|
+
$stage-z-index: $max-titlebar-z-index + 10;
|
|
6
|
+
$collector-z-index: $stage-z-index + 10;
|
|
7
|
+
|
|
8
|
+
$tele-colors: (
|
|
9
|
+
managerContainerBackground: #f9f9f9,
|
|
10
|
+
managerStageBackground: #fff,
|
|
11
|
+
managerStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.08),
|
|
12
|
+
boxContainerBackground: #f9f9f9,
|
|
13
|
+
boxStageBackground: #fff,
|
|
14
|
+
boxStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.08),
|
|
15
|
+
boxColor: #191919,
|
|
16
|
+
boxBorder: 1px solid #e3e3ec,
|
|
17
|
+
boxShadow: 0px 4px 10px 0px rgba(47, 65, 146, 0.15),
|
|
18
|
+
boxFooterColor: #191919,
|
|
19
|
+
boxFooterBackground: #fff,
|
|
20
|
+
titlebarColor: #191919,
|
|
21
|
+
titlebarBackground: #fff,
|
|
22
|
+
titlebarBorderBottom: 1px solid #eeeef7,
|
|
23
|
+
titlebarTabColor: #7b88a0,
|
|
24
|
+
titlebarTabFocusColor: #357bf6,
|
|
25
|
+
titlebarTabBackground: transparent,
|
|
26
|
+
titlebarTabDividerColor: #e5e5f0,
|
|
27
|
+
collectorBackground: #fff,
|
|
28
|
+
collectorShadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
$tele-colors-dark: (
|
|
32
|
+
managerContainerBackground: #25282e,
|
|
33
|
+
managerStageBackground: #272a30,
|
|
34
|
+
managerStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.24),
|
|
35
|
+
boxContainerBackground: #25282e,
|
|
36
|
+
boxStageBackground: #272a30,
|
|
37
|
+
boxStageShadow: 0px 0px 16px rgba(0, 0, 0, 0.24),
|
|
38
|
+
boxColor: #e9e9e9,
|
|
39
|
+
boxBorder: 1px solid #383b42,
|
|
40
|
+
boxShadow: 0px 4px 10px 0px rgba(56, 59, 66, 0.15),
|
|
41
|
+
boxFooterColor: #e9e9e9,
|
|
42
|
+
boxFooterBackground: #383b42,
|
|
43
|
+
titlebarColor: #e9e9e9,
|
|
44
|
+
titlebarBackground: #383b42,
|
|
45
|
+
titlebarBorderBottom: none,
|
|
46
|
+
titlebarTabColor: #e9e9e9,
|
|
47
|
+
titlebarTabFocusColor: #357bf6,
|
|
48
|
+
titlebarTabBackground: transparent,
|
|
49
|
+
titlebarTabDividerColor: #7b88a0,
|
|
50
|
+
collectorBackground: #383b42,
|
|
51
|
+
collectorShadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
@mixin clr($property, $key) {
|
|
55
|
+
#{$property}: map-get($tele-colors, $key);
|
|
56
|
+
#{$property}: var(--tele-#{$key}, map-get($tele-colors, $key));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@mixin clr-dark($property, $key) {
|
|
60
|
+
#{$property}: map-get($tele-colors-dark, $key);
|
|
61
|
+
#{$property}: var(--tele-#{$key}, map-get($tele-colors-dark, $key));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@mixin clr-root() {
|
|
65
|
+
@each $key, $value in $tele-colors {
|
|
66
|
+
--tele-#{$key}: #{$value};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@mixin clr-root-dark() {
|
|
71
|
+
@each $key, $value in $tele-colors-dark {
|
|
72
|
+
--tele-#{$key}: #{$value};
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -9,12 +9,6 @@ export function preventEvent(ev: Event): void {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function flattenEvent(ev: MouseEvent | TouchEvent): MouseEvent | Touch {
|
|
13
|
-
return (ev as TouchEvent).touches
|
|
14
|
-
? (ev as TouchEvent).touches[0]
|
|
15
|
-
: (ev as MouseEvent);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
12
|
export function getRandomInt(min: number, max: number): number {
|
|
19
13
|
min = Math.ceil(min);
|
|
20
14
|
max = Math.floor(max);
|
|
@@ -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,178 +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$, highlightStage$, ratio$],
|
|
38
|
-
([rootRect, highlightStage, ratio]) => {
|
|
39
|
-
if (!highlightStage) {
|
|
40
|
-
return rootRect;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (ratio <= 0 || rootRect.width <= 0 || rootRect.height <= 0) {
|
|
44
|
-
return rootRect;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const preferredHeight = rootRect.width * ratio;
|
|
48
|
-
if (preferredHeight === rootRect.height) {
|
|
49
|
-
return rootRect;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (preferredHeight < rootRect.height) {
|
|
53
|
-
return {
|
|
54
|
-
x: 0,
|
|
55
|
-
y: (rootRect.height - preferredHeight) / 2,
|
|
56
|
-
width: rootRect.width,
|
|
57
|
-
height: preferredHeight,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const preferredWidth = rootRect.height / ratio;
|
|
62
|
-
return {
|
|
63
|
-
x: (rootRect.width - preferredWidth) / 2,
|
|
64
|
-
y: 0,
|
|
65
|
-
width: preferredWidth,
|
|
66
|
-
height: rootRect.height,
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
{ compare: shallowequal }
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
this._sideEffect.addDisposer(
|
|
73
|
-
combine([root$, highlightStage$]).subscribe(
|
|
74
|
-
([root, highlightStage]) => {
|
|
75
|
-
if (root && highlightStage) {
|
|
76
|
-
root.appendChild(this.render());
|
|
77
|
-
} else if (this.$boxStage?.parentNode) {
|
|
78
|
-
this.$boxStage.remove();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private render(): HTMLDivElement {
|
|
86
|
-
if (this.$boxStage) {
|
|
87
|
-
return this.$boxStage;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const $boxStage = document.createElement("div");
|
|
91
|
-
$boxStage.className = this.wrapClassName("box-stage-container");
|
|
92
|
-
const $boxStageMask1 = document.createElement("div");
|
|
93
|
-
$boxStageMask1.className = this.wrapClassName("box-stage-mask");
|
|
94
|
-
const $boxStageMask2 = document.createElement("div");
|
|
95
|
-
$boxStageMask2.className = this.wrapClassName("box-stage-mask");
|
|
96
|
-
const $boxStageFrame = document.createElement("div");
|
|
97
|
-
$boxStageFrame.className = this.wrapClassName("box-stage-frame");
|
|
98
|
-
|
|
99
|
-
const [
|
|
100
|
-
$topLeftCorner,
|
|
101
|
-
$topRightCorner,
|
|
102
|
-
$bottomLeftCorner,
|
|
103
|
-
$bottomRightCorner,
|
|
104
|
-
] = [
|
|
105
|
-
"M0 8V0h8v2H2v6H0Z",
|
|
106
|
-
"M8 8V0H0v2h6v6h2Z",
|
|
107
|
-
"M0 0v8h8V6H2V0H0Z",
|
|
108
|
-
"M8 0v8H0V6h6V0h2Z",
|
|
109
|
-
].map((path, i) => {
|
|
110
|
-
const $svg = document.createElementNS(
|
|
111
|
-
"http://www.w3.org/2000/svg",
|
|
112
|
-
"svg"
|
|
113
|
-
);
|
|
114
|
-
$svg.setAttribute("viewBox", "0 0 8 8");
|
|
115
|
-
$svg.setAttribute(
|
|
116
|
-
"class",
|
|
117
|
-
`${this.wrapClassName("box-stage-frame-corner")} is-${i}`
|
|
118
|
-
);
|
|
119
|
-
const $path = document.createElementNS(
|
|
120
|
-
"http://www.w3.org/2000/svg",
|
|
121
|
-
"path"
|
|
122
|
-
);
|
|
123
|
-
$path.setAttribute("d", path);
|
|
124
|
-
$path.setAttribute("fill", "#3381FF");
|
|
125
|
-
$svg.appendChild($path);
|
|
126
|
-
return $svg;
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
$boxStageFrame.appendChild($topLeftCorner);
|
|
130
|
-
$boxStageFrame.appendChild($bottomLeftCorner);
|
|
131
|
-
$boxStageFrame.appendChild($topRightCorner);
|
|
132
|
-
$boxStageFrame.appendChild($bottomRightCorner);
|
|
133
|
-
|
|
134
|
-
$boxStage.appendChild($boxStageMask1);
|
|
135
|
-
$boxStage.appendChild($boxStageFrame);
|
|
136
|
-
$boxStage.appendChild($boxStageMask2);
|
|
137
|
-
|
|
138
|
-
this._sideEffect.addDisposer(
|
|
139
|
-
this.highlightStage$.subscribe((highlightStage) => {
|
|
140
|
-
$boxStage.classList.toggle("is-active", highlightStage);
|
|
141
|
-
})
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
this._sideEffect.addDisposer(
|
|
145
|
-
combine([this.highlightStage$, this.stageRect$]).subscribe(
|
|
146
|
-
([highlightStage, stageRect]) => {
|
|
147
|
-
if (!highlightStage) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (stageRect.x > 0) {
|
|
151
|
-
$boxStage.style.flexDirection = "row";
|
|
152
|
-
$boxStageMask1.style.width = `${stageRect.x}px`;
|
|
153
|
-
$boxStageMask1.style.height = "";
|
|
154
|
-
$boxStageMask2.style.width = `${stageRect.x}px`;
|
|
155
|
-
$boxStageMask2.style.height = "";
|
|
156
|
-
} else if (stageRect.y > 0) {
|
|
157
|
-
$boxStage.style.flexDirection = "column";
|
|
158
|
-
$boxStageMask1.style.width = "";
|
|
159
|
-
$boxStageMask1.style.height = `${stageRect.y}px`;
|
|
160
|
-
$boxStageMask2.style.width = "";
|
|
161
|
-
$boxStageMask2.style.height = `${stageRect.y}px`;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
this.$boxStage = $boxStage;
|
|
168
|
-
return $boxStage;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public destroy(): void {
|
|
172
|
-
this._sideEffect.flushAll();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public wrapClassName(className: string): string {
|
|
176
|
-
return `${this.namespace}-${className}`;
|
|
177
|
-
}
|
|
178
|
-
}
|
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: $base-z-index + 2000;
|
|
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
|
-
}
|