@netless/telebox-insider 1.0.0-alpha.10 → 1.0.0-alpha.13
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 +11 -2
- package/dist/TeleBox/typings.d.ts +7 -3
- package/dist/TeleBoxManager/typings.d.ts +4 -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 +1 -1
- package/src/TeleBox/index.ts +79 -7
- package/src/TeleBox/style.scss +4 -0
- package/src/TeleBox/typings.ts +7 -3
- package/src/TeleBoxManager/index.ts +4 -1
- package/src/TeleBoxManager/typings.ts +10 -3
package/package.json
CHANGED
package/src/TeleBox/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ type ValConfig = {
|
|
|
58
58
|
resizable: Val<RequiredTeleBoxConfig["resizable"], boolean>;
|
|
59
59
|
draggable: Val<RequiredTeleBoxConfig["draggable"], boolean>;
|
|
60
60
|
ratio: Val<RequiredTeleBoxConfig["ratio"], boolean>;
|
|
61
|
+
stageRatio: Val<number | null>;
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
type PropsValConfig = {
|
|
@@ -76,6 +77,7 @@ type MyReadonlyValConfig = {
|
|
|
76
77
|
focus: Val<RequiredTeleBoxConfig["focus"], boolean>;
|
|
77
78
|
|
|
78
79
|
$userContent: Val<TeleBoxConfig["content"], boolean>;
|
|
80
|
+
$userStage: Val<TeleBoxConfig["content"], boolean>;
|
|
79
81
|
$userFooter: Val<TeleBoxConfig["footer"], boolean>;
|
|
80
82
|
$userStyles: Val<TeleBoxConfig["styles"], boolean>;
|
|
81
83
|
|
|
@@ -116,8 +118,10 @@ export class TeleBox {
|
|
|
116
118
|
ratio = -1,
|
|
117
119
|
focus = false,
|
|
118
120
|
zIndex = 100,
|
|
121
|
+
stageRatio = null,
|
|
119
122
|
titleBar,
|
|
120
123
|
content,
|
|
124
|
+
stage,
|
|
121
125
|
footer,
|
|
122
126
|
styles,
|
|
123
127
|
highlightStage = null,
|
|
@@ -129,7 +133,7 @@ export class TeleBox {
|
|
|
129
133
|
root$,
|
|
130
134
|
rootRect$,
|
|
131
135
|
managerStageRect$,
|
|
132
|
-
|
|
136
|
+
managerStageRatio$,
|
|
133
137
|
collectorRect$,
|
|
134
138
|
managerHighlightStage$,
|
|
135
139
|
}: TeleBoxConfig) {
|
|
@@ -149,6 +153,7 @@ export class TeleBox {
|
|
|
149
153
|
const zIndex$ = new Val(zIndex);
|
|
150
154
|
const focus$ = new Val(focus);
|
|
151
155
|
const $userContent$ = new Val(content);
|
|
156
|
+
const $userStage$ = new Val(stage);
|
|
152
157
|
const $userFooter$ = new Val(footer);
|
|
153
158
|
const $userStyles$ = new Val(styles);
|
|
154
159
|
|
|
@@ -226,11 +231,9 @@ export class TeleBox {
|
|
|
226
231
|
);
|
|
227
232
|
|
|
228
233
|
const highlightStage$ = combine(
|
|
229
|
-
[
|
|
230
|
-
([
|
|
231
|
-
boxHighlightStage
|
|
232
|
-
? managerHighlightStage && maximized
|
|
233
|
-
: boxHighlightStage
|
|
234
|
+
[boxHighlightStage$, managerHighlightStage$],
|
|
235
|
+
([boxHighlightStage, managerHighlightStage]) =>
|
|
236
|
+
boxHighlightStage ?? managerHighlightStage
|
|
234
237
|
);
|
|
235
238
|
|
|
236
239
|
const contentRoot$ = new Val<HTMLElement | null>(null);
|
|
@@ -239,11 +242,17 @@ export class TeleBox {
|
|
|
239
242
|
compare: shallowequal,
|
|
240
243
|
});
|
|
241
244
|
|
|
245
|
+
const stageRatio$ = new Val(stageRatio);
|
|
246
|
+
|
|
242
247
|
const teleStage = new TeleStage({
|
|
243
248
|
namespace,
|
|
244
249
|
root$: contentRoot$,
|
|
245
250
|
rootRect$: contentRect$,
|
|
246
|
-
ratio$:
|
|
251
|
+
ratio$: combine(
|
|
252
|
+
[stageRatio$, managerStageRatio$],
|
|
253
|
+
([stageRatio, managerStageRatio]) =>
|
|
254
|
+
stageRatio ?? managerStageRatio
|
|
255
|
+
),
|
|
247
256
|
highlightStage$,
|
|
248
257
|
});
|
|
249
258
|
this._sideEffect.addDisposer(() => teleStage.destroy());
|
|
@@ -266,6 +275,7 @@ export class TeleBox {
|
|
|
266
275
|
focus: focus$,
|
|
267
276
|
|
|
268
277
|
$userContent: $userContent$,
|
|
278
|
+
$userStage: $userStage$,
|
|
269
279
|
$userFooter: $userFooter$,
|
|
270
280
|
$userStyles: $userStyles$,
|
|
271
281
|
|
|
@@ -290,6 +300,7 @@ export class TeleBox {
|
|
|
290
300
|
resizable: resizable$,
|
|
291
301
|
draggable: draggable$,
|
|
292
302
|
ratio: ratio$,
|
|
303
|
+
stageRatio: stageRatio$,
|
|
293
304
|
};
|
|
294
305
|
|
|
295
306
|
withValueEnhancer(this, valConfig, valManager);
|
|
@@ -573,6 +584,17 @@ export class TeleBox {
|
|
|
573
584
|
this._$userContent$.setValue(undefined);
|
|
574
585
|
}
|
|
575
586
|
|
|
587
|
+
public mountStage(stage: HTMLElement): void {
|
|
588
|
+
this._$userStage$.setValue(stage);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Unmount content from the box.
|
|
593
|
+
*/
|
|
594
|
+
public unmountStage(): void {
|
|
595
|
+
this._$userStage$.setValue(undefined);
|
|
596
|
+
}
|
|
597
|
+
|
|
576
598
|
/**
|
|
577
599
|
* Mount dom to box Footer.
|
|
578
600
|
*/
|
|
@@ -617,6 +639,9 @@ export class TeleBox {
|
|
|
617
639
|
/** DOM of the box content */
|
|
618
640
|
public $content!: HTMLElement;
|
|
619
641
|
|
|
642
|
+
/** DOM of the box stage area */
|
|
643
|
+
public $stage?: HTMLElement;
|
|
644
|
+
|
|
620
645
|
/** DOM of the box title bar */
|
|
621
646
|
public $titleBar!: HTMLElement;
|
|
622
647
|
|
|
@@ -828,6 +853,41 @@ export class TeleBox {
|
|
|
828
853
|
});
|
|
829
854
|
});
|
|
830
855
|
|
|
856
|
+
this._sideEffect.add(() => {
|
|
857
|
+
let last$userStage: HTMLElement | undefined;
|
|
858
|
+
return this._$userStage$.subscribe(($userStage) => {
|
|
859
|
+
if (last$userStage) {
|
|
860
|
+
last$userStage.remove();
|
|
861
|
+
}
|
|
862
|
+
last$userStage = $userStage;
|
|
863
|
+
if ($userStage) {
|
|
864
|
+
if (!this.$stage) {
|
|
865
|
+
const $stage = document.createElement("div");
|
|
866
|
+
this.$stage = $stage;
|
|
867
|
+
$stage.className = this.wrapClassName("content-stage");
|
|
868
|
+
this._sideEffect.addDisposer(
|
|
869
|
+
this._contentStageRect$.subscribe((rect) => {
|
|
870
|
+
if (rect) {
|
|
871
|
+
$stage.style.top = rect.y + "px";
|
|
872
|
+
$stage.style.left = rect.x + "px";
|
|
873
|
+
$stage.style.width = rect.width + "px";
|
|
874
|
+
$stage.style.height = rect.height + "px";
|
|
875
|
+
}
|
|
876
|
+
}),
|
|
877
|
+
"content-stage-rect"
|
|
878
|
+
);
|
|
879
|
+
$content.appendChild($stage);
|
|
880
|
+
}
|
|
881
|
+
if (!this.$stage.parentElement) {
|
|
882
|
+
$content.appendChild(this.$stage);
|
|
883
|
+
}
|
|
884
|
+
this.$stage.appendChild($userStage);
|
|
885
|
+
} else if (this.$stage?.parentElement) {
|
|
886
|
+
this.$stage.remove();
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
|
|
831
891
|
$contentWrap.appendChild($content);
|
|
832
892
|
|
|
833
893
|
const $footer = document.createElement("div");
|
|
@@ -1109,7 +1169,19 @@ export type ReadonlyTeleBox = Pick<
|
|
|
1109
1169
|
| PropKeys
|
|
1110
1170
|
| "wrapClassName"
|
|
1111
1171
|
| "mountContent"
|
|
1172
|
+
| "unmountContent"
|
|
1112
1173
|
| "mountFooter"
|
|
1174
|
+
| "unmountFooter"
|
|
1175
|
+
| "mountStage"
|
|
1176
|
+
| "unmountStage"
|
|
1113
1177
|
| "mountStyles"
|
|
1178
|
+
| "unmountStyles"
|
|
1179
|
+
| "setStageRatio"
|
|
1180
|
+
| "setDraggable"
|
|
1181
|
+
| "setResizable"
|
|
1182
|
+
| "setHighlightStage"
|
|
1183
|
+
| "setTitle"
|
|
1184
|
+
| "setRatio"
|
|
1185
|
+
| "setVisible"
|
|
1114
1186
|
| "handleTrackStart"
|
|
1115
1187
|
>;
|
package/src/TeleBox/style.scss
CHANGED
package/src/TeleBox/typings.ts
CHANGED
|
@@ -56,13 +56,17 @@ export interface TeleBoxConfig {
|
|
|
56
56
|
readonly focus?: boolean;
|
|
57
57
|
/** Base z-index for box. */
|
|
58
58
|
readonly zIndex?: number;
|
|
59
|
+
/** Box stage ratio. Follow manager stage ratio if null. Default null. */
|
|
60
|
+
readonly stageRatio?: number | null;
|
|
59
61
|
/** Classname Prefix. For CSS styling. Default "telebox". */
|
|
60
62
|
readonly namespace?: string;
|
|
61
63
|
/** TeleTitleBar Instance. */
|
|
62
64
|
readonly titleBar?: TeleTitleBar;
|
|
63
|
-
/** Box content. */
|
|
65
|
+
/** Box content element. */
|
|
64
66
|
readonly content?: HTMLElement;
|
|
65
|
-
/**
|
|
67
|
+
/** Stage element. */
|
|
68
|
+
readonly stage?: HTMLElement;
|
|
69
|
+
/** Box footer element. */
|
|
66
70
|
readonly footer?: HTMLElement;
|
|
67
71
|
/** Box content styles. */
|
|
68
72
|
readonly styles?: HTMLStyleElement;
|
|
@@ -85,7 +89,7 @@ export interface TeleBoxConfig {
|
|
|
85
89
|
/** Position and dimension of stage area */
|
|
86
90
|
readonly managerStageRect$: ReadonlyVal<TeleBoxRect>;
|
|
87
91
|
/** Stage area height/with ratio. No ratio if <= 0. */
|
|
88
|
-
readonly
|
|
92
|
+
readonly managerStageRatio$: ReadonlyVal<number, boolean>;
|
|
89
93
|
/** Position and dimension of collector */
|
|
90
94
|
readonly collectorRect$: ReadonlyVal<TeleBoxRect | undefined>;
|
|
91
95
|
/** highlight stage settings from manager */
|
|
@@ -394,7 +394,7 @@ export class TeleBoxManager {
|
|
|
394
394
|
fence$: this._fence$,
|
|
395
395
|
rootRect$: this._rootRect$,
|
|
396
396
|
managerStageRect$: this._stageRect$,
|
|
397
|
-
|
|
397
|
+
managerStageRatio$: this._stageRatio$,
|
|
398
398
|
readonly$: this._readonly$,
|
|
399
399
|
collectorRect$: this.collector._rect$,
|
|
400
400
|
managerHighlightStage$: this._highlightStage$,
|
|
@@ -670,6 +670,9 @@ export class TeleBoxManager {
|
|
|
670
670
|
if (config.zIndex != null) {
|
|
671
671
|
box._zIndex$.setValue(config.zIndex, skipUpdate);
|
|
672
672
|
}
|
|
673
|
+
if (config.stageRatio !== undefined) {
|
|
674
|
+
box.setStageRatio(config.stageRatio, skipUpdate);
|
|
675
|
+
}
|
|
673
676
|
if (config.content != null) {
|
|
674
677
|
box.mountContent(config.content);
|
|
675
678
|
}
|
|
@@ -37,11 +37,17 @@ type TeleBoxManagerBoxConfigBaseProps =
|
|
|
37
37
|
| "resizable"
|
|
38
38
|
| "draggable"
|
|
39
39
|
| "ratio"
|
|
40
|
-
| "zIndex"
|
|
40
|
+
| "zIndex"
|
|
41
|
+
| "stageRatio";
|
|
41
42
|
|
|
42
43
|
export type TeleBoxManagerCreateConfig = Pick<
|
|
43
44
|
TeleBoxConfig,
|
|
44
|
-
|
|
45
|
+
| TeleBoxManagerBoxConfigBaseProps
|
|
46
|
+
| "content"
|
|
47
|
+
| "stage"
|
|
48
|
+
| "footer"
|
|
49
|
+
| "id"
|
|
50
|
+
| "focus"
|
|
45
51
|
>;
|
|
46
52
|
|
|
47
53
|
export type TeleBoxManagerQueryConfig = Pick<
|
|
@@ -51,6 +57,7 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
51
57
|
| "resizable"
|
|
52
58
|
| "draggable"
|
|
53
59
|
| "ratio"
|
|
60
|
+
| "stageRatio"
|
|
54
61
|
| "zIndex"
|
|
55
62
|
| "id"
|
|
56
63
|
| "focus"
|
|
@@ -58,7 +65,7 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
58
65
|
|
|
59
66
|
export type TeleBoxManagerUpdateConfig = Pick<
|
|
60
67
|
TeleBoxConfig,
|
|
61
|
-
TeleBoxManagerBoxConfigBaseProps | "content" | "footer"
|
|
68
|
+
TeleBoxManagerBoxConfigBaseProps | "content" | "stage" | "footer"
|
|
62
69
|
>;
|
|
63
70
|
|
|
64
71
|
type CheckTeleBoxManagerConfig<
|