@netless/telebox-insider 1.0.0-alpha.11 → 1.0.0-alpha.14
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 +10 -2
- package/dist/TeleBox/typings.d.ts +4 -2
- package/dist/TeleBoxManager/typings.d.ts +2 -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 +1 -1
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/TeleBox/index.ts +70 -7
- package/src/TeleBox/style.scss +4 -0
- package/src/TeleBox/typings.ts +4 -2
- package/src/TeleBoxManager/index.ts +2 -2
- package/src/TeleBoxManager/typings.ts +7 -2
package/package.json
CHANGED
package/src/TeleBox/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ type MyReadonlyValConfig = {
|
|
|
77
77
|
focus: Val<RequiredTeleBoxConfig["focus"], boolean>;
|
|
78
78
|
|
|
79
79
|
$userContent: Val<TeleBoxConfig["content"], boolean>;
|
|
80
|
+
$userStage: Val<TeleBoxConfig["content"], boolean>;
|
|
80
81
|
$userFooter: Val<TeleBoxConfig["footer"], boolean>;
|
|
81
82
|
$userStyles: Val<TeleBoxConfig["styles"], boolean>;
|
|
82
83
|
|
|
@@ -120,6 +121,7 @@ export class TeleBox {
|
|
|
120
121
|
stageRatio = null,
|
|
121
122
|
titleBar,
|
|
122
123
|
content,
|
|
124
|
+
stage,
|
|
123
125
|
footer,
|
|
124
126
|
styles,
|
|
125
127
|
highlightStage = null,
|
|
@@ -151,6 +153,7 @@ export class TeleBox {
|
|
|
151
153
|
const zIndex$ = new Val(zIndex);
|
|
152
154
|
const focus$ = new Val(focus);
|
|
153
155
|
const $userContent$ = new Val(content);
|
|
156
|
+
const $userStage$ = new Val(stage);
|
|
154
157
|
const $userFooter$ = new Val(footer);
|
|
155
158
|
const $userStyles$ = new Val(styles);
|
|
156
159
|
|
|
@@ -228,11 +231,9 @@ export class TeleBox {
|
|
|
228
231
|
);
|
|
229
232
|
|
|
230
233
|
const highlightStage$ = combine(
|
|
231
|
-
[
|
|
232
|
-
([
|
|
233
|
-
boxHighlightStage
|
|
234
|
-
? managerHighlightStage && maximized
|
|
235
|
-
: boxHighlightStage
|
|
234
|
+
[boxHighlightStage$, managerHighlightStage$],
|
|
235
|
+
([boxHighlightStage, managerHighlightStage]) =>
|
|
236
|
+
boxHighlightStage ?? managerHighlightStage
|
|
236
237
|
);
|
|
237
238
|
|
|
238
239
|
const contentRoot$ = new Val<HTMLElement | null>(null);
|
|
@@ -274,6 +275,7 @@ export class TeleBox {
|
|
|
274
275
|
focus: focus$,
|
|
275
276
|
|
|
276
277
|
$userContent: $userContent$,
|
|
278
|
+
$userStage: $userStage$,
|
|
277
279
|
$userFooter: $userFooter$,
|
|
278
280
|
$userStyles: $userStyles$,
|
|
279
281
|
|
|
@@ -582,6 +584,17 @@ export class TeleBox {
|
|
|
582
584
|
this._$userContent$.setValue(undefined);
|
|
583
585
|
}
|
|
584
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
|
+
|
|
585
598
|
/**
|
|
586
599
|
* Mount dom to box Footer.
|
|
587
600
|
*/
|
|
@@ -626,6 +639,9 @@ export class TeleBox {
|
|
|
626
639
|
/** DOM of the box content */
|
|
627
640
|
public $content!: HTMLElement;
|
|
628
641
|
|
|
642
|
+
/** DOM of the box stage area */
|
|
643
|
+
public $stage?: HTMLElement;
|
|
644
|
+
|
|
629
645
|
/** DOM of the box title bar */
|
|
630
646
|
public $titleBar!: HTMLElement;
|
|
631
647
|
|
|
@@ -801,8 +817,8 @@ export class TeleBox {
|
|
|
801
817
|
const observer = new ResizeObserver(() => {
|
|
802
818
|
const rect = $content.getBoundingClientRect();
|
|
803
819
|
this._contentRect$.setValue({
|
|
804
|
-
x:
|
|
805
|
-
y:
|
|
820
|
+
x: 0,
|
|
821
|
+
y: 0,
|
|
806
822
|
width: rect.width,
|
|
807
823
|
height: rect.height,
|
|
808
824
|
});
|
|
@@ -837,6 +853,41 @@ export class TeleBox {
|
|
|
837
853
|
});
|
|
838
854
|
});
|
|
839
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
|
+
|
|
840
891
|
$contentWrap.appendChild($content);
|
|
841
892
|
|
|
842
893
|
const $footer = document.createElement("div");
|
|
@@ -1118,7 +1169,19 @@ export type ReadonlyTeleBox = Pick<
|
|
|
1118
1169
|
| PropKeys
|
|
1119
1170
|
| "wrapClassName"
|
|
1120
1171
|
| "mountContent"
|
|
1172
|
+
| "unmountContent"
|
|
1121
1173
|
| "mountFooter"
|
|
1174
|
+
| "unmountFooter"
|
|
1175
|
+
| "mountStage"
|
|
1176
|
+
| "unmountStage"
|
|
1122
1177
|
| "mountStyles"
|
|
1178
|
+
| "unmountStyles"
|
|
1179
|
+
| "setStageRatio"
|
|
1180
|
+
| "setDraggable"
|
|
1181
|
+
| "setResizable"
|
|
1182
|
+
| "setHighlightStage"
|
|
1183
|
+
| "setTitle"
|
|
1184
|
+
| "setRatio"
|
|
1185
|
+
| "setVisible"
|
|
1123
1186
|
| "handleTrackStart"
|
|
1124
1187
|
>;
|
package/src/TeleBox/style.scss
CHANGED
package/src/TeleBox/typings.ts
CHANGED
|
@@ -62,9 +62,11 @@ export interface TeleBoxConfig {
|
|
|
62
62
|
readonly namespace?: string;
|
|
63
63
|
/** TeleTitleBar Instance. */
|
|
64
64
|
readonly titleBar?: TeleTitleBar;
|
|
65
|
-
/** Box content. */
|
|
65
|
+
/** Box content element. */
|
|
66
66
|
readonly content?: HTMLElement;
|
|
67
|
-
/**
|
|
67
|
+
/** Stage element. */
|
|
68
|
+
readonly stage?: HTMLElement;
|
|
69
|
+
/** Box footer element. */
|
|
68
70
|
readonly footer?: HTMLElement;
|
|
69
71
|
/** Box content styles. */
|
|
70
72
|
readonly styles?: HTMLStyleElement;
|
|
@@ -114,8 +114,8 @@ export class TeleBoxManager {
|
|
|
114
114
|
const observer = new ResizeObserver(() => {
|
|
115
115
|
const rect = root.getBoundingClientRect();
|
|
116
116
|
rootRect$.setValue({
|
|
117
|
-
x:
|
|
118
|
-
y:
|
|
117
|
+
x: 0,
|
|
118
|
+
y: 0,
|
|
119
119
|
width: rect.width,
|
|
120
120
|
height: rect.height,
|
|
121
121
|
});
|
|
@@ -42,7 +42,12 @@ type TeleBoxManagerBoxConfigBaseProps =
|
|
|
42
42
|
|
|
43
43
|
export type TeleBoxManagerCreateConfig = Pick<
|
|
44
44
|
TeleBoxConfig,
|
|
45
|
-
|
|
45
|
+
| TeleBoxManagerBoxConfigBaseProps
|
|
46
|
+
| "content"
|
|
47
|
+
| "stage"
|
|
48
|
+
| "footer"
|
|
49
|
+
| "id"
|
|
50
|
+
| "focus"
|
|
46
51
|
>;
|
|
47
52
|
|
|
48
53
|
export type TeleBoxManagerQueryConfig = Pick<
|
|
@@ -60,7 +65,7 @@ export type TeleBoxManagerQueryConfig = Pick<
|
|
|
60
65
|
|
|
61
66
|
export type TeleBoxManagerUpdateConfig = Pick<
|
|
62
67
|
TeleBoxConfig,
|
|
63
|
-
TeleBoxManagerBoxConfigBaseProps | "content" | "footer"
|
|
68
|
+
TeleBoxManagerBoxConfigBaseProps | "content" | "stage" | "footer"
|
|
64
69
|
>;
|
|
65
70
|
|
|
66
71
|
type CheckTeleBoxManagerConfig<
|