@netless/telebox-insider 1.0.0-alpha.25 → 1.0.0-alpha.28
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 +1 -0
- package/dist/TeleBoxCollector/index.d.ts +5 -7
- package/dist/TeleBoxManager/index.d.ts +8 -4
- package/dist/TeleBoxManager/typings.d.ts +38 -0
- package/dist/index.d.ts +0 -1
- package/dist/style.css +113 -112
- package/dist/telebox-insider.cjs.js +59 -41
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +59 -41
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/index.ts +2 -0
- package/src/TeleBox/style.scss +7 -5
- package/src/TeleBox/style.shadow.scss +17 -28
- package/src/TeleBoxCollector/index.ts +27 -39
- package/src/TeleBoxCollector/style.scss +4 -8
- package/src/TeleBoxManager/MaxTitleBar/style.scss +8 -28
- package/src/TeleBoxManager/index.ts +77 -20
- package/src/TeleBoxManager/style.scss +24 -25
- package/src/TeleBoxManager/typings.ts +45 -0
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +2 -2
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +21 -58
- package/src/index.ts +0 -2
- package/src/scss/mixins.scss +0 -5
- package/src/scss/variables.scss +62 -36
package/package.json
CHANGED
package/src/TeleBox/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ type PropsValConfig = {
|
|
|
65
65
|
readonly: RequiredTeleBoxConfig["readonly$"];
|
|
66
66
|
rootRect: RequiredTeleBoxConfig["rootRect$"];
|
|
67
67
|
managerStageRect: RequiredTeleBoxConfig["managerStageRect$"];
|
|
68
|
+
managerStageRatio: RequiredTeleBoxConfig["managerStageRatio$"];
|
|
68
69
|
defaultBoxStageStyle: RequiredTeleBoxConfig["defaultBoxStageStyle$"];
|
|
69
70
|
defaultBoxBodyStyle: RequiredTeleBoxConfig["defaultBoxBodyStyle$"];
|
|
70
71
|
collectorRect: RequiredTeleBoxConfig["collectorRect$"];
|
|
@@ -240,6 +241,7 @@ export class TeleBox {
|
|
|
240
241
|
readonly: readonly$,
|
|
241
242
|
rootRect: rootRect$,
|
|
242
243
|
managerStageRect: managerStageRect$,
|
|
244
|
+
managerStageRatio: managerStageRatio$,
|
|
243
245
|
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
|
244
246
|
defaultBoxStageStyle: defaultBoxStageStyle$,
|
|
245
247
|
collectorRect: collectorRect$,
|
package/src/TeleBox/style.scss
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.#{$namespace}-box-main {
|
|
17
|
-
@include
|
|
18
|
-
@include
|
|
17
|
+
@include clr(border, boxBorder);
|
|
18
|
+
@include clr(boxShadow, boxShadow);
|
|
19
19
|
|
|
20
20
|
position: relative;
|
|
21
21
|
width: 100%;
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
|
|
51
51
|
position: absolute;
|
|
52
52
|
z-index: 2147483647;
|
|
53
|
+
// enable pointermove event on touch devices
|
|
54
|
+
touch-action: none;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
.#{$namespace}-n {
|
|
@@ -169,7 +171,7 @@
|
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
.#{$namespace}-maximized {
|
|
172
|
-
|
|
174
|
+
boxshadow: none;
|
|
173
175
|
transition: none;
|
|
174
176
|
}
|
|
175
177
|
|
|
@@ -198,7 +200,7 @@
|
|
|
198
200
|
color-scheme: dark;
|
|
199
201
|
|
|
200
202
|
.#{$namespace}-box-main {
|
|
201
|
-
@include
|
|
202
|
-
@include
|
|
203
|
+
@include clr-dark(border, boxBorder);
|
|
204
|
+
@include clr-dark(boxShadow, boxShadow);
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@import "../scss/variables.scss";
|
|
2
2
|
@import "../scss/mixins.scss";
|
|
3
|
+
@import "../scss/fancy-scrollbar.scss";
|
|
3
4
|
|
|
4
5
|
.#{$namespace}-quarantine {
|
|
5
6
|
all: initial;
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.#{$namespace}-body-wrap {
|
|
14
|
-
@include
|
|
15
|
+
@include clr(color, boxColor);
|
|
15
16
|
|
|
16
17
|
flex: 1;
|
|
17
18
|
width: 100%;
|
|
@@ -26,11 +27,7 @@
|
|
|
26
27
|
width: 100%;
|
|
27
28
|
height: 100%;
|
|
28
29
|
position: relative;
|
|
29
|
-
@include
|
|
30
|
-
background-color,
|
|
31
|
-
manager-container-background,
|
|
32
|
-
$manager-container-background
|
|
33
|
-
);
|
|
30
|
+
@include clr(background-color, boxContainerBackground);
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
.#{$namespace}-box-stage {
|
|
@@ -38,12 +35,8 @@
|
|
|
38
35
|
z-index: 1;
|
|
39
36
|
overflow: hidden;
|
|
40
37
|
|
|
41
|
-
@include
|
|
42
|
-
|
|
43
|
-
manager-stage-background,
|
|
44
|
-
$manager-stage-background
|
|
45
|
-
);
|
|
46
|
-
@include v(box-shadow, manager-stage-shadow, $manager-stage-shadow);
|
|
38
|
+
@include clr(background-color, boxStageBackground);
|
|
39
|
+
@include clr(boxShadow, boxStageShadow);
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
.#{$namespace}-footer-wrap {
|
|
@@ -51,6 +44,9 @@
|
|
|
51
44
|
display: flex;
|
|
52
45
|
flex-direction: column;
|
|
53
46
|
|
|
47
|
+
@include clr(color, boxFooterColor);
|
|
48
|
+
@include clr(background-color, boxFooterBackground);
|
|
49
|
+
|
|
54
50
|
&::before {
|
|
55
51
|
content: "";
|
|
56
52
|
display: block;
|
|
@@ -62,27 +58,20 @@
|
|
|
62
58
|
color-scheme: dark;
|
|
63
59
|
|
|
64
60
|
.#{$namespace}-body-wrap {
|
|
65
|
-
@include
|
|
61
|
+
@include clr-dark(color, boxColor);
|
|
66
62
|
}
|
|
67
63
|
|
|
68
64
|
.#{$namespace}-content {
|
|
69
|
-
@include
|
|
70
|
-
background-color,
|
|
71
|
-
manager-container-background-dark,
|
|
72
|
-
$manager-container-background-dark
|
|
73
|
-
);
|
|
65
|
+
@include clr-dark(background-color, boxContainerBackground);
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
.#{$namespace}-box-stage {
|
|
77
|
-
@include
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@include
|
|
83
|
-
|
|
84
|
-
manager-stage-shadow-dark,
|
|
85
|
-
$manager-stage-shadow-dark
|
|
86
|
-
);
|
|
69
|
+
@include clr-dark(background-color, boxStageBackground);
|
|
70
|
+
@include clr-dark(boxShadow, boxStageShadow);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.#{$namespace}-footer-wrap {
|
|
74
|
+
@include clr-dark(color, boxFooterColor);
|
|
75
|
+
@include clr-dark(background-color, boxFooterBackground);
|
|
87
76
|
}
|
|
88
77
|
}
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
import { derive } from "value-enhancer";
|
|
10
10
|
import {
|
|
11
11
|
withValueEnhancer,
|
|
12
|
-
combine,
|
|
13
12
|
Val,
|
|
14
13
|
withReadonlyValueEnhancer,
|
|
15
14
|
ValManager,
|
|
@@ -20,10 +19,11 @@ import type { TeleBoxRect } from "../TeleBox/typings";
|
|
|
20
19
|
export interface TeleBoxCollectorConfig {
|
|
21
20
|
namespace?: string;
|
|
22
21
|
styles?: TeleStyles;
|
|
23
|
-
root
|
|
24
|
-
minimized$:
|
|
22
|
+
root: HTMLElement;
|
|
23
|
+
minimized$: ReadonlyVal<boolean>;
|
|
25
24
|
readonly$: ReadonlyVal<boolean>;
|
|
26
25
|
darkMode$: ReadonlyVal<boolean>;
|
|
26
|
+
onClick?: () => void;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
type ValConfig = {
|
|
@@ -31,17 +31,13 @@ type ValConfig = {
|
|
|
31
31
|
$collector: Val<HTMLElement>;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
type PropsValConfig = {
|
|
35
|
-
root: TeleBoxCollectorConfig["root$"];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
34
|
type MyReadonlyValConfig = {
|
|
39
35
|
rect: ReadonlyVal<TeleBoxRect | undefined>;
|
|
40
36
|
visible: ReadonlyVal<boolean>;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> &
|
|
44
|
-
ReadonlyValEnhancedResult<
|
|
40
|
+
ReadonlyValEnhancedResult<MyReadonlyValConfig>;
|
|
45
41
|
|
|
46
42
|
export interface TeleBoxCollector extends CombinedValEnhancedResult {}
|
|
47
43
|
|
|
@@ -52,7 +48,8 @@ export class TeleBoxCollector {
|
|
|
52
48
|
darkMode$,
|
|
53
49
|
namespace = "telebox",
|
|
54
50
|
styles = {},
|
|
55
|
-
root
|
|
51
|
+
root,
|
|
52
|
+
onClick,
|
|
56
53
|
}: TeleBoxCollectorConfig) {
|
|
57
54
|
this.namespace = namespace;
|
|
58
55
|
|
|
@@ -71,12 +68,6 @@ export class TeleBoxCollector {
|
|
|
71
68
|
|
|
72
69
|
withValueEnhancer(this, valConfig, valManager);
|
|
73
70
|
|
|
74
|
-
const propsValConfig: PropsValConfig = {
|
|
75
|
-
root: root$,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
withReadonlyValueEnhancer(this, propsValConfig);
|
|
79
|
-
|
|
80
71
|
const myReadonlyValConfig: MyReadonlyValConfig = {
|
|
81
72
|
rect: rect$,
|
|
82
73
|
visible: visible$,
|
|
@@ -89,12 +80,17 @@ export class TeleBoxCollector {
|
|
|
89
80
|
|
|
90
81
|
this._sideEffect.addDisposer(
|
|
91
82
|
el$.subscribe(($collector) => {
|
|
83
|
+
this._sideEffect.add(() => {
|
|
84
|
+
root.appendChild($collector);
|
|
85
|
+
return () => $collector.remove();
|
|
86
|
+
}, "telebox-collector-mount");
|
|
87
|
+
|
|
92
88
|
this._sideEffect.addEventListener(
|
|
93
89
|
$collector,
|
|
94
|
-
"
|
|
95
|
-
(
|
|
96
|
-
if (
|
|
97
|
-
|
|
90
|
+
"click",
|
|
91
|
+
() => {
|
|
92
|
+
if (!readonly$.value) {
|
|
93
|
+
onClick?.();
|
|
98
94
|
}
|
|
99
95
|
},
|
|
100
96
|
{},
|
|
@@ -136,28 +132,20 @@ export class TeleBoxCollector {
|
|
|
136
132
|
}
|
|
137
133
|
});
|
|
138
134
|
}),
|
|
139
|
-
root$.subscribe((root) => {
|
|
140
|
-
if (root) {
|
|
141
|
-
root.appendChild($collector);
|
|
142
|
-
}
|
|
143
|
-
}),
|
|
144
135
|
// Place after $collector appended to the DOM so that rect calc works
|
|
145
|
-
|
|
146
|
-
(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
height,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
136
|
+
minimized$.subscribe((minimized) => {
|
|
137
|
+
if (minimized) {
|
|
138
|
+
const { x, y, width, height } =
|
|
139
|
+
$collector.getBoundingClientRect();
|
|
140
|
+
const rootRect = root.getBoundingClientRect();
|
|
141
|
+
rect$.setValue({
|
|
142
|
+
x: x - rootRect.x,
|
|
143
|
+
y: y - rootRect.y,
|
|
144
|
+
width,
|
|
145
|
+
height,
|
|
146
|
+
});
|
|
159
147
|
}
|
|
160
|
-
),
|
|
148
|
+
}),
|
|
161
149
|
],
|
|
162
150
|
"telebox-collector-el"
|
|
163
151
|
);
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
background-position: center;
|
|
25
25
|
-webkit-tap-highlight-color: transparent;
|
|
26
26
|
|
|
27
|
-
@include
|
|
28
|
-
@include
|
|
27
|
+
@include clr(background-color, collectorBackground);
|
|
28
|
+
@include clr(boxShadow, collectorShadow);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.#{$namespace}-collector-visible {
|
|
@@ -41,11 +41,7 @@
|
|
|
41
41
|
color-scheme: dark;
|
|
42
42
|
|
|
43
43
|
&.#{$namespace}-collector {
|
|
44
|
-
@include
|
|
45
|
-
|
|
46
|
-
collector-background-dark,
|
|
47
|
-
$collector-background-dark
|
|
48
|
-
);
|
|
49
|
-
@include v(box-shadow, collector-shadow-dark, $collector-shadow-dark);
|
|
44
|
+
@include clr-dark(background-color, collectorBackground);
|
|
45
|
+
@include clr-dark(boxShadow, collectorShadow);
|
|
50
46
|
}
|
|
51
47
|
}
|
|
@@ -113,21 +113,13 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
113
113
|
cursor: pointer;
|
|
114
114
|
user-select: none;
|
|
115
115
|
|
|
116
|
-
@include
|
|
117
|
-
@include
|
|
118
|
-
|
|
119
|
-
titlebar-tab-background,
|
|
120
|
-
$titlebar-tab-background
|
|
121
|
-
);
|
|
122
|
-
@include v(
|
|
123
|
-
border-right-color,
|
|
124
|
-
titlebar-tab-divider-color,
|
|
125
|
-
$titlebar-tab-divider-color
|
|
126
|
-
);
|
|
116
|
+
@include clr(color, titlebarTabColor);
|
|
117
|
+
@include clr(background-color, titlebarTabBackground);
|
|
118
|
+
@include clr(border-right-color, titlebarTabDividerColor);
|
|
127
119
|
}
|
|
128
120
|
|
|
129
121
|
.#{$namespace}-titles-tab-focus {
|
|
130
|
-
@include
|
|
122
|
+
@include clr(color, titlebarTabFocusColor);
|
|
131
123
|
}
|
|
132
124
|
|
|
133
125
|
.#{$namespace}-readonly {
|
|
@@ -140,24 +132,12 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
140
132
|
color-scheme: dark;
|
|
141
133
|
|
|
142
134
|
.#{$namespace}-titles-tab {
|
|
143
|
-
@include
|
|
144
|
-
@include
|
|
145
|
-
|
|
146
|
-
titlebar-tab-background-dark,
|
|
147
|
-
$titlebar-tab-background-dark
|
|
148
|
-
);
|
|
149
|
-
@include v(
|
|
150
|
-
border-right-color,
|
|
151
|
-
titlebar-tab-divider-color-dark,
|
|
152
|
-
$titlebar-tab-divider-color-dark
|
|
153
|
-
);
|
|
135
|
+
@include clr-dark(color, titlebarTabColor);
|
|
136
|
+
@include clr-dark(background-color, titlebarTabBackground);
|
|
137
|
+
@include clr-dark(border-right-color, titlebarTabDividerColor);
|
|
154
138
|
}
|
|
155
139
|
|
|
156
140
|
.#{$namespace}-titles-tab-focus {
|
|
157
|
-
@include
|
|
158
|
-
color,
|
|
159
|
-
titlebar-tab-focus-color-dark,
|
|
160
|
-
$titlebar-tab-focus-color-dark
|
|
161
|
-
);
|
|
141
|
+
@include clr-dark(color, titlebarTabFocusColor);
|
|
162
142
|
}
|
|
163
143
|
}
|
|
@@ -36,7 +36,9 @@ import type {
|
|
|
36
36
|
TeleBoxManagerConfig,
|
|
37
37
|
TeleBoxManagerCreateConfig,
|
|
38
38
|
TeleBoxManagerEventConfig,
|
|
39
|
+
TeleBoxFullscreen,
|
|
39
40
|
TeleBoxManagerQueryConfig,
|
|
41
|
+
TeleBoxManagerThemeConfig,
|
|
40
42
|
TeleBoxManagerUpdateConfig,
|
|
41
43
|
} from "./typings";
|
|
42
44
|
import { MaxTitleBar } from "./MaxTitleBar";
|
|
@@ -53,13 +55,14 @@ type ReadonlyValConfig = {
|
|
|
53
55
|
root: Val<HTMLElement | null>;
|
|
54
56
|
rootRect: Val<TeleBoxRect>;
|
|
55
57
|
stageRect: ReadonlyVal<TeleBoxRect>;
|
|
58
|
+
minimized: ReadonlyVal<boolean, boolean>;
|
|
59
|
+
maximized: ReadonlyVal<boolean, boolean>;
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
type ValConfig = {
|
|
63
|
+
fullscreen: Val<TeleBoxFullscreen>;
|
|
59
64
|
prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
|
|
60
65
|
readonly: Val<boolean, boolean>;
|
|
61
|
-
minimized: Val<boolean, boolean>;
|
|
62
|
-
maximized: Val<boolean, boolean>;
|
|
63
66
|
fence: Val<boolean, boolean>;
|
|
64
67
|
stageRatio: Val<number, boolean>;
|
|
65
68
|
containerStyle: Val<string>;
|
|
@@ -76,6 +79,7 @@ export interface TeleBoxManager extends CombinedValEnhancedResult {}
|
|
|
76
79
|
export class TeleBoxManager {
|
|
77
80
|
public constructor({
|
|
78
81
|
root = null,
|
|
82
|
+
fullscreen = false,
|
|
79
83
|
prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
|
|
80
84
|
minimized = false,
|
|
81
85
|
maximized = false,
|
|
@@ -88,6 +92,7 @@ export class TeleBoxManager {
|
|
|
88
92
|
stageStyle = "",
|
|
89
93
|
defaultBoxBodyStyle = null,
|
|
90
94
|
defaultBoxStageStyle = null,
|
|
95
|
+
theme = {},
|
|
91
96
|
}: TeleBoxManagerConfig = {}) {
|
|
92
97
|
this._sideEffect = new SideEffectManager();
|
|
93
98
|
|
|
@@ -98,14 +103,28 @@ export class TeleBoxManager {
|
|
|
98
103
|
|
|
99
104
|
const root$ = new Val(root);
|
|
100
105
|
const readonly$ = new Val(readonly);
|
|
101
|
-
const minimized$ = new Val(minimized);
|
|
102
|
-
const maximized$ = new Val(maximized);
|
|
103
106
|
const fence$ = new Val(fence);
|
|
104
107
|
const containerStyle$ = new Val(containerStyle);
|
|
105
108
|
const stageStyle$ = new Val(stageStyle);
|
|
106
109
|
const stageRatio$ = new Val(stageRatio);
|
|
107
110
|
const defaultBoxBodyStyle$ = new Val(defaultBoxBodyStyle);
|
|
108
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);
|
|
109
128
|
|
|
110
129
|
const rootRect$ = new Val<TeleBoxRect>(
|
|
111
130
|
{
|
|
@@ -202,32 +221,23 @@ export class TeleBoxManager {
|
|
|
202
221
|
: TELE_BOX_STATE.Normal
|
|
203
222
|
);
|
|
204
223
|
|
|
205
|
-
this.collector =
|
|
206
|
-
collector ??
|
|
207
|
-
new TeleBoxCollector({
|
|
208
|
-
minimized$: minimized$,
|
|
209
|
-
readonly$: readonly$,
|
|
210
|
-
darkMode$: darkMode$,
|
|
211
|
-
namespace,
|
|
212
|
-
root$,
|
|
213
|
-
});
|
|
214
|
-
|
|
215
224
|
const readonlyValConfig: ReadonlyValConfig = {
|
|
216
225
|
darkMode: darkMode$,
|
|
217
226
|
state: state$,
|
|
218
227
|
root: root$,
|
|
219
228
|
rootRect: rootRect$,
|
|
220
229
|
stageRect: stageRect$,
|
|
230
|
+
minimized: minimized$,
|
|
231
|
+
maximized: maximized$,
|
|
221
232
|
};
|
|
222
233
|
|
|
223
234
|
withReadonlyValueEnhancer(this, readonlyValConfig, valManager);
|
|
224
235
|
|
|
225
236
|
const valConfig: ValConfig = {
|
|
237
|
+
fullscreen: fullscreen$,
|
|
226
238
|
prefersColorScheme: prefersColorScheme$,
|
|
227
239
|
readonly: readonly$,
|
|
228
240
|
fence: fence$,
|
|
229
|
-
minimized: minimized$,
|
|
230
|
-
maximized: maximized$,
|
|
231
241
|
stageRatio: stageRatio$,
|
|
232
242
|
containerStyle: containerStyle$,
|
|
233
243
|
stageStyle: stageStyle$,
|
|
@@ -278,6 +288,7 @@ export class TeleBoxManager {
|
|
|
278
288
|
|
|
279
289
|
this.$container = document.createElement("div");
|
|
280
290
|
this.$container.className = this.wrapClassName("manager-container");
|
|
291
|
+
this.setTheme(theme);
|
|
281
292
|
|
|
282
293
|
this.$stage = document.createElement("div");
|
|
283
294
|
this.$stage.className = this.wrapClassName("manager-stage");
|
|
@@ -294,11 +305,34 @@ export class TeleBoxManager {
|
|
|
294
305
|
!darkMode
|
|
295
306
|
);
|
|
296
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
|
+
}),
|
|
297
325
|
maximized$.subscribe((maximized) => {
|
|
298
|
-
this.$container.classList.toggle(
|
|
326
|
+
this.$container.classList.toggle(
|
|
327
|
+
this.wrapClassName("is-maximized"),
|
|
328
|
+
maximized
|
|
329
|
+
);
|
|
299
330
|
}),
|
|
300
331
|
minimized$.subscribe((minimized) => {
|
|
301
|
-
this.$container.classList.toggle(
|
|
332
|
+
this.$container.classList.toggle(
|
|
333
|
+
this.wrapClassName("is-minimized"),
|
|
334
|
+
minimized
|
|
335
|
+
);
|
|
302
336
|
}),
|
|
303
337
|
containerStyle$.subscribe((containerStyle) => {
|
|
304
338
|
this.$container.style.cssText = containerStyle;
|
|
@@ -321,6 +355,17 @@ export class TeleBoxManager {
|
|
|
321
355
|
}),
|
|
322
356
|
]);
|
|
323
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
|
+
|
|
324
369
|
this.titleBar = new MaxTitleBar({
|
|
325
370
|
namespace: this.namespace,
|
|
326
371
|
title$: derive(this.topBox$, (topBox) => topBox?.title || ""),
|
|
@@ -333,11 +378,11 @@ export class TeleBoxManager {
|
|
|
333
378
|
onEvent: (event): void => {
|
|
334
379
|
switch (event.type) {
|
|
335
380
|
case TELE_BOX_DELEGATE_EVENT.Maximize: {
|
|
336
|
-
|
|
381
|
+
this.setMaximized(!maximized$.value);
|
|
337
382
|
break;
|
|
338
383
|
}
|
|
339
384
|
case TELE_BOX_DELEGATE_EVENT.Minimize: {
|
|
340
|
-
|
|
385
|
+
this.setMinimized(true);
|
|
341
386
|
break;
|
|
342
387
|
}
|
|
343
388
|
case TELE_BOX_EVENT.Close: {
|
|
@@ -403,6 +448,9 @@ export class TeleBoxManager {
|
|
|
403
448
|
|
|
404
449
|
public readonly namespace: string;
|
|
405
450
|
|
|
451
|
+
public setMinimized: (minimized: boolean, skipUpdate?: boolean) => void;
|
|
452
|
+
public setMaximized: (maximized: boolean, skipUpdate?: boolean) => void;
|
|
453
|
+
|
|
406
454
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
407
455
|
public setState(state: TeleBoxState, skipUpdate = false): this {
|
|
408
456
|
switch (state) {
|
|
@@ -576,6 +624,15 @@ export class TeleBoxManager {
|
|
|
576
624
|
return deletedBoxes;
|
|
577
625
|
}
|
|
578
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
|
+
|
|
579
636
|
/**
|
|
580
637
|
* Mount manager to a container element.
|
|
581
638
|
*/
|
|
@@ -9,48 +9,47 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
justify-content: center;
|
|
11
11
|
align-items: center;
|
|
12
|
-
@include
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
&.is-maximized,
|
|
19
|
-
&.is-minimized {
|
|
12
|
+
@include clr-root();
|
|
13
|
+
@include clr(background, managerContainerBackground);
|
|
14
|
+
|
|
15
|
+
&.#{$namespace}-is-maximized,
|
|
16
|
+
&.#{$namespace}-is-minimized {
|
|
20
17
|
& > .#{$namespace}-manager-stage {
|
|
21
18
|
overflow: visible;
|
|
22
19
|
}
|
|
23
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
|
+
}
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
.#{$namespace}-manager-stage {
|
|
27
37
|
position: relative;
|
|
28
38
|
overflow: hidden;
|
|
29
|
-
@include
|
|
30
|
-
@include
|
|
39
|
+
@include clr(background, managerStageBackground);
|
|
40
|
+
@include clr(boxShadow, managerStageShadow);
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
.#{$namespace}-color-scheme-dark {
|
|
34
44
|
color-scheme: dark;
|
|
35
45
|
|
|
36
46
|
&.#{$namespace}-manager-container {
|
|
37
|
-
@include
|
|
38
|
-
|
|
39
|
-
manager-container-background-dark,
|
|
40
|
-
$manager-container-background-dark
|
|
41
|
-
);
|
|
47
|
+
@include clr-root-dark();
|
|
48
|
+
@include clr-dark(background, managerContainerBackground);
|
|
42
49
|
|
|
43
50
|
& > .#{$namespace}-manager-stage {
|
|
44
|
-
@include
|
|
45
|
-
|
|
46
|
-
manager-stage-background-dark,
|
|
47
|
-
$manager-stage-background-dark
|
|
48
|
-
);
|
|
49
|
-
@include v(
|
|
50
|
-
box-shadow,
|
|
51
|
-
manager-stage-shadow-dark,
|
|
52
|
-
$manager-stage-shadow-dark
|
|
53
|
-
);
|
|
51
|
+
@include clr-dark(background, managerStageBackground);
|
|
52
|
+
@include clr-dark(boxShadow, managerStageShadow);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
}
|