@netless/telebox-insider 0.2.19 → 0.2.23
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/TeleTitleBar/DefaultTitleBar/index.d.ts +14 -2
- 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 +2 -2
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/style.scss +0 -2
- package/src/TeleBoxCollector/style.scss +1 -0
- package/src/TeleBoxManager/MaxTitleBar/index.ts +7 -0
- package/src/TeleBoxManager/MaxTitleBar/style.scss +12 -6
- package/src/TeleBoxManager/index.ts +5 -3
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +90 -24
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +21 -1
package/package.json
CHANGED
package/src/TeleBox/style.scss
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
top: 0;
|
|
6
6
|
left: 0;
|
|
7
7
|
z-index: $base-z-index;
|
|
8
|
-
will-change: transform;
|
|
9
8
|
transition: width 0.4s cubic-bezier(0.4, 0.9, 0.71, 1.02),
|
|
10
9
|
height 0.4s cubic-bezier(0.55, 0.82, 0.63, 0.95),
|
|
11
10
|
opacity 0.6s cubic-bezier(0.7, 0, 0.84, 0), transform 0.4s ease;
|
|
@@ -182,7 +181,6 @@
|
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
.#{$namespace}-minimized {
|
|
185
|
-
will-change: transform;
|
|
186
184
|
transition: width 0.05s cubic-bezier(0.4, 0.9, 0.71, 1.02),
|
|
187
185
|
height 0.05s cubic-bezier(0.55, 0.82, 0.63, 0.95),
|
|
188
186
|
opacity 0.6s cubic-bezier(0.7, 0, 0.84, 0), transform 0.6s ease;
|
|
@@ -105,6 +105,13 @@ export class MaxTitleBar extends DefaultTitleBar {
|
|
|
105
105
|
|
|
106
106
|
public render(): HTMLElement {
|
|
107
107
|
const $titleBar = super.render();
|
|
108
|
+
if ($titleBar.firstElementChild?.nextElementSibling) {
|
|
109
|
+
$titleBar.insertBefore(
|
|
110
|
+
this.$dragArea,
|
|
111
|
+
$titleBar.firstElementChild.nextElementSibling
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
108
115
|
const { x, y, width } = this.containerRect;
|
|
109
116
|
$titleBar.style.transform = `translate(${x}px, ${y}px)`;
|
|
110
117
|
$titleBar.style.width = width + "px";
|
|
@@ -15,6 +15,15 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
15
15
|
left: 0;
|
|
16
16
|
z-index: $base-z-index * 500;
|
|
17
17
|
user-select: none;
|
|
18
|
+
|
|
19
|
+
.#{$namespace}-drag-area {
|
|
20
|
+
height: 100%;
|
|
21
|
+
min-width: 16px;
|
|
22
|
+
position: static;
|
|
23
|
+
margin: 0;
|
|
24
|
+
flex-grow: 1;
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
.#{$namespace}-max-titlebar-maximized {
|
|
@@ -36,9 +45,8 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
.#{$namespace}-titles {
|
|
39
|
-
flex: 1;
|
|
40
48
|
height: 100%;
|
|
41
|
-
margin: 0
|
|
49
|
+
margin: 0;
|
|
42
50
|
overflow-y: hidden;
|
|
43
51
|
overflow-x: scroll;
|
|
44
52
|
overflow-x: overlay; // for webkit
|
|
@@ -92,6 +100,7 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
.#{$namespace}-titles-tab {
|
|
103
|
+
height: 100%;
|
|
95
104
|
overflow: hidden;
|
|
96
105
|
max-width: 182px;
|
|
97
106
|
min-width: 50px;
|
|
@@ -108,10 +117,7 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
|
|
|
108
117
|
color: #7b88a0;
|
|
109
118
|
background: transparent;
|
|
110
119
|
cursor: pointer;
|
|
111
|
-
|
|
112
|
-
& ~ & {
|
|
113
|
-
margin-left: 2px;
|
|
114
|
-
}
|
|
120
|
+
user-select: none;
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
.#{$namespace}-titles-tab-focus {
|
|
@@ -458,8 +458,11 @@ export class TeleBoxManager {
|
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
box._zIndex$.reaction((_, __, skipUpdate) => {
|
|
461
|
-
if (this.
|
|
462
|
-
this.topBox
|
|
461
|
+
if (this.boxes.length > 0) {
|
|
462
|
+
const topBox = this.boxes.reduce((topBox, box) =>
|
|
463
|
+
topBox.zIndex > box.zIndex ? topBox : box
|
|
464
|
+
);
|
|
465
|
+
this.topBox$.setValue(topBox);
|
|
463
466
|
}
|
|
464
467
|
if (!skipUpdate) {
|
|
465
468
|
this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
|
|
@@ -734,7 +737,6 @@ export class TeleBoxManager {
|
|
|
734
737
|
if (this.topBox) {
|
|
735
738
|
if (box !== this.topBox) {
|
|
736
739
|
box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
|
|
737
|
-
this.topBox$.setValue(box);
|
|
738
740
|
}
|
|
739
741
|
}
|
|
740
742
|
}
|
|
@@ -56,6 +56,8 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
56
56
|
iconClassName: this.wrapClassName("titlebar-icon-close"),
|
|
57
57
|
},
|
|
58
58
|
];
|
|
59
|
+
|
|
60
|
+
this.$dragArea = this.renderDragArea();
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
public readonly namespace: string;
|
|
@@ -64,6 +66,8 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
64
66
|
|
|
65
67
|
public $title: HTMLElement | undefined;
|
|
66
68
|
|
|
69
|
+
public $dragArea: HTMLElement;
|
|
70
|
+
|
|
67
71
|
public setTitle(title: string): void {
|
|
68
72
|
this.title = title;
|
|
69
73
|
if (this.$title) {
|
|
@@ -97,18 +101,10 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
97
101
|
if (!this.$titleBar) {
|
|
98
102
|
this.$titleBar = document.createElement("div");
|
|
99
103
|
this.$titleBar.className = this.wrapClassName("titlebar");
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.handleTitleBarClick
|
|
105
|
-
);
|
|
106
|
-
this.sideEffect.addEventListener(
|
|
107
|
-
this.$titleBar,
|
|
108
|
-
"touchstart",
|
|
109
|
-
this.handleTitleBarClick,
|
|
110
|
-
{ passive: true }
|
|
111
|
-
);
|
|
104
|
+
|
|
105
|
+
const $titleArea = document.createElement("div");
|
|
106
|
+
$titleArea.className = this.wrapClassName("title-area");
|
|
107
|
+
$titleArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
|
112
108
|
|
|
113
109
|
this.$title = document.createElement("h1");
|
|
114
110
|
this.$title.className = this.wrapClassName("title");
|
|
@@ -118,6 +114,9 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
118
114
|
this.$title.title = this.title;
|
|
119
115
|
}
|
|
120
116
|
|
|
117
|
+
$titleArea.appendChild(this.$title);
|
|
118
|
+
$titleArea.appendChild(this.$dragArea);
|
|
119
|
+
|
|
121
120
|
const $buttonsContainer = document.createElement("div");
|
|
122
121
|
$buttonsContainer.className = this.wrapClassName("titlebar-btns");
|
|
123
122
|
|
|
@@ -167,13 +166,31 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
167
166
|
}
|
|
168
167
|
);
|
|
169
168
|
|
|
170
|
-
this.$titleBar.appendChild(
|
|
169
|
+
this.$titleBar.appendChild($titleArea);
|
|
171
170
|
this.$titleBar.appendChild($buttonsContainer);
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
return this.$titleBar;
|
|
175
174
|
}
|
|
176
175
|
|
|
176
|
+
public renderDragArea(): HTMLElement {
|
|
177
|
+
const $dragArea = document.createElement("div");
|
|
178
|
+
$dragArea.className = this.wrapClassName("drag-area");
|
|
179
|
+
$dragArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
|
180
|
+
this.sideEffect.addEventListener(
|
|
181
|
+
$dragArea,
|
|
182
|
+
"mousedown",
|
|
183
|
+
this.handleTitleBarClick
|
|
184
|
+
);
|
|
185
|
+
this.sideEffect.addEventListener(
|
|
186
|
+
$dragArea,
|
|
187
|
+
"touchstart",
|
|
188
|
+
this.handleTitleBarTouch,
|
|
189
|
+
{ passive: true }
|
|
190
|
+
);
|
|
191
|
+
return $dragArea;
|
|
192
|
+
}
|
|
193
|
+
|
|
177
194
|
public dragHandle(): HTMLElement | undefined {
|
|
178
195
|
return this.$titleBar;
|
|
179
196
|
}
|
|
@@ -209,17 +226,18 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
209
226
|
|
|
210
227
|
protected sideEffect = new SideEffectManager();
|
|
211
228
|
|
|
212
|
-
protected lastTitleBarClick =
|
|
229
|
+
protected lastTitleBarClick = {
|
|
230
|
+
timestamp: 0,
|
|
231
|
+
clientX: -100,
|
|
232
|
+
clientY: -100,
|
|
233
|
+
};
|
|
213
234
|
|
|
214
|
-
protected handleTitleBarClick = (ev: MouseEvent
|
|
235
|
+
protected handleTitleBarClick = (ev: MouseEvent): void => {
|
|
215
236
|
if (this.readonly) {
|
|
216
237
|
return;
|
|
217
238
|
}
|
|
218
239
|
|
|
219
|
-
if (
|
|
220
|
-
(ev as MouseEvent).button != null &&
|
|
221
|
-
(ev as MouseEvent).button !== 0
|
|
222
|
-
) {
|
|
240
|
+
if (ev.button !== 0) {
|
|
223
241
|
return; // Not left mouse
|
|
224
242
|
}
|
|
225
243
|
|
|
@@ -230,14 +248,62 @@ export class DefaultTitleBar implements TeleTitleBar {
|
|
|
230
248
|
preventEvent(ev);
|
|
231
249
|
|
|
232
250
|
const now = Date.now();
|
|
233
|
-
if (now - this.lastTitleBarClick <= 500) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
251
|
+
if (now - this.lastTitleBarClick.timestamp <= 500) {
|
|
252
|
+
if (
|
|
253
|
+
Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 3 &&
|
|
254
|
+
Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 3
|
|
255
|
+
) {
|
|
256
|
+
// double click
|
|
257
|
+
if (this.onEvent) {
|
|
258
|
+
this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} else if (this.onDragStart) {
|
|
262
|
+
this.onDragStart(ev);
|
|
263
|
+
}
|
|
264
|
+
this.lastTitleBarClick.timestamp = now;
|
|
265
|
+
this.lastTitleBarClick.clientX = ev.clientX;
|
|
266
|
+
this.lastTitleBarClick.clientY = ev.clientY;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
protected lastTitleBarTouch = {
|
|
270
|
+
timestamp: 0,
|
|
271
|
+
clientX: -100,
|
|
272
|
+
clientY: -100,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
protected handleTitleBarTouch = (ev: TouchEvent): void => {
|
|
276
|
+
if (this.readonly) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if ((ev.target as HTMLElement).dataset?.teleTitleBarNoDblClick) {
|
|
281
|
+
return; // btns
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
preventEvent(ev);
|
|
285
|
+
|
|
286
|
+
const now = Date.now();
|
|
287
|
+
const {
|
|
288
|
+
clientX = this.lastTitleBarTouch.clientX + 100,
|
|
289
|
+
clientY = this.lastTitleBarTouch.clientY + 100,
|
|
290
|
+
} = ev.touches[0] || {};
|
|
291
|
+
|
|
292
|
+
if (now - this.lastTitleBarTouch.timestamp <= 500) {
|
|
293
|
+
if (
|
|
294
|
+
Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 3 &&
|
|
295
|
+
Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 3
|
|
296
|
+
) {
|
|
297
|
+
// double click
|
|
298
|
+
if (this.onEvent) {
|
|
299
|
+
this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
|
|
300
|
+
}
|
|
237
301
|
}
|
|
238
302
|
} else if (this.onDragStart) {
|
|
239
303
|
this.onDragStart(ev);
|
|
240
304
|
}
|
|
241
|
-
this.
|
|
305
|
+
this.lastTitleBarTouch.timestamp = now;
|
|
306
|
+
this.lastTitleBarTouch.clientX = clientX;
|
|
307
|
+
this.lastTitleBarTouch.clientY = clientY;
|
|
242
308
|
};
|
|
243
309
|
}
|
|
@@ -9,11 +9,21 @@
|
|
|
9
9
|
background: #fff;
|
|
10
10
|
user-select: none;
|
|
11
11
|
border-bottom: 1px solid #eeeef7;
|
|
12
|
+
touch-action: manipulation;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.#{$namespace}-title-area {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
position: relative;
|
|
18
|
+
height: 100%;
|
|
19
|
+
flex: 1;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
.#{$namespace}-title {
|
|
15
25
|
overflow: hidden;
|
|
16
|
-
margin: 0
|
|
26
|
+
margin: 0;
|
|
17
27
|
padding: 0;
|
|
18
28
|
font-size: 14px;
|
|
19
29
|
font-weight: 400;
|
|
@@ -24,6 +34,16 @@
|
|
|
24
34
|
color: #191919;
|
|
25
35
|
}
|
|
26
36
|
|
|
37
|
+
.#{$namespace}-drag-area {
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 0;
|
|
40
|
+
left: 0;
|
|
41
|
+
right: 0;
|
|
42
|
+
bottom: 0;
|
|
43
|
+
margin: auto;
|
|
44
|
+
z-index: 10;
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
.#{$namespace}-titlebar-btns {
|
|
28
48
|
white-space: nowrap;
|
|
29
49
|
word-break: keep-all;
|