@flowgram.ai/panel-manager-plugin 0.1.0-alpha.23 → 0.1.0-alpha.25
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 +16 -12
- package/.rush/temp/shrinkwrap-deps.json +6 -2
- package/dist/esm/index.js +307 -134
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +78 -32
- package/dist/index.d.ts +78 -32
- package/dist/index.js +321 -146
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
- package/rush-logs/panel-manager-plugin.build.log +9 -9
- package/src/components/panel-layer/css.ts +13 -14
- package/src/components/panel-layer/panel-layer.tsx +3 -3
- package/src/components/panel-layer/panel.tsx +107 -0
- package/src/contexts.ts +10 -0
- package/src/create-panel-manager-plugin.ts +31 -1
- package/src/hooks/use-panel.ts +19 -0
- package/src/index.ts +2 -1
- package/src/services/index.ts +1 -0
- package/src/services/panel-config.ts +1 -0
- package/src/services/panel-factory.ts +123 -0
- package/src/services/panel-manager.ts +69 -31
- package/src/services/panel-restore.ts +25 -0
- package/src/types.ts +13 -0
- package/src/utils.ts +22 -0
- package/src/components/panel-layer/float-panel.tsx +0 -59
- package/src/services/float-panel.ts +0 -75
package/dist/index.js
CHANGED
|
@@ -40,14 +40,39 @@ var index_exports = {};
|
|
|
40
40
|
__export(index_exports, {
|
|
41
41
|
DockedPanelLayer: () => DockedPanelLayer,
|
|
42
42
|
PanelManager: () => PanelManager,
|
|
43
|
+
PanelRestore: () => PanelRestore,
|
|
43
44
|
ResizeBar: () => ResizeBar,
|
|
44
45
|
createPanelManagerPlugin: () => createPanelManagerPlugin,
|
|
46
|
+
usePanel: () => usePanel,
|
|
45
47
|
usePanelManager: () => usePanelManager
|
|
46
48
|
});
|
|
47
49
|
module.exports = __toCommonJS(index_exports);
|
|
48
50
|
|
|
49
51
|
// src/create-panel-manager-plugin.ts
|
|
50
|
-
var
|
|
52
|
+
var import_core3 = require("@flowgram.ai/core");
|
|
53
|
+
|
|
54
|
+
// src/services/panel-factory.ts
|
|
55
|
+
var import_vanilla = require("zustand/vanilla");
|
|
56
|
+
var import_nanoid = require("nanoid");
|
|
57
|
+
var import_inversify2 = require("inversify");
|
|
58
|
+
|
|
59
|
+
// src/services/panel-restore.ts
|
|
60
|
+
var import_inversify = require("inversify");
|
|
61
|
+
var PanelRestore = Symbol("PanelRestore");
|
|
62
|
+
var PanelRestoreImpl = class {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.map = /* @__PURE__ */ new Map();
|
|
65
|
+
}
|
|
66
|
+
store(k, v) {
|
|
67
|
+
this.map.set(k, v);
|
|
68
|
+
}
|
|
69
|
+
restore(k) {
|
|
70
|
+
return this.map.get(k);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
PanelRestoreImpl = __decorateClass([
|
|
74
|
+
(0, import_inversify.injectable)()
|
|
75
|
+
], PanelRestoreImpl);
|
|
51
76
|
|
|
52
77
|
// src/components/resize-bar/index.tsx
|
|
53
78
|
var import_react = require("react");
|
|
@@ -148,131 +173,214 @@ var defineConfig = (config) => {
|
|
|
148
173
|
};
|
|
149
174
|
};
|
|
150
175
|
|
|
151
|
-
// src/
|
|
152
|
-
var
|
|
153
|
-
|
|
176
|
+
// src/utils.ts
|
|
177
|
+
var merge = (...objs) => {
|
|
178
|
+
const result = {};
|
|
179
|
+
for (const obj of objs) {
|
|
180
|
+
if (!obj || typeof obj !== "object") continue;
|
|
181
|
+
for (const key of Object.keys(obj)) {
|
|
182
|
+
const value = obj[key];
|
|
183
|
+
if (result[key] === void 0) {
|
|
184
|
+
result[key] = value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
};
|
|
154
190
|
|
|
155
|
-
// src/services/
|
|
156
|
-
var
|
|
191
|
+
// src/services/panel-factory.ts
|
|
192
|
+
var PanelEntityFactory = Symbol("PanelEntityFactory");
|
|
193
|
+
var PanelEntityFactoryConstant = Symbol("PanelEntityFactoryConstant");
|
|
194
|
+
var PanelEntityConfigConstant = Symbol("PanelEntityConfigConstant");
|
|
157
195
|
var PANEL_SIZE_DEFAULT = 400;
|
|
158
|
-
var
|
|
159
|
-
constructor(
|
|
160
|
-
this.
|
|
161
|
-
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
this.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (!this.sizeMap.has(factory.key)) {
|
|
179
|
-
this.sizeMap.set(factory.key, factory.defaultSize || PANEL_SIZE_DEFAULT);
|
|
196
|
+
var PanelEntity = class {
|
|
197
|
+
constructor() {
|
|
198
|
+
this.initialized = false;
|
|
199
|
+
/** 实例唯一标识 */
|
|
200
|
+
this.id = (0, import_nanoid.nanoid)();
|
|
201
|
+
/** 渲染缓存 */
|
|
202
|
+
this.node = null;
|
|
203
|
+
}
|
|
204
|
+
get area() {
|
|
205
|
+
return this.config.area;
|
|
206
|
+
}
|
|
207
|
+
get mode() {
|
|
208
|
+
return this.config.area.startsWith("docked") ? "docked" : "floating";
|
|
209
|
+
}
|
|
210
|
+
get key() {
|
|
211
|
+
return this.factory.key;
|
|
212
|
+
}
|
|
213
|
+
get renderer() {
|
|
214
|
+
if (!this.node) {
|
|
215
|
+
this.node = this.factory.render(this.config.props);
|
|
180
216
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
217
|
+
return this.node;
|
|
218
|
+
}
|
|
219
|
+
get fullscreen() {
|
|
220
|
+
return this.store.getState().fullscreen;
|
|
221
|
+
}
|
|
222
|
+
set fullscreen(next) {
|
|
223
|
+
this.store.setState({ fullscreen: next });
|
|
224
|
+
}
|
|
225
|
+
get resizable() {
|
|
226
|
+
if (this.fullscreen) {
|
|
227
|
+
return false;
|
|
188
228
|
}
|
|
189
|
-
this.
|
|
229
|
+
return this.factory.resize !== void 0 ? this.factory.resize : this.globalConfig.autoResize;
|
|
190
230
|
}
|
|
191
|
-
get
|
|
192
|
-
return
|
|
231
|
+
get layer() {
|
|
232
|
+
return document.querySelector(
|
|
233
|
+
this.mode ? ".gedit-flow-panel-layer-wrap-docked" : ".gedit-flow-panel-layer-wrap-floating"
|
|
234
|
+
);
|
|
193
235
|
}
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
} else {
|
|
198
|
-
this.elements = this.elements.filter((e) => e.key !== key);
|
|
236
|
+
init() {
|
|
237
|
+
if (this.initialized) {
|
|
238
|
+
return;
|
|
199
239
|
}
|
|
200
|
-
this.
|
|
240
|
+
this.initialized = true;
|
|
241
|
+
const cache = this.restore.restore(this.key);
|
|
242
|
+
const initialState = merge(
|
|
243
|
+
{
|
|
244
|
+
size: this.config.defaultSize,
|
|
245
|
+
fullscreen: this.config.fullscreen
|
|
246
|
+
},
|
|
247
|
+
cache ? cache : {},
|
|
248
|
+
{
|
|
249
|
+
size: this.factory.defaultSize || PANEL_SIZE_DEFAULT,
|
|
250
|
+
fullscreen: this.factory.fullscreen || false
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
this.store = (0, import_vanilla.createStore)(() => initialState);
|
|
254
|
+
}
|
|
255
|
+
mergeState() {
|
|
201
256
|
}
|
|
202
257
|
dispose() {
|
|
203
|
-
this.
|
|
204
|
-
this.onUpdateEmitter.dispose();
|
|
258
|
+
this.restore.store(this.key, this.store.getState());
|
|
205
259
|
}
|
|
206
260
|
};
|
|
261
|
+
__decorateClass([
|
|
262
|
+
(0, import_inversify2.inject)(PanelRestore)
|
|
263
|
+
], PanelEntity.prototype, "restore", 2);
|
|
264
|
+
__decorateClass([
|
|
265
|
+
(0, import_inversify2.inject)(PanelEntityFactoryConstant)
|
|
266
|
+
], PanelEntity.prototype, "factory", 2);
|
|
267
|
+
__decorateClass([
|
|
268
|
+
(0, import_inversify2.inject)(PanelEntityConfigConstant)
|
|
269
|
+
], PanelEntity.prototype, "config", 2);
|
|
270
|
+
__decorateClass([
|
|
271
|
+
(0, import_inversify2.inject)(PanelManagerConfig)
|
|
272
|
+
], PanelEntity.prototype, "globalConfig", 2);
|
|
273
|
+
PanelEntity = __decorateClass([
|
|
274
|
+
(0, import_inversify2.injectable)()
|
|
275
|
+
], PanelEntity);
|
|
207
276
|
|
|
208
277
|
// src/services/panel-manager.ts
|
|
278
|
+
var import_inversify3 = require("inversify");
|
|
279
|
+
var import_utils2 = require("@flowgram.ai/utils");
|
|
209
280
|
var PanelManager = class {
|
|
210
281
|
constructor() {
|
|
211
282
|
this.panelRegistry = /* @__PURE__ */ new Map();
|
|
283
|
+
this.panels = /* @__PURE__ */ new Map();
|
|
284
|
+
this.onPanelsChangeEvent = new import_utils2.Emitter();
|
|
285
|
+
this.onPanelsChange = this.onPanelsChangeEvent.event;
|
|
212
286
|
}
|
|
213
287
|
init() {
|
|
214
288
|
this.config.factories.forEach((factory) => this.register(factory));
|
|
215
|
-
this.right = new FloatPanel(this.config.right);
|
|
216
|
-
this.bottom = new FloatPanel(this.config.bottom);
|
|
217
|
-
this.dockedRight = new FloatPanel(this.config.dockedRight);
|
|
218
|
-
this.dockedBottom = new FloatPanel(this.config.dockedBottom);
|
|
219
289
|
}
|
|
290
|
+
/** registry panel factory */
|
|
220
291
|
register(factory) {
|
|
221
292
|
this.panelRegistry.set(factory.key, factory);
|
|
222
293
|
}
|
|
294
|
+
/** open panel */
|
|
223
295
|
open(key, area = "right", options) {
|
|
224
296
|
const factory = this.panelRegistry.get(key);
|
|
225
297
|
if (!factory) {
|
|
226
298
|
return;
|
|
227
299
|
}
|
|
228
|
-
const
|
|
229
|
-
|
|
300
|
+
const sameKeyPanels = this.getPanels(area).filter((p) => p.key === key);
|
|
301
|
+
if (!factory.allowDuplicates && sameKeyPanels.length) {
|
|
302
|
+
sameKeyPanels.forEach((p) => this.remove(p.id));
|
|
303
|
+
}
|
|
304
|
+
const panel = this.createPanel({
|
|
305
|
+
factory,
|
|
306
|
+
config: {
|
|
307
|
+
area,
|
|
308
|
+
...options
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
this.panels.set(panel.id, panel);
|
|
312
|
+
this.trim(area);
|
|
313
|
+
this.onPanelsChangeEvent.fire();
|
|
230
314
|
}
|
|
315
|
+
/** close panel */
|
|
231
316
|
close(key) {
|
|
232
|
-
this.
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
317
|
+
const panels = this.getPanels();
|
|
318
|
+
const closedPanels = key ? panels.filter((p) => p.key === key) : panels;
|
|
319
|
+
closedPanels.forEach((p) => this.remove(p.id));
|
|
320
|
+
this.onPanelsChangeEvent.fire();
|
|
236
321
|
}
|
|
237
|
-
|
|
322
|
+
trim(area) {
|
|
323
|
+
const panels = this.getPanels(area);
|
|
324
|
+
const areaConfig = this.getAreaConfig(area);
|
|
325
|
+
while (panels.length > areaConfig.max) {
|
|
326
|
+
const removed = panels.shift();
|
|
327
|
+
if (removed) {
|
|
328
|
+
this.remove(removed.id);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
remove(id) {
|
|
333
|
+
const panel = this.panels.get(id);
|
|
334
|
+
if (panel) {
|
|
335
|
+
panel.dispose();
|
|
336
|
+
this.panels.delete(id);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
getPanels(area) {
|
|
340
|
+
const panels = [];
|
|
341
|
+
this.panels.forEach((panel) => {
|
|
342
|
+
if (!area || panel.area === area) {
|
|
343
|
+
panels.push(panel);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return panels;
|
|
347
|
+
}
|
|
348
|
+
getAreaConfig(area) {
|
|
238
349
|
switch (area) {
|
|
239
350
|
case "docked-bottom":
|
|
240
|
-
return this.dockedBottom;
|
|
351
|
+
return this.config.dockedBottom;
|
|
241
352
|
case "docked-right":
|
|
242
|
-
return this.dockedRight;
|
|
353
|
+
return this.config.dockedRight;
|
|
243
354
|
case "bottom":
|
|
244
|
-
return this.bottom;
|
|
355
|
+
return this.config.bottom;
|
|
245
356
|
case "right":
|
|
246
357
|
default:
|
|
247
|
-
return this.right;
|
|
358
|
+
return this.config.right;
|
|
248
359
|
}
|
|
249
360
|
}
|
|
250
361
|
dispose() {
|
|
251
|
-
this.
|
|
252
|
-
this.bottom.dispose();
|
|
253
|
-
this.dockedBottom.dispose();
|
|
254
|
-
this.dockedRight.dispose();
|
|
362
|
+
this.onPanelsChangeEvent.dispose();
|
|
255
363
|
}
|
|
256
364
|
};
|
|
257
365
|
__decorateClass([
|
|
258
|
-
(0,
|
|
259
|
-
], PanelManager.prototype, "playground", 2);
|
|
260
|
-
__decorateClass([
|
|
261
|
-
(0, import_inversify.inject)(PanelManagerConfig)
|
|
366
|
+
(0, import_inversify3.inject)(PanelManagerConfig)
|
|
262
367
|
], PanelManager.prototype, "config", 2);
|
|
368
|
+
__decorateClass([
|
|
369
|
+
(0, import_inversify3.inject)(PanelEntityFactory)
|
|
370
|
+
], PanelManager.prototype, "createPanel", 2);
|
|
263
371
|
PanelManager = __decorateClass([
|
|
264
|
-
(0,
|
|
372
|
+
(0, import_inversify3.injectable)()
|
|
265
373
|
], PanelManager);
|
|
266
374
|
|
|
267
375
|
// src/services/panel-layer.ts
|
|
268
376
|
var import_react_dom = __toESM(require("react-dom"));
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
var
|
|
272
|
-
var
|
|
377
|
+
var import_react6 = require("react");
|
|
378
|
+
var import_inversify4 = require("inversify");
|
|
379
|
+
var import_utils3 = require("@flowgram.ai/utils");
|
|
380
|
+
var import_core2 = require("@flowgram.ai/core");
|
|
273
381
|
|
|
274
382
|
// src/components/panel-layer/panel-layer.tsx
|
|
275
|
-
var
|
|
383
|
+
var import_clsx2 = __toESM(require("clsx"));
|
|
276
384
|
|
|
277
385
|
// src/hooks/use-global-css.ts
|
|
278
386
|
var import_react2 = require("react");
|
|
@@ -291,12 +399,105 @@ var useGlobalCSS = ({ cssText, id, cleanup }) => {
|
|
|
291
399
|
}, [id]);
|
|
292
400
|
};
|
|
293
401
|
|
|
294
|
-
// src/components/panel-layer/
|
|
295
|
-
var
|
|
402
|
+
// src/components/panel-layer/panel.tsx
|
|
403
|
+
var import_react5 = require("react");
|
|
404
|
+
var import_clsx = require("clsx");
|
|
296
405
|
|
|
297
406
|
// src/hooks/use-panel-manager.ts
|
|
298
|
-
var
|
|
299
|
-
var usePanelManager = () => (0,
|
|
407
|
+
var import_core = require("@flowgram.ai/core");
|
|
408
|
+
var usePanelManager = () => (0, import_core.useService)(PanelManager);
|
|
409
|
+
|
|
410
|
+
// src/hooks/use-panel.ts
|
|
411
|
+
var import_react4 = require("react");
|
|
412
|
+
var import_traditional = require("zustand/traditional");
|
|
413
|
+
var import_shallow = require("zustand/shallow");
|
|
414
|
+
|
|
415
|
+
// src/contexts.ts
|
|
416
|
+
var import_react3 = require("react");
|
|
417
|
+
var PanelContext = (0, import_react3.createContext)({});
|
|
418
|
+
|
|
419
|
+
// src/hooks/use-panel.ts
|
|
420
|
+
var usePanel = () => (0, import_react4.useContext)(PanelContext);
|
|
421
|
+
var usePanelStore = (selector) => {
|
|
422
|
+
const panel = usePanel();
|
|
423
|
+
return (0, import_traditional.useStoreWithEqualityFn)(panel.store, selector, import_shallow.shallow);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// src/components/panel-layer/panel.tsx
|
|
427
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
428
|
+
var PanelItem = ({ panel }) => {
|
|
429
|
+
const panelManager = usePanelManager();
|
|
430
|
+
const ref = (0, import_react5.useRef)(null);
|
|
431
|
+
const isHorizontal = ["right", "docked-right"].includes(panel.area);
|
|
432
|
+
const { size, fullscreen } = usePanelStore((s) => ({ size: s.size, fullscreen: s.fullscreen }));
|
|
433
|
+
const [layerSize, setLayerSize] = (0, import_react5.useState)(size);
|
|
434
|
+
const currentSize = fullscreen ? layerSize : size;
|
|
435
|
+
const sizeStyle = isHorizontal ? { width: currentSize } : { height: currentSize };
|
|
436
|
+
const handleResize = (next) => {
|
|
437
|
+
let nextSize = next;
|
|
438
|
+
if (typeof panel.factory.maxSize === "number" && nextSize > panel.factory.maxSize) {
|
|
439
|
+
nextSize = panel.factory.maxSize;
|
|
440
|
+
} else if (typeof panel.factory.minSize === "number" && nextSize < panel.factory.minSize) {
|
|
441
|
+
nextSize = panel.factory.minSize;
|
|
442
|
+
}
|
|
443
|
+
panel.store.setState({ size: nextSize });
|
|
444
|
+
};
|
|
445
|
+
(0, import_react5.useEffect)(() => {
|
|
446
|
+
if (ref.current && !fullscreen) {
|
|
447
|
+
const { width, height } = ref.current.getBoundingClientRect();
|
|
448
|
+
const realSize = isHorizontal ? width : height;
|
|
449
|
+
panel.store.setState({ size: realSize });
|
|
450
|
+
}
|
|
451
|
+
}, [fullscreen]);
|
|
452
|
+
(0, import_react5.useEffect)(() => {
|
|
453
|
+
if (!fullscreen) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const layer = panel.layer;
|
|
457
|
+
if (!layer) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
461
|
+
const { width, height } = entry.contentRect;
|
|
462
|
+
setLayerSize(isHorizontal ? width : height);
|
|
463
|
+
});
|
|
464
|
+
observer.observe(layer);
|
|
465
|
+
return () => observer.disconnect();
|
|
466
|
+
}, [fullscreen]);
|
|
467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
468
|
+
"div",
|
|
469
|
+
{
|
|
470
|
+
className: (0, import_clsx.clsx)(
|
|
471
|
+
"gedit-flow-panel-wrap",
|
|
472
|
+
isHorizontal ? "panel-horizontal" : "panel-vertical"
|
|
473
|
+
),
|
|
474
|
+
ref,
|
|
475
|
+
style: { ...panel.factory.style, ...panel.config.style, ...sizeStyle },
|
|
476
|
+
children: [
|
|
477
|
+
panel.resizable && panelManager.config.resizeBarRender({
|
|
478
|
+
size,
|
|
479
|
+
direction: isHorizontal ? "vertical" : "horizontal",
|
|
480
|
+
onResize: handleResize
|
|
481
|
+
}),
|
|
482
|
+
panel.renderer
|
|
483
|
+
]
|
|
484
|
+
},
|
|
485
|
+
panel.id
|
|
486
|
+
);
|
|
487
|
+
};
|
|
488
|
+
var PanelArea = ({ area }) => {
|
|
489
|
+
const panelManager = usePanelManager();
|
|
490
|
+
const [panels, setPanels] = (0, import_react5.useState)(panelManager.getPanels(area));
|
|
491
|
+
(0, import_react5.useEffect)(() => {
|
|
492
|
+
const dispose = panelManager.onPanelsChange(() => {
|
|
493
|
+
(0, import_react5.startTransition)(() => {
|
|
494
|
+
setPanels(panelManager.getPanels(area));
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
return () => dispose.dispose();
|
|
498
|
+
}, []);
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: panels.map((panel) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PanelContext.Provider, { value: panel, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PanelItem, { panel }) }, panel.id)) });
|
|
500
|
+
};
|
|
300
501
|
|
|
301
502
|
// src/components/panel-layer/css.ts
|
|
302
503
|
var globalCSS = `
|
|
@@ -316,8 +517,6 @@ var globalCSS = `
|
|
|
316
517
|
|
|
317
518
|
}
|
|
318
519
|
.gedit-flow-panel-layer-wrap-floating {
|
|
319
|
-
column-gap: 4px;
|
|
320
|
-
padding: 4px;
|
|
321
520
|
pointer-events: none;
|
|
322
521
|
}
|
|
323
522
|
|
|
@@ -329,18 +528,15 @@ var globalCSS = `
|
|
|
329
528
|
display: flex;
|
|
330
529
|
flex-direction: column;
|
|
331
530
|
}
|
|
332
|
-
.gedit-flow-panel-layer-wrap-floating .gedit-flow-panel-left-area {
|
|
333
|
-
row-gap: 4px;
|
|
334
|
-
}
|
|
335
531
|
.gedit-flow-panel-right-area {
|
|
336
532
|
height: 100%;
|
|
337
533
|
flex-grow: 1;
|
|
338
534
|
flex-shrink: 0;
|
|
339
535
|
min-width: 0;
|
|
340
536
|
display: flex;
|
|
341
|
-
|
|
537
|
+
max-width: 100%;
|
|
342
538
|
}
|
|
343
|
-
|
|
539
|
+
|
|
344
540
|
.gedit-flow-panel-main-area {
|
|
345
541
|
position: relative;
|
|
346
542
|
overflow: hidden;
|
|
@@ -355,55 +551,18 @@ var globalCSS = `
|
|
|
355
551
|
width: 100%;
|
|
356
552
|
min-height: 0;
|
|
357
553
|
}
|
|
554
|
+
.gedit-flow-panel-wrap {
|
|
555
|
+
pointer-events: auto;
|
|
556
|
+
overflow: auto;
|
|
557
|
+
position: relative;
|
|
558
|
+
}
|
|
559
|
+
.gedit-flow-panel-wrap.panel-horizontal {
|
|
560
|
+
height: 100%;
|
|
561
|
+
}
|
|
562
|
+
.gedit-flow-panel-wrap.panel-vertical {
|
|
563
|
+
width: 100%;
|
|
564
|
+
}
|
|
358
565
|
`;
|
|
359
|
-
var floatPanelWrap = {
|
|
360
|
-
pointerEvents: "auto",
|
|
361
|
-
height: "100%",
|
|
362
|
-
width: "100%",
|
|
363
|
-
overflow: "auto"
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// src/components/panel-layer/float-panel.tsx
|
|
367
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
368
|
-
var FloatPanel2 = ({ area }) => {
|
|
369
|
-
const [, setVersion] = (0, import_react3.useState)(0);
|
|
370
|
-
const panelManager = usePanelManager();
|
|
371
|
-
const panel = (0, import_react3.useRef)(panelManager.getPanel(area));
|
|
372
|
-
const isHorizontal = ["right", "docked-right"].includes(area);
|
|
373
|
-
const render = () => panel.current.elements.map((i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "float-panel-wrap", style: { ...floatPanelWrap, ...i.style }, children: i.el }, i.key));
|
|
374
|
-
const node = (0, import_react3.useRef)(render());
|
|
375
|
-
(0, import_react3.useEffect)(() => {
|
|
376
|
-
const dispose = panel.current.onUpdate(() => {
|
|
377
|
-
(0, import_react3.startTransition)(() => {
|
|
378
|
-
node.current = render();
|
|
379
|
-
setVersion((v) => v + 1);
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
return () => dispose.dispose();
|
|
383
|
-
}, [panel]);
|
|
384
|
-
const onResize = (0, import_react3.useCallback)((newSize) => panel.current.updateSize(newSize), []);
|
|
385
|
-
const size = panel.current.currentSize;
|
|
386
|
-
const sizeStyle = isHorizontal ? { width: size, height: "100%" } : { height: size, width: "100%" };
|
|
387
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
388
|
-
"div",
|
|
389
|
-
{
|
|
390
|
-
className: "gedit-flow-panel",
|
|
391
|
-
style: {
|
|
392
|
-
position: "relative",
|
|
393
|
-
display: panel.current.visible ? "block" : "none",
|
|
394
|
-
...sizeStyle
|
|
395
|
-
},
|
|
396
|
-
children: [
|
|
397
|
-
panelManager.config.resizeBarRender({
|
|
398
|
-
size,
|
|
399
|
-
direction: isHorizontal ? "vertical" : "horizontal",
|
|
400
|
-
onResize
|
|
401
|
-
}),
|
|
402
|
-
node.current
|
|
403
|
-
]
|
|
404
|
-
}
|
|
405
|
-
);
|
|
406
|
-
};
|
|
407
566
|
|
|
408
567
|
// src/components/panel-layer/panel-layer.tsx
|
|
409
568
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -420,7 +579,7 @@ var PanelLayer = ({
|
|
|
420
579
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
421
580
|
"div",
|
|
422
581
|
{
|
|
423
|
-
className: (0,
|
|
582
|
+
className: (0, import_clsx2.default)(
|
|
424
583
|
"gedit-flow-panel-layer-wrap",
|
|
425
584
|
mode === "docked" && "gedit-flow-panel-layer-wrap-docked",
|
|
426
585
|
mode === "floating" && "gedit-flow-panel-layer-wrap-floating",
|
|
@@ -430,9 +589,9 @@ var PanelLayer = ({
|
|
|
430
589
|
children: [
|
|
431
590
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gedit-flow-panel-left-area", children: [
|
|
432
591
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-main-area", children }),
|
|
433
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-bottom-area", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-bottom-area", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PanelArea, { area: mode === "docked" ? "docked-bottom" : "bottom" }) })
|
|
434
593
|
] }),
|
|
435
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-right-area", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-right-area", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PanelArea, { area: mode === "docked" ? "docked-right" : "right" }) })
|
|
436
595
|
]
|
|
437
596
|
}
|
|
438
597
|
);
|
|
@@ -443,16 +602,16 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
|
443
602
|
var DockedPanelLayer = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PanelLayer, { mode: "docked", ...props });
|
|
444
603
|
|
|
445
604
|
// src/services/panel-layer.ts
|
|
446
|
-
var PanelLayer2 = class extends
|
|
605
|
+
var PanelLayer2 = class extends import_core2.Layer {
|
|
447
606
|
constructor() {
|
|
448
607
|
super(...arguments);
|
|
449
|
-
this.panelRoot =
|
|
608
|
+
this.panelRoot = import_utils3.domUtils.createDivWithClass("gedit-flow-panel-layer");
|
|
450
609
|
this.layout = null;
|
|
451
610
|
}
|
|
452
611
|
onReady() {
|
|
453
612
|
this.panelConfig.getPopupContainer(this.pluginContext).appendChild(this.panelRoot);
|
|
454
613
|
this.toDispose.push(
|
|
455
|
-
|
|
614
|
+
import_utils3.Disposable.create(() => {
|
|
456
615
|
this.panelRoot.remove();
|
|
457
616
|
})
|
|
458
617
|
);
|
|
@@ -465,31 +624,45 @@ var PanelLayer2 = class extends import_core3.Layer {
|
|
|
465
624
|
top: 0,
|
|
466
625
|
zIndex: 100
|
|
467
626
|
};
|
|
468
|
-
|
|
627
|
+
import_utils3.domUtils.setStyle(this.panelRoot, commonStyle);
|
|
469
628
|
}
|
|
470
629
|
render() {
|
|
471
630
|
if (!this.layout) {
|
|
472
631
|
const { children, ...layoutProps } = this.panelConfig.layerProps;
|
|
473
|
-
this.layout = (0,
|
|
632
|
+
this.layout = (0, import_react6.createElement)(PanelLayer, layoutProps, children);
|
|
474
633
|
}
|
|
475
634
|
return import_react_dom.default.createPortal(this.layout, this.panelRoot);
|
|
476
635
|
}
|
|
477
636
|
};
|
|
478
637
|
__decorateClass([
|
|
479
|
-
(0,
|
|
638
|
+
(0, import_inversify4.inject)(PanelManagerConfig)
|
|
480
639
|
], PanelLayer2.prototype, "panelConfig", 2);
|
|
481
640
|
__decorateClass([
|
|
482
|
-
(0,
|
|
641
|
+
(0, import_inversify4.inject)(import_core2.PluginContext)
|
|
483
642
|
], PanelLayer2.prototype, "pluginContext", 2);
|
|
484
643
|
PanelLayer2 = __decorateClass([
|
|
485
|
-
(0,
|
|
644
|
+
(0, import_inversify4.injectable)()
|
|
486
645
|
], PanelLayer2);
|
|
487
646
|
|
|
488
647
|
// src/create-panel-manager-plugin.ts
|
|
489
|
-
var createPanelManagerPlugin = (0,
|
|
648
|
+
var createPanelManagerPlugin = (0, import_core3.definePluginCreator)({
|
|
490
649
|
onBind: ({ bind }, opt) => {
|
|
491
650
|
bind(PanelManager).to(PanelManager).inSingletonScope();
|
|
651
|
+
bind(PanelRestore).to(PanelRestoreImpl).inSingletonScope();
|
|
492
652
|
bind(PanelManagerConfig).toConstantValue(defineConfig(opt));
|
|
653
|
+
bind(PanelEntityFactory).toFactory(
|
|
654
|
+
(context) => ({
|
|
655
|
+
factory,
|
|
656
|
+
config
|
|
657
|
+
}) => {
|
|
658
|
+
const container = context.container.createChild();
|
|
659
|
+
container.bind(PanelEntityFactoryConstant).toConstantValue(factory);
|
|
660
|
+
container.bind(PanelEntityConfigConstant).toConstantValue(config);
|
|
661
|
+
const panel = container.resolve(PanelEntity);
|
|
662
|
+
panel.init();
|
|
663
|
+
return panel;
|
|
664
|
+
}
|
|
665
|
+
);
|
|
493
666
|
},
|
|
494
667
|
onInit(ctx) {
|
|
495
668
|
ctx.playground.registerLayer(PanelLayer2);
|
|
@@ -501,8 +674,10 @@ var createPanelManagerPlugin = (0, import_core4.definePluginCreator)({
|
|
|
501
674
|
0 && (module.exports = {
|
|
502
675
|
DockedPanelLayer,
|
|
503
676
|
PanelManager,
|
|
677
|
+
PanelRestore,
|
|
504
678
|
ResizeBar,
|
|
505
679
|
createPanelManagerPlugin,
|
|
680
|
+
usePanel,
|
|
506
681
|
usePanelManager
|
|
507
682
|
});
|
|
508
683
|
//# sourceMappingURL=index.js.map
|