@flowgram.ai/panel-manager-plugin 1.0.2 → 1.0.3
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/.rush/temp/chunked-rush-logs/panel-manager-plugin.build.chunks.jsonl +9 -9
- package/.rush/temp/package-deps_build.json +20 -15
- package/.rush/temp/shrinkwrap-deps.json +7 -2
- package/CHANGELOG.json +3 -3
- package/CHANGELOG.md +3 -3
- package/dist/esm/index.js +410 -209
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +102 -32
- package/dist/index.d.ts +102 -32
- package/dist/index.js +412 -208
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
- package/rush-logs/panel-manager-plugin.build.log +9 -9
- package/src/components/panel-layer/css.ts +63 -58
- package/src/components/panel-layer/docked-panel-layer.tsx +12 -0
- package/src/components/panel-layer/index.ts +2 -1
- package/src/components/panel-layer/panel-layer.tsx +42 -15
- package/src/components/panel-layer/panel.tsx +90 -0
- package/src/components/resize-bar/index.tsx +6 -3
- package/src/contexts.ts +10 -0
- package/src/create-panel-manager-plugin.ts +32 -2
- package/src/hooks/use-global-css.ts +31 -0
- package/src/hooks/use-panel.ts +10 -0
- package/src/index.ts +3 -1
- package/src/services/index.ts +1 -0
- package/src/services/panel-config.ts +23 -2
- package/src/services/panel-factory.ts +81 -0
- package/src/services/panel-layer.ts +2 -1
- package/src/services/panel-manager.ts +79 -16
- package/src/services/panel-restore.ts +25 -0
- package/src/types.ts +12 -1
- package/src/components/panel-layer/float-panel.tsx +0 -54
- package/src/services/float-panel.ts +0 -75
package/dist/esm/index.js
CHANGED
|
@@ -12,200 +12,90 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
12
12
|
// src/create-panel-manager-plugin.ts
|
|
13
13
|
import { definePluginCreator } from "@flowgram.ai/core";
|
|
14
14
|
|
|
15
|
-
// src/services/panel-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
right: {
|
|
20
|
-
max: 1
|
|
21
|
-
},
|
|
22
|
-
bottom: {
|
|
23
|
-
max: 1
|
|
24
|
-
},
|
|
25
|
-
factories: [],
|
|
26
|
-
getPopupContainer: (ctx) => ctx.playground.node.parentNode,
|
|
27
|
-
autoResize: true
|
|
28
|
-
};
|
|
29
|
-
return {
|
|
30
|
-
...defaultConfig,
|
|
31
|
-
...config
|
|
32
|
-
};
|
|
33
|
-
};
|
|
15
|
+
// src/services/panel-factory.ts
|
|
16
|
+
import { createStore } from "zustand/vanilla";
|
|
17
|
+
import { nanoid } from "nanoid";
|
|
18
|
+
import { inject, injectable as injectable2 } from "inversify";
|
|
34
19
|
|
|
35
|
-
// src/services/panel-
|
|
36
|
-
import { injectable
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var FloatPanel = class {
|
|
42
|
-
constructor(config) {
|
|
43
|
-
this.config = config;
|
|
44
|
-
this.elements = [];
|
|
45
|
-
this.onUpdateEmitter = new Emitter();
|
|
46
|
-
this.sizeMap = /* @__PURE__ */ new Map();
|
|
47
|
-
this.onUpdate = this.onUpdateEmitter.event;
|
|
48
|
-
this.currentFactoryKey = "";
|
|
49
|
-
}
|
|
50
|
-
updateSize(newSize) {
|
|
51
|
-
this.sizeMap.set(this.currentFactoryKey, newSize);
|
|
52
|
-
this.onUpdateEmitter.fire();
|
|
53
|
-
}
|
|
54
|
-
get currentSize() {
|
|
55
|
-
return this.sizeMap.get(this.currentFactoryKey) || PANEL_SIZE_DEFAULT;
|
|
56
|
-
}
|
|
57
|
-
open(factory, options) {
|
|
58
|
-
const el = factory.render(options?.props);
|
|
59
|
-
const idx = this.elements.findIndex((e) => e.key === factory.key);
|
|
60
|
-
this.currentFactoryKey = factory.key;
|
|
61
|
-
if (!this.sizeMap.has(factory.key)) {
|
|
62
|
-
this.sizeMap.set(factory.key, factory.defaultSize || PANEL_SIZE_DEFAULT);
|
|
63
|
-
}
|
|
64
|
-
if (idx >= 0) {
|
|
65
|
-
this.elements[idx] = { el, key: factory.key, style: factory.style };
|
|
66
|
-
} else {
|
|
67
|
-
this.elements.push({ el, key: factory.key, style: factory.style });
|
|
68
|
-
if (this.elements.length > this.config.max) {
|
|
69
|
-
this.elements.shift();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
this.onUpdateEmitter.fire();
|
|
73
|
-
}
|
|
74
|
-
get visible() {
|
|
75
|
-
return this.elements.length > 0;
|
|
20
|
+
// src/services/panel-restore.ts
|
|
21
|
+
import { injectable } from "inversify";
|
|
22
|
+
var PanelRestore = Symbol("PanelRestore");
|
|
23
|
+
var PanelRestoreImpl = class {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.map = /* @__PURE__ */ new Map();
|
|
76
26
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.elements = [];
|
|
80
|
-
} else {
|
|
81
|
-
this.elements = this.elements.filter((e) => e.key !== key);
|
|
82
|
-
}
|
|
83
|
-
this.onUpdateEmitter.fire();
|
|
27
|
+
store(k, v) {
|
|
28
|
+
this.map.set(k, v);
|
|
84
29
|
}
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
this.onUpdateEmitter.dispose();
|
|
30
|
+
restore(k) {
|
|
31
|
+
return this.map.get(k);
|
|
88
32
|
}
|
|
89
33
|
};
|
|
34
|
+
PanelRestoreImpl = __decorateClass([
|
|
35
|
+
injectable()
|
|
36
|
+
], PanelRestoreImpl);
|
|
90
37
|
|
|
91
|
-
// src/services/panel-
|
|
92
|
-
var
|
|
38
|
+
// src/services/panel-factory.ts
|
|
39
|
+
var PanelEntityFactory = Symbol("PanelEntityFactory");
|
|
40
|
+
var PanelEntityFactoryConstant = Symbol("PanelEntityFactoryConstant");
|
|
41
|
+
var PanelEntityConfigConstant = Symbol("PanelEntityConfigConstant");
|
|
42
|
+
var PANEL_SIZE_DEFAULT = 400;
|
|
43
|
+
var PanelEntity = class {
|
|
93
44
|
constructor() {
|
|
94
|
-
this.
|
|
45
|
+
this.initialized = false;
|
|
46
|
+
/** 实例唯一标识 */
|
|
47
|
+
this.id = nanoid();
|
|
48
|
+
/** 渲染缓存 */
|
|
49
|
+
this.node = null;
|
|
95
50
|
}
|
|
96
|
-
|
|
97
|
-
this.config.
|
|
98
|
-
this.right = new FloatPanel(this.config.right);
|
|
99
|
-
this.bottom = new FloatPanel(this.config.bottom);
|
|
51
|
+
get area() {
|
|
52
|
+
return this.config.area;
|
|
100
53
|
}
|
|
101
|
-
|
|
102
|
-
this.
|
|
54
|
+
get key() {
|
|
55
|
+
return this.factory.key;
|
|
103
56
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
57
|
+
get renderer() {
|
|
58
|
+
if (!this.node) {
|
|
59
|
+
this.node = this.factory.render(this.config.props);
|
|
108
60
|
}
|
|
109
|
-
|
|
110
|
-
panel.open(factory, options);
|
|
61
|
+
return this.node;
|
|
111
62
|
}
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
63
|
+
init() {
|
|
64
|
+
if (this.initialized) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.initialized = true;
|
|
68
|
+
const cache = this.restore.restore(this.key);
|
|
69
|
+
this.store = createStore(() => ({
|
|
70
|
+
size: this.config.defaultSize || this.factory.defaultSize || PANEL_SIZE_DEFAULT,
|
|
71
|
+
...cache ?? {}
|
|
72
|
+
}));
|
|
118
73
|
}
|
|
119
74
|
dispose() {
|
|
120
|
-
this.
|
|
121
|
-
this.bottom.dispose();
|
|
75
|
+
this.restore.store(this.key, this.store.getState());
|
|
122
76
|
}
|
|
123
77
|
};
|
|
124
78
|
__decorateClass([
|
|
125
|
-
inject(
|
|
126
|
-
],
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
import { Layer, PluginContext } from "@flowgram.ai/core";
|
|
137
|
-
|
|
138
|
-
// src/components/panel-layer/float-panel.tsx
|
|
139
|
-
import { useEffect, useRef as useRef2, startTransition, useState as useState2, useCallback } from "react";
|
|
140
|
-
|
|
141
|
-
// src/hooks/use-panel-manager.ts
|
|
142
|
-
import { useService } from "@flowgram.ai/core";
|
|
143
|
-
var usePanelManager = () => useService(PanelManager);
|
|
144
|
-
|
|
145
|
-
// src/components/panel-layer/css.ts
|
|
146
|
-
var globalCSS = `
|
|
147
|
-
.gedit-flow-panel-layer * {
|
|
148
|
-
box-sizing: border-box;
|
|
149
|
-
}
|
|
150
|
-
`;
|
|
151
|
-
var panelLayer = {
|
|
152
|
-
pointerEvents: "none",
|
|
153
|
-
position: "absolute",
|
|
154
|
-
top: 0,
|
|
155
|
-
left: 0,
|
|
156
|
-
display: "flex",
|
|
157
|
-
columnGap: "4px",
|
|
158
|
-
width: "100%",
|
|
159
|
-
height: "100%",
|
|
160
|
-
padding: "4px",
|
|
161
|
-
boxSizing: "border-box",
|
|
162
|
-
overflow: "hidden"
|
|
163
|
-
};
|
|
164
|
-
var leftArea = {
|
|
165
|
-
width: "100%",
|
|
166
|
-
minWidth: 0,
|
|
167
|
-
flexGrow: 0,
|
|
168
|
-
flexShrink: 1,
|
|
169
|
-
display: "flex",
|
|
170
|
-
flexDirection: "column",
|
|
171
|
-
rowGap: "4px"
|
|
172
|
-
};
|
|
173
|
-
var rightArea = {
|
|
174
|
-
height: "100%",
|
|
175
|
-
flexGrow: 1,
|
|
176
|
-
flexShrink: 0,
|
|
177
|
-
minWidth: 0,
|
|
178
|
-
display: "flex",
|
|
179
|
-
columnGap: "4px"
|
|
180
|
-
};
|
|
181
|
-
var mainArea = {
|
|
182
|
-
position: "relative",
|
|
183
|
-
overflow: "hidden",
|
|
184
|
-
flexGrow: 0,
|
|
185
|
-
flexShrink: 1,
|
|
186
|
-
width: "100%",
|
|
187
|
-
height: "100%"
|
|
188
|
-
};
|
|
189
|
-
var bottomArea = {
|
|
190
|
-
flexGrow: 1,
|
|
191
|
-
flexShrink: 0,
|
|
192
|
-
width: "100%",
|
|
193
|
-
minHeight: 0
|
|
194
|
-
};
|
|
195
|
-
var floatPanelWrap = {
|
|
196
|
-
pointerEvents: "auto",
|
|
197
|
-
height: "100%",
|
|
198
|
-
width: "100%",
|
|
199
|
-
overflow: "auto"
|
|
200
|
-
};
|
|
79
|
+
inject(PanelRestore)
|
|
80
|
+
], PanelEntity.prototype, "restore", 2);
|
|
81
|
+
__decorateClass([
|
|
82
|
+
inject(PanelEntityFactoryConstant)
|
|
83
|
+
], PanelEntity.prototype, "factory", 2);
|
|
84
|
+
__decorateClass([
|
|
85
|
+
inject(PanelEntityConfigConstant)
|
|
86
|
+
], PanelEntity.prototype, "config", 2);
|
|
87
|
+
PanelEntity = __decorateClass([
|
|
88
|
+
injectable2()
|
|
89
|
+
], PanelEntity);
|
|
201
90
|
|
|
202
91
|
// src/components/resize-bar/index.tsx
|
|
203
92
|
import { useRef, useState } from "react";
|
|
204
93
|
import { jsx } from "react/jsx-runtime";
|
|
205
|
-
var ResizeBar = ({ onResize, size,
|
|
94
|
+
var ResizeBar = ({ onResize, size, direction }) => {
|
|
206
95
|
const currentPoint = useRef(null);
|
|
207
96
|
const [isDragging, setIsDragging] = useState(false);
|
|
208
97
|
const [isHovered, setIsHovered] = useState(false);
|
|
98
|
+
const isVertical = direction === "vertical";
|
|
209
99
|
return /* @__PURE__ */ jsx(
|
|
210
100
|
"div",
|
|
211
101
|
{
|
|
@@ -269,53 +159,342 @@ var ResizeBar = ({ onResize, size, isVertical }) => {
|
|
|
269
159
|
);
|
|
270
160
|
};
|
|
271
161
|
|
|
272
|
-
// src/
|
|
273
|
-
|
|
274
|
-
var
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
162
|
+
// src/services/panel-config.ts
|
|
163
|
+
var PanelManagerConfig = Symbol("PanelManagerConfig");
|
|
164
|
+
var defineConfig = (config) => {
|
|
165
|
+
const defaultConfig = {
|
|
166
|
+
right: {
|
|
167
|
+
max: 1
|
|
168
|
+
},
|
|
169
|
+
bottom: {
|
|
170
|
+
max: 1
|
|
171
|
+
},
|
|
172
|
+
dockedRight: {
|
|
173
|
+
max: 1
|
|
174
|
+
},
|
|
175
|
+
dockedBottom: {
|
|
176
|
+
max: 1
|
|
177
|
+
},
|
|
178
|
+
factories: [],
|
|
179
|
+
autoResize: true,
|
|
180
|
+
layerProps: {},
|
|
181
|
+
resizeBarRender: ResizeBar,
|
|
182
|
+
getPopupContainer: (ctx) => ctx.playground.node.parentNode
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
...defaultConfig,
|
|
186
|
+
...config
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/services/panel-manager.ts
|
|
191
|
+
import { injectable as injectable3, inject as inject2 } from "inversify";
|
|
192
|
+
import { Emitter } from "@flowgram.ai/utils";
|
|
193
|
+
var PanelManager = class {
|
|
194
|
+
constructor() {
|
|
195
|
+
this.panelRegistry = /* @__PURE__ */ new Map();
|
|
196
|
+
this.panels = /* @__PURE__ */ new Map();
|
|
197
|
+
this.onPanelsChangeEvent = new Emitter();
|
|
198
|
+
this.onPanelsChange = this.onPanelsChangeEvent.event;
|
|
199
|
+
}
|
|
200
|
+
init() {
|
|
201
|
+
this.config.factories.forEach((factory) => this.register(factory));
|
|
202
|
+
}
|
|
203
|
+
/** registry panel factory */
|
|
204
|
+
register(factory) {
|
|
205
|
+
this.panelRegistry.set(factory.key, factory);
|
|
206
|
+
}
|
|
207
|
+
/** open panel */
|
|
208
|
+
open(key, area = "right", options) {
|
|
209
|
+
const factory = this.panelRegistry.get(key);
|
|
210
|
+
if (!factory) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const sameKeyPanels = this.getPanels(area).filter((p) => p.key === key);
|
|
214
|
+
if (!factory.allowDuplicates && sameKeyPanels.length) {
|
|
215
|
+
sameKeyPanels.forEach((p) => this.remove(p.id));
|
|
216
|
+
}
|
|
217
|
+
const panel = this.createPanel({
|
|
218
|
+
factory,
|
|
219
|
+
config: {
|
|
220
|
+
area,
|
|
221
|
+
...options
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
this.panels.set(panel.id, panel);
|
|
225
|
+
this.trim(area);
|
|
226
|
+
this.onPanelsChangeEvent.fire();
|
|
227
|
+
console.log("jxj", this.panels);
|
|
228
|
+
}
|
|
229
|
+
/** close panel */
|
|
230
|
+
close(key) {
|
|
231
|
+
const panels = this.getPanels();
|
|
232
|
+
const closedPanels = key ? panels.filter((p) => p.key === key) : panels;
|
|
233
|
+
closedPanels.forEach((p) => this.remove(p.id));
|
|
234
|
+
this.onPanelsChangeEvent.fire();
|
|
235
|
+
}
|
|
236
|
+
trim(area) {
|
|
237
|
+
const panels = this.getPanels(area);
|
|
238
|
+
const areaConfig = this.getAreaConfig(area);
|
|
239
|
+
console.log("jxj", areaConfig.max, panels.length);
|
|
240
|
+
while (panels.length > areaConfig.max) {
|
|
241
|
+
const removed = panels.shift();
|
|
242
|
+
if (removed) {
|
|
243
|
+
this.remove(removed.id);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
remove(id) {
|
|
248
|
+
const panel = this.panels.get(id);
|
|
249
|
+
if (panel) {
|
|
250
|
+
panel.dispose();
|
|
251
|
+
this.panels.delete(id);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
getPanels(area) {
|
|
255
|
+
const panels = [];
|
|
256
|
+
this.panels.forEach((panel) => {
|
|
257
|
+
if (!area || panel.area === area) {
|
|
258
|
+
panels.push(panel);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return panels;
|
|
262
|
+
}
|
|
263
|
+
getAreaConfig(area) {
|
|
264
|
+
switch (area) {
|
|
265
|
+
case "docked-bottom":
|
|
266
|
+
return this.config.dockedBottom;
|
|
267
|
+
case "docked-right":
|
|
268
|
+
return this.config.dockedRight;
|
|
269
|
+
case "bottom":
|
|
270
|
+
return this.config.bottom;
|
|
271
|
+
case "right":
|
|
272
|
+
default:
|
|
273
|
+
return this.config.right;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
dispose() {
|
|
277
|
+
this.onPanelsChangeEvent.dispose();
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
__decorateClass([
|
|
281
|
+
inject2(PanelManagerConfig)
|
|
282
|
+
], PanelManager.prototype, "config", 2);
|
|
283
|
+
__decorateClass([
|
|
284
|
+
inject2(PanelEntityFactory)
|
|
285
|
+
], PanelManager.prototype, "createPanel", 2);
|
|
286
|
+
PanelManager = __decorateClass([
|
|
287
|
+
injectable3()
|
|
288
|
+
], PanelManager);
|
|
289
|
+
|
|
290
|
+
// src/services/panel-layer.ts
|
|
291
|
+
import ReactDOM from "react-dom";
|
|
292
|
+
import { createElement } from "react";
|
|
293
|
+
import { injectable as injectable4, inject as inject3 } from "inversify";
|
|
294
|
+
import { domUtils, Disposable } from "@flowgram.ai/utils";
|
|
295
|
+
import { Layer, PluginContext } from "@flowgram.ai/core";
|
|
296
|
+
|
|
297
|
+
// src/components/panel-layer/panel-layer.tsx
|
|
298
|
+
import clsx2 from "clsx";
|
|
299
|
+
|
|
300
|
+
// src/hooks/use-global-css.ts
|
|
301
|
+
import { useEffect } from "react";
|
|
302
|
+
var useGlobalCSS = ({ cssText, id, cleanup }) => {
|
|
280
303
|
useEffect(() => {
|
|
281
|
-
|
|
304
|
+
if (typeof document === "undefined") return;
|
|
305
|
+
if (document.getElementById(id)) return;
|
|
306
|
+
const style = document.createElement("style");
|
|
307
|
+
style.id = id;
|
|
308
|
+
style.textContent = cssText;
|
|
309
|
+
document.head.appendChild(style);
|
|
310
|
+
return () => {
|
|
311
|
+
const existing = document.getElementById(id);
|
|
312
|
+
if (existing && cleanup) existing.remove();
|
|
313
|
+
};
|
|
314
|
+
}, [id]);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// src/components/panel-layer/panel.tsx
|
|
318
|
+
import { useEffect as useEffect2, startTransition, useState as useState2, useRef as useRef2 } from "react";
|
|
319
|
+
import { useStoreWithEqualityFn } from "zustand/traditional";
|
|
320
|
+
import { shallow } from "zustand/shallow";
|
|
321
|
+
import clsx from "clsx";
|
|
322
|
+
|
|
323
|
+
// src/hooks/use-panel-manager.ts
|
|
324
|
+
import { useService } from "@flowgram.ai/core";
|
|
325
|
+
var usePanelManager = () => useService(PanelManager);
|
|
326
|
+
|
|
327
|
+
// src/contexts.ts
|
|
328
|
+
import { createContext } from "react";
|
|
329
|
+
var PanelContext = createContext({});
|
|
330
|
+
|
|
331
|
+
// src/components/panel-layer/panel.tsx
|
|
332
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
333
|
+
var PanelItem = ({ panel }) => {
|
|
334
|
+
const panelManager = usePanelManager();
|
|
335
|
+
const ref = useRef2(null);
|
|
336
|
+
const resize = panel.factory.resize !== void 0 ? panel.factory.resize : panelManager.config.autoResize;
|
|
337
|
+
const isHorizontal = ["right", "docked-right"].includes(panel.area);
|
|
338
|
+
const size = useStoreWithEqualityFn(panel.store, (s) => s.size, shallow);
|
|
339
|
+
const sizeStyle = isHorizontal ? { width: size } : { height: size };
|
|
340
|
+
const handleResize = (next) => {
|
|
341
|
+
let nextSize = next;
|
|
342
|
+
if (typeof panel.factory.maxSize === "number" && nextSize > panel.factory.maxSize) {
|
|
343
|
+
nextSize = panel.factory.maxSize;
|
|
344
|
+
} else if (typeof panel.factory.minSize === "number" && nextSize < panel.factory.minSize) {
|
|
345
|
+
nextSize = panel.factory.minSize;
|
|
346
|
+
}
|
|
347
|
+
panel.store.setState({ size: nextSize });
|
|
348
|
+
};
|
|
349
|
+
useEffect2(() => {
|
|
350
|
+
if (ref.current) {
|
|
351
|
+
const { width, height } = ref.current.getBoundingClientRect();
|
|
352
|
+
const realSize = isHorizontal ? width : height;
|
|
353
|
+
panel.store.setState({ size: realSize });
|
|
354
|
+
}
|
|
355
|
+
}, []);
|
|
356
|
+
return /* @__PURE__ */ jsxs(
|
|
357
|
+
"div",
|
|
358
|
+
{
|
|
359
|
+
className: clsx(
|
|
360
|
+
"gedit-flow-panel-wrap",
|
|
361
|
+
isHorizontal ? "panel-horizontal" : "panel-vertical"
|
|
362
|
+
),
|
|
363
|
+
ref,
|
|
364
|
+
style: { ...panel.factory.style, ...panel.config.style, ...sizeStyle },
|
|
365
|
+
children: [
|
|
366
|
+
resize && panelManager.config.resizeBarRender({
|
|
367
|
+
size,
|
|
368
|
+
direction: isHorizontal ? "vertical" : "horizontal",
|
|
369
|
+
onResize: handleResize
|
|
370
|
+
}),
|
|
371
|
+
panel.renderer
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
panel.id
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
var PanelArea = ({ area }) => {
|
|
378
|
+
const panelManager = usePanelManager();
|
|
379
|
+
const [panels, setPanels] = useState2(panelManager.getPanels(area));
|
|
380
|
+
useEffect2(() => {
|
|
381
|
+
const dispose = panelManager.onPanelsChange(() => {
|
|
282
382
|
startTransition(() => {
|
|
283
|
-
|
|
284
|
-
setVersion((v) => v + 1);
|
|
383
|
+
setPanels(panelManager.getPanels(area));
|
|
285
384
|
});
|
|
286
385
|
});
|
|
287
386
|
return () => dispose.dispose();
|
|
288
|
-
}, [
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
387
|
+
}, []);
|
|
388
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: panels.map((panel) => /* @__PURE__ */ jsx2(PanelContext.Provider, { value: panel, children: /* @__PURE__ */ jsx2(PanelItem, { panel }) }, panel.id)) });
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// src/components/panel-layer/css.ts
|
|
392
|
+
var globalCSS = `
|
|
393
|
+
.gedit-flow-panel-layer-wrap * {
|
|
394
|
+
box-sizing: border-box;
|
|
395
|
+
}
|
|
396
|
+
.gedit-flow-panel-layer-wrap {
|
|
397
|
+
position: absolute;
|
|
398
|
+
top: 0;
|
|
399
|
+
left: 0;
|
|
400
|
+
display: flex;
|
|
401
|
+
width: 100%;
|
|
402
|
+
height: 100%;
|
|
403
|
+
overflow: hidden;
|
|
404
|
+
}
|
|
405
|
+
.gedit-flow-panel-layer-wrap-docked {
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
.gedit-flow-panel-layer-wrap-floating {
|
|
409
|
+
column-gap: 4px;
|
|
410
|
+
padding: 4px;
|
|
411
|
+
pointer-events: none;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.gedit-flow-panel-left-area {
|
|
415
|
+
width: 100%;
|
|
416
|
+
min-width: 0;
|
|
417
|
+
flex-grow: 0;
|
|
418
|
+
flex-shrink: 1;
|
|
419
|
+
display: flex;
|
|
420
|
+
flex-direction: column;
|
|
421
|
+
}
|
|
422
|
+
.gedit-flow-panel-layer-wrap-floating .gedit-flow-panel-left-area {
|
|
423
|
+
row-gap: 4px;
|
|
424
|
+
}
|
|
425
|
+
.gedit-flow-panel-right-area {
|
|
426
|
+
height: 100%;
|
|
427
|
+
flex-grow: 1;
|
|
428
|
+
flex-shrink: 0;
|
|
429
|
+
min-width: 0;
|
|
430
|
+
display: flex;
|
|
431
|
+
column-gap: 4px;
|
|
432
|
+
max-width: 100%;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.gedit-flow-panel-main-area {
|
|
436
|
+
position: relative;
|
|
437
|
+
overflow: hidden;
|
|
438
|
+
flex-grow: 0;
|
|
439
|
+
flex-shrink: 1;
|
|
440
|
+
width: 100%;
|
|
441
|
+
height: 100%;
|
|
442
|
+
}
|
|
443
|
+
.gedit-flow-panel-bottom-area {
|
|
444
|
+
flex-grow: 1;
|
|
445
|
+
flex-shrink: 0;
|
|
446
|
+
width: 100%;
|
|
447
|
+
min-height: 0;
|
|
448
|
+
}
|
|
449
|
+
.gedit-flow-panel-wrap {
|
|
450
|
+
pointer-events: auto;
|
|
451
|
+
overflow: auto;
|
|
452
|
+
position: relative;
|
|
453
|
+
}
|
|
454
|
+
.gedit-flow-panel-wrap.panel-horizontal {
|
|
455
|
+
height: 100%;
|
|
456
|
+
}
|
|
457
|
+
.gedit-flow-panel-wrap.panel-vertical {
|
|
458
|
+
width: 100%;
|
|
459
|
+
}
|
|
460
|
+
`;
|
|
461
|
+
|
|
462
|
+
// src/components/panel-layer/panel-layer.tsx
|
|
463
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
464
|
+
var PanelLayer = ({
|
|
465
|
+
mode = "floating",
|
|
466
|
+
className,
|
|
467
|
+
style,
|
|
468
|
+
children
|
|
469
|
+
}) => {
|
|
470
|
+
useGlobalCSS({
|
|
471
|
+
cssText: globalCSS,
|
|
472
|
+
id: "flow-panel-layer-css"
|
|
473
|
+
});
|
|
474
|
+
return /* @__PURE__ */ jsxs2(
|
|
293
475
|
"div",
|
|
294
476
|
{
|
|
295
|
-
className:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
477
|
+
className: clsx2(
|
|
478
|
+
"gedit-flow-panel-layer-wrap",
|
|
479
|
+
mode === "docked" && "gedit-flow-panel-layer-wrap-docked",
|
|
480
|
+
mode === "floating" && "gedit-flow-panel-layer-wrap-floating",
|
|
481
|
+
className
|
|
482
|
+
),
|
|
483
|
+
style,
|
|
301
484
|
children: [
|
|
302
|
-
|
|
303
|
-
|
|
485
|
+
/* @__PURE__ */ jsxs2("div", { className: "gedit-flow-panel-left-area", children: [
|
|
486
|
+
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-main-area", children }),
|
|
487
|
+
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-bottom-area", children: /* @__PURE__ */ jsx3(PanelArea, { area: mode === "docked" ? "docked-bottom" : "bottom" }) })
|
|
488
|
+
] }),
|
|
489
|
+
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-right-area", children: /* @__PURE__ */ jsx3(PanelArea, { area: mode === "docked" ? "docked-right" : "right" }) })
|
|
304
490
|
]
|
|
305
491
|
}
|
|
306
492
|
);
|
|
307
493
|
};
|
|
308
494
|
|
|
309
|
-
// src/components/panel-layer/panel-layer.tsx
|
|
310
|
-
import { jsx as
|
|
311
|
-
var
|
|
312
|
-
/* @__PURE__ */ jsx3("style", { dangerouslySetInnerHTML: { __html: globalCSS } }),
|
|
313
|
-
/* @__PURE__ */ jsxs2("div", { className: "gedit-flow-panel-left-area", style: leftArea, children: [
|
|
314
|
-
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-main-area", style: mainArea, children }),
|
|
315
|
-
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-bottom-area", style: bottomArea, children: /* @__PURE__ */ jsx3(FloatPanel2, { area: "bottom" }) })
|
|
316
|
-
] }),
|
|
317
|
-
/* @__PURE__ */ jsx3("div", { className: "gedit-flow-panel-right-area", style: rightArea, children: /* @__PURE__ */ jsx3(FloatPanel2, { area: "right" }) })
|
|
318
|
-
] });
|
|
495
|
+
// src/components/panel-layer/docked-panel-layer.tsx
|
|
496
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
497
|
+
var DockedPanelLayer = (props) => /* @__PURE__ */ jsx4(PanelLayer, { mode: "docked", ...props });
|
|
319
498
|
|
|
320
499
|
// src/services/panel-layer.ts
|
|
321
500
|
var PanelLayer2 = class extends Layer {
|
|
@@ -344,37 +523,59 @@ var PanelLayer2 = class extends Layer {
|
|
|
344
523
|
}
|
|
345
524
|
render() {
|
|
346
525
|
if (!this.layout) {
|
|
347
|
-
|
|
526
|
+
const { children, ...layoutProps } = this.panelConfig.layerProps;
|
|
527
|
+
this.layout = createElement(PanelLayer, layoutProps, children);
|
|
348
528
|
}
|
|
349
529
|
return ReactDOM.createPortal(this.layout, this.panelRoot);
|
|
350
530
|
}
|
|
351
531
|
};
|
|
352
532
|
__decorateClass([
|
|
353
|
-
|
|
533
|
+
inject3(PanelManagerConfig)
|
|
354
534
|
], PanelLayer2.prototype, "panelConfig", 2);
|
|
355
535
|
__decorateClass([
|
|
356
|
-
|
|
536
|
+
inject3(PluginContext)
|
|
357
537
|
], PanelLayer2.prototype, "pluginContext", 2);
|
|
358
538
|
PanelLayer2 = __decorateClass([
|
|
359
|
-
|
|
539
|
+
injectable4()
|
|
360
540
|
], PanelLayer2);
|
|
361
541
|
|
|
362
542
|
// src/create-panel-manager-plugin.ts
|
|
363
543
|
var createPanelManagerPlugin = definePluginCreator({
|
|
364
544
|
onBind: ({ bind }, opt) => {
|
|
365
545
|
bind(PanelManager).to(PanelManager).inSingletonScope();
|
|
546
|
+
bind(PanelRestore).to(PanelRestoreImpl).inSingletonScope();
|
|
366
547
|
bind(PanelManagerConfig).toConstantValue(defineConfig(opt));
|
|
548
|
+
bind(PanelEntityFactory).toFactory(
|
|
549
|
+
(context) => ({
|
|
550
|
+
factory,
|
|
551
|
+
config
|
|
552
|
+
}) => {
|
|
553
|
+
const container = context.container.createChild();
|
|
554
|
+
container.bind(PanelEntityFactoryConstant).toConstantValue(factory);
|
|
555
|
+
container.bind(PanelEntityConfigConstant).toConstantValue(config);
|
|
556
|
+
const panel = container.resolve(PanelEntity);
|
|
557
|
+
panel.init();
|
|
558
|
+
return panel;
|
|
559
|
+
}
|
|
560
|
+
);
|
|
367
561
|
},
|
|
368
|
-
onInit(ctx
|
|
562
|
+
onInit(ctx) {
|
|
369
563
|
ctx.playground.registerLayer(PanelLayer2);
|
|
370
564
|
const panelManager = ctx.container.get(PanelManager);
|
|
371
565
|
panelManager.init();
|
|
372
566
|
}
|
|
373
567
|
});
|
|
568
|
+
|
|
569
|
+
// src/hooks/use-panel.ts
|
|
570
|
+
import { useContext } from "react";
|
|
571
|
+
var usePanel = () => useContext(PanelContext);
|
|
374
572
|
export {
|
|
573
|
+
DockedPanelLayer,
|
|
375
574
|
PanelManager,
|
|
575
|
+
PanelRestore,
|
|
376
576
|
ResizeBar,
|
|
377
577
|
createPanelManagerPlugin,
|
|
578
|
+
usePanel,
|
|
378
579
|
usePanelManager
|
|
379
580
|
};
|
|
380
581
|
//# sourceMappingURL=index.js.map
|