@netless/telebox-insider 1.0.0-alpha.2 → 1.0.0-alpha.22
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 +49 -34
- package/dist/TeleBox/typings.d.ts +22 -10
- package/dist/TeleBox/utils.d.ts +5 -0
- package/dist/TeleBoxCollector/index.d.ts +7 -6
- package/dist/TeleBoxManager/MaxTitleBar/index.d.ts +1 -1
- package/dist/TeleBoxManager/index.d.ts +8 -2
- package/dist/TeleBoxManager/typings.d.ts +12 -6
- package/dist/TeleTitleBar/DefaultTitleBar/index.d.ts +3 -5
- package/dist/TeleTitleBar/typings.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/telebox-insider.cjs.js +2 -1
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +1647 -1
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +3 -3
- package/src/TeleBox/index.ts +373 -261
- package/src/TeleBox/style.scss +9 -29
- package/src/TeleBox/style.shadow.scss +87 -0
- package/src/TeleBox/typings.ts +22 -10
- package/src/TeleBox/utils.ts +32 -0
- package/src/TeleBoxCollector/index.ts +33 -18
- package/src/TeleBoxCollector/style.scss +10 -4
- package/src/TeleBoxManager/MaxTitleBar/index.ts +3 -28
- package/src/TeleBoxManager/MaxTitleBar/style.scss +38 -16
- package/src/TeleBoxManager/index.ts +106 -54
- package/src/TeleBoxManager/style.scss +56 -0
- package/src/TeleBoxManager/typings.ts +24 -7
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +4 -12
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +68 -11
- package/src/TeleTitleBar/typings.ts +1 -1
- package/src/scss/mixins.scss +5 -0
- package/src/scss/variables.scss +46 -0
- package/dist/TeleStage/index.d.ts +0 -21
- package/src/TeleStage/index.ts +0 -178
- package/src/TeleStage/style.scss +0 -49
|
@@ -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 - 1;
|
|
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
|
-
}
|