@flowgram.ai/panel-manager-plugin 1.0.2 → 1.0.6

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/index.js CHANGED
@@ -38,9 +38,12 @@ var __decorateClass = (decorators, target, key, kind) => {
38
38
  // src/index.ts
39
39
  var index_exports = {};
40
40
  __export(index_exports, {
41
+ DockedPanelLayer: () => DockedPanelLayer,
41
42
  PanelManager: () => PanelManager,
43
+ PanelRestore: () => PanelRestore,
42
44
  ResizeBar: () => ResizeBar,
43
45
  createPanelManagerPlugin: () => createPanelManagerPlugin,
46
+ usePanel: () => usePanel,
44
47
  usePanelManager: () => usePanelManager
45
48
  });
46
49
  module.exports = __toCommonJS(index_exports);
@@ -48,200 +51,37 @@ module.exports = __toCommonJS(index_exports);
48
51
  // src/create-panel-manager-plugin.ts
49
52
  var import_core3 = require("@flowgram.ai/core");
50
53
 
51
- // src/services/panel-config.ts
52
- var PanelManagerConfig = Symbol("PanelManagerConfig");
53
- var defineConfig = (config) => {
54
- const defaultConfig = {
55
- right: {
56
- max: 1
57
- },
58
- bottom: {
59
- max: 1
60
- },
61
- factories: [],
62
- getPopupContainer: (ctx) => ctx.playground.node.parentNode,
63
- autoResize: true
64
- };
65
- return {
66
- ...defaultConfig,
67
- ...config
68
- };
69
- };
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");
70
58
 
71
- // src/services/panel-manager.ts
59
+ // src/services/panel-restore.ts
72
60
  var import_inversify = require("inversify");
73
-
74
- // src/services/float-panel.ts
75
- var import_utils = require("@flowgram.ai/utils");
76
- var PANEL_SIZE_DEFAULT = 400;
77
- var FloatPanel = class {
78
- constructor(config) {
79
- this.config = config;
80
- this.elements = [];
81
- this.onUpdateEmitter = new import_utils.Emitter();
82
- this.sizeMap = /* @__PURE__ */ new Map();
83
- this.onUpdate = this.onUpdateEmitter.event;
84
- this.currentFactoryKey = "";
85
- }
86
- updateSize(newSize) {
87
- this.sizeMap.set(this.currentFactoryKey, newSize);
88
- this.onUpdateEmitter.fire();
89
- }
90
- get currentSize() {
91
- return this.sizeMap.get(this.currentFactoryKey) || PANEL_SIZE_DEFAULT;
92
- }
93
- open(factory, options) {
94
- const el = factory.render(options?.props);
95
- const idx = this.elements.findIndex((e) => e.key === factory.key);
96
- this.currentFactoryKey = factory.key;
97
- if (!this.sizeMap.has(factory.key)) {
98
- this.sizeMap.set(factory.key, factory.defaultSize || PANEL_SIZE_DEFAULT);
99
- }
100
- if (idx >= 0) {
101
- this.elements[idx] = { el, key: factory.key, style: factory.style };
102
- } else {
103
- this.elements.push({ el, key: factory.key, style: factory.style });
104
- if (this.elements.length > this.config.max) {
105
- this.elements.shift();
106
- }
107
- }
108
- this.onUpdateEmitter.fire();
109
- }
110
- get visible() {
111
- return this.elements.length > 0;
112
- }
113
- close(key) {
114
- if (!key) {
115
- this.elements = [];
116
- } else {
117
- this.elements = this.elements.filter((e) => e.key !== key);
118
- }
119
- this.onUpdateEmitter.fire();
120
- }
121
- dispose() {
122
- this.elements = [];
123
- this.onUpdateEmitter.dispose();
124
- }
125
- };
126
-
127
- // src/services/panel-manager.ts
128
- var PanelManager = class {
61
+ var PanelRestore = Symbol("PanelRestore");
62
+ var PanelRestoreImpl = class {
129
63
  constructor() {
130
- this.panelRegistry = /* @__PURE__ */ new Map();
64
+ this.map = /* @__PURE__ */ new Map();
131
65
  }
132
- init() {
133
- this.config.factories.forEach((factory) => this.register(factory));
134
- this.right = new FloatPanel(this.config.right);
135
- this.bottom = new FloatPanel(this.config.bottom);
136
- }
137
- register(factory) {
138
- this.panelRegistry.set(factory.key, factory);
139
- }
140
- open(key, area = "right", options) {
141
- const factory = this.panelRegistry.get(key);
142
- if (!factory) {
143
- return;
144
- }
145
- const panel = this.getPanel(area);
146
- panel.open(factory, options);
147
- }
148
- close(key) {
149
- this.right.close(key);
150
- this.bottom.close(key);
66
+ store(k, v) {
67
+ this.map.set(k, v);
151
68
  }
152
- getPanel(area) {
153
- return area === "right" ? this.right : this.bottom;
154
- }
155
- dispose() {
156
- this.right.dispose();
157
- this.bottom.dispose();
69
+ restore(k) {
70
+ return this.map.get(k);
158
71
  }
159
72
  };
160
- __decorateClass([
161
- (0, import_inversify.inject)(PanelManagerConfig)
162
- ], PanelManager.prototype, "config", 2);
163
- PanelManager = __decorateClass([
73
+ PanelRestoreImpl = __decorateClass([
164
74
  (0, import_inversify.injectable)()
165
- ], PanelManager);
166
-
167
- // src/services/panel-layer.ts
168
- var import_react_dom = __toESM(require("react-dom"));
169
- var import_react3 = require("react");
170
- var import_inversify2 = require("inversify");
171
- var import_utils2 = require("@flowgram.ai/utils");
172
- var import_core2 = require("@flowgram.ai/core");
173
-
174
- // src/components/panel-layer/float-panel.tsx
175
- var import_react2 = require("react");
176
-
177
- // src/hooks/use-panel-manager.ts
178
- var import_core = require("@flowgram.ai/core");
179
- var usePanelManager = () => (0, import_core.useService)(PanelManager);
180
-
181
- // src/components/panel-layer/css.ts
182
- var globalCSS = `
183
- .gedit-flow-panel-layer * {
184
- box-sizing: border-box;
185
- }
186
- `;
187
- var panelLayer = {
188
- pointerEvents: "none",
189
- position: "absolute",
190
- top: 0,
191
- left: 0,
192
- display: "flex",
193
- columnGap: "4px",
194
- width: "100%",
195
- height: "100%",
196
- padding: "4px",
197
- boxSizing: "border-box",
198
- overflow: "hidden"
199
- };
200
- var leftArea = {
201
- width: "100%",
202
- minWidth: 0,
203
- flexGrow: 0,
204
- flexShrink: 1,
205
- display: "flex",
206
- flexDirection: "column",
207
- rowGap: "4px"
208
- };
209
- var rightArea = {
210
- height: "100%",
211
- flexGrow: 1,
212
- flexShrink: 0,
213
- minWidth: 0,
214
- display: "flex",
215
- columnGap: "4px"
216
- };
217
- var mainArea = {
218
- position: "relative",
219
- overflow: "hidden",
220
- flexGrow: 0,
221
- flexShrink: 1,
222
- width: "100%",
223
- height: "100%"
224
- };
225
- var bottomArea = {
226
- flexGrow: 1,
227
- flexShrink: 0,
228
- width: "100%",
229
- minHeight: 0
230
- };
231
- var floatPanelWrap = {
232
- pointerEvents: "auto",
233
- height: "100%",
234
- width: "100%",
235
- overflow: "auto"
236
- };
75
+ ], PanelRestoreImpl);
237
76
 
238
77
  // src/components/resize-bar/index.tsx
239
78
  var import_react = require("react");
240
79
  var import_jsx_runtime = require("react/jsx-runtime");
241
- var ResizeBar = ({ onResize, size, isVertical }) => {
80
+ var ResizeBar = ({ onResize, size, direction }) => {
242
81
  const currentPoint = (0, import_react.useRef)(null);
243
82
  const [isDragging, setIsDragging] = (0, import_react.useState)(false);
244
83
  const [isHovered, setIsHovered] = (0, import_react.useState)(false);
84
+ const isVertical = direction === "vertical";
245
85
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246
86
  "div",
247
87
  {
@@ -305,65 +145,499 @@ var ResizeBar = ({ onResize, size, isVertical }) => {
305
145
  );
306
146
  };
307
147
 
308
- // src/components/panel-layer/float-panel.tsx
148
+ // src/services/panel-config.ts
149
+ var PanelManagerConfig = Symbol("PanelManagerConfig");
150
+ var defineConfig = (config) => {
151
+ const defaultConfig = {
152
+ right: {
153
+ max: 1
154
+ },
155
+ bottom: {
156
+ max: 1
157
+ },
158
+ dockedRight: {
159
+ max: 1
160
+ },
161
+ dockedBottom: {
162
+ max: 1
163
+ },
164
+ factories: [],
165
+ autoResize: true,
166
+ layerProps: {},
167
+ resizeBarRender: ResizeBar,
168
+ getPopupContainer: (ctx) => ctx.playground.node.parentNode
169
+ };
170
+ return {
171
+ ...defaultConfig,
172
+ ...config
173
+ };
174
+ };
175
+
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
+ };
190
+
191
+ // src/services/panel-factory.ts
192
+ var PanelEntityFactory = Symbol("PanelEntityFactory");
193
+ var PanelEntityFactoryConstant = Symbol("PanelEntityFactoryConstant");
194
+ var PanelEntityConfigConstant = Symbol("PanelEntityConfigConstant");
195
+ var PANEL_SIZE_DEFAULT = 400;
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);
216
+ }
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;
228
+ }
229
+ return this.factory.resize !== void 0 ? this.factory.resize : this.globalConfig.autoResize;
230
+ }
231
+ get keepDOM() {
232
+ return this.factory.keepDOM;
233
+ }
234
+ get visible() {
235
+ return this.store.getState().visible;
236
+ }
237
+ set visible(next) {
238
+ this.store.setState({ visible: next });
239
+ }
240
+ get layer() {
241
+ return document.querySelector(
242
+ this.mode ? ".gedit-flow-panel-layer-wrap-docked" : ".gedit-flow-panel-layer-wrap-floating"
243
+ );
244
+ }
245
+ init() {
246
+ if (this.initialized) {
247
+ return;
248
+ }
249
+ this.initialized = true;
250
+ const cache = this.restore.restore(this.key);
251
+ const initialState = merge(
252
+ {
253
+ size: this.config.defaultSize,
254
+ fullscreen: this.config.fullscreen
255
+ },
256
+ cache ? cache : {},
257
+ {
258
+ size: this.factory.defaultSize || PANEL_SIZE_DEFAULT,
259
+ fullscreen: this.factory.fullscreen || false,
260
+ ...this.factory.keepDOM ? { visible: true } : {}
261
+ }
262
+ );
263
+ this.store = (0, import_vanilla.createStore)(() => initialState);
264
+ }
265
+ mergeState() {
266
+ }
267
+ dispose() {
268
+ this.restore.store(this.key, this.store.getState());
269
+ }
270
+ };
271
+ __decorateClass([
272
+ (0, import_inversify2.inject)(PanelRestore)
273
+ ], PanelEntity.prototype, "restore", 2);
274
+ __decorateClass([
275
+ (0, import_inversify2.inject)(PanelEntityFactoryConstant)
276
+ ], PanelEntity.prototype, "factory", 2);
277
+ __decorateClass([
278
+ (0, import_inversify2.inject)(PanelEntityConfigConstant)
279
+ ], PanelEntity.prototype, "config", 2);
280
+ __decorateClass([
281
+ (0, import_inversify2.inject)(PanelManagerConfig)
282
+ ], PanelEntity.prototype, "globalConfig", 2);
283
+ PanelEntity = __decorateClass([
284
+ (0, import_inversify2.injectable)()
285
+ ], PanelEntity);
286
+
287
+ // src/services/panel-manager.ts
288
+ var import_inversify3 = require("inversify");
289
+ var import_utils2 = require("@flowgram.ai/utils");
290
+ var PanelManager = class {
291
+ constructor() {
292
+ this.panelRegistry = /* @__PURE__ */ new Map();
293
+ this.panels = /* @__PURE__ */ new Map();
294
+ this.onPanelsChangeEvent = new import_utils2.Emitter();
295
+ this.onPanelsChange = this.onPanelsChangeEvent.event;
296
+ }
297
+ init() {
298
+ this.config.factories.forEach((factory) => this.register(factory));
299
+ }
300
+ /** registry panel factory */
301
+ register(factory) {
302
+ this.panelRegistry.set(factory.key, factory);
303
+ }
304
+ /** open panel */
305
+ open(key, area = "right", options) {
306
+ const factory = this.panelRegistry.get(key);
307
+ if (!factory) {
308
+ return;
309
+ }
310
+ const sameKeyPanels = this.getPanels(area).filter((p) => p.key === key);
311
+ if (!factory.allowDuplicates && sameKeyPanels.length) {
312
+ !factory.keepDOM && sameKeyPanels.forEach((p) => this.remove(p.id));
313
+ }
314
+ if (factory.keepDOM && sameKeyPanels.length) {
315
+ sameKeyPanels[0].visible = true;
316
+ return;
317
+ }
318
+ const panel = this.createPanel({
319
+ factory,
320
+ config: {
321
+ area,
322
+ ...options
323
+ }
324
+ });
325
+ this.panels.set(panel.id, panel);
326
+ this.trim(area);
327
+ this.onPanelsChangeEvent.fire();
328
+ }
329
+ /** close panel */
330
+ close(key) {
331
+ const panels = this.getPanels();
332
+ const closedPanels = key ? panels.filter((p) => p.key === key) : panels;
333
+ closedPanels.forEach((panel) => {
334
+ if (panel.keepDOM) {
335
+ panel.visible = false;
336
+ return;
337
+ }
338
+ this.remove(panel.id);
339
+ });
340
+ this.onPanelsChangeEvent.fire();
341
+ }
342
+ trim(area) {
343
+ const panels = this.getPanels(area).filter((p) => !p.keepDOM);
344
+ const areaConfig = this.getAreaConfig(area);
345
+ while (panels.length > areaConfig.max) {
346
+ const removed = panels.shift();
347
+ if (removed) {
348
+ this.remove(removed.id);
349
+ }
350
+ }
351
+ }
352
+ remove(id) {
353
+ const panel = this.panels.get(id);
354
+ if (panel) {
355
+ panel.dispose();
356
+ this.panels.delete(id);
357
+ }
358
+ }
359
+ getPanels(area) {
360
+ const panels = [];
361
+ this.panels.forEach((panel) => {
362
+ if (!area || panel.area === area) {
363
+ panels.push(panel);
364
+ }
365
+ });
366
+ return panels;
367
+ }
368
+ getAreaConfig(area) {
369
+ switch (area) {
370
+ case "docked-bottom":
371
+ return this.config.dockedBottom;
372
+ case "docked-right":
373
+ return this.config.dockedRight;
374
+ case "bottom":
375
+ return this.config.bottom;
376
+ case "right":
377
+ default:
378
+ return this.config.right;
379
+ }
380
+ }
381
+ dispose() {
382
+ this.onPanelsChangeEvent.dispose();
383
+ }
384
+ };
385
+ __decorateClass([
386
+ (0, import_inversify3.inject)(PanelManagerConfig)
387
+ ], PanelManager.prototype, "config", 2);
388
+ __decorateClass([
389
+ (0, import_inversify3.inject)(PanelEntityFactory)
390
+ ], PanelManager.prototype, "createPanel", 2);
391
+ PanelManager = __decorateClass([
392
+ (0, import_inversify3.injectable)()
393
+ ], PanelManager);
394
+
395
+ // src/services/panel-layer.ts
396
+ var import_react_dom = __toESM(require("react-dom"));
397
+ var import_react6 = require("react");
398
+ var import_inversify4 = require("inversify");
399
+ var import_utils3 = require("@flowgram.ai/utils");
400
+ var import_core2 = require("@flowgram.ai/core");
401
+
402
+ // src/components/panel-layer/panel-layer.tsx
403
+ var import_clsx2 = __toESM(require("clsx"));
404
+
405
+ // src/hooks/use-global-css.ts
406
+ var import_react2 = require("react");
407
+ var useGlobalCSS = ({ cssText, id, cleanup }) => {
408
+ (0, import_react2.useEffect)(() => {
409
+ if (typeof document === "undefined") return;
410
+ if (document.getElementById(id)) return;
411
+ const style = document.createElement("style");
412
+ style.id = id;
413
+ style.textContent = cssText;
414
+ document.head.appendChild(style);
415
+ return () => {
416
+ const existing = document.getElementById(id);
417
+ if (existing && cleanup) existing.remove();
418
+ };
419
+ }, [id]);
420
+ };
421
+
422
+ // src/components/panel-layer/panel.tsx
423
+ var import_react5 = require("react");
424
+ var import_clsx = require("clsx");
425
+
426
+ // src/hooks/use-panel-manager.ts
427
+ var import_core = require("@flowgram.ai/core");
428
+ var usePanelManager = () => (0, import_core.useService)(PanelManager);
429
+
430
+ // src/hooks/use-panel.ts
431
+ var import_react4 = require("react");
432
+ var import_traditional = require("zustand/traditional");
433
+ var import_shallow = require("zustand/shallow");
434
+
435
+ // src/contexts.ts
436
+ var import_react3 = require("react");
437
+ var PanelContext = (0, import_react3.createContext)({});
438
+
439
+ // src/hooks/use-panel.ts
440
+ var usePanel = () => (0, import_react4.useContext)(PanelContext);
441
+ var usePanelStore = (selector) => {
442
+ const panel = usePanel();
443
+ return (0, import_traditional.useStoreWithEqualityFn)(panel.store, selector, import_shallow.shallow);
444
+ };
445
+
446
+ // src/components/panel-layer/panel.tsx
309
447
  var import_jsx_runtime2 = require("react/jsx-runtime");
310
- var FloatPanel2 = ({ area }) => {
311
- const [, setVersion] = (0, import_react2.useState)(0);
448
+ var PanelItem = ({ panel }) => {
312
449
  const panelManager = usePanelManager();
313
- const panel = (0, import_react2.useRef)(panelManager.getPanel(area));
314
- 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));
315
- const node = (0, import_react2.useRef)(render());
316
- (0, import_react2.useEffect)(() => {
317
- const dispose = panel.current.onUpdate(() => {
318
- (0, import_react2.startTransition)(() => {
319
- node.current = render();
320
- setVersion((v) => v + 1);
321
- });
450
+ const ref = (0, import_react5.useRef)(null);
451
+ const isHorizontal = ["right", "docked-right"].includes(panel.area);
452
+ const { size, fullscreen, visible } = usePanelStore((s) => ({ size: s.size, fullscreen: s.fullscreen, visible: s.visible }));
453
+ const [layerSize, setLayerSize] = (0, import_react5.useState)(size);
454
+ const [displayStyle, setDisplayStyle] = (0, import_react5.useState)({});
455
+ const currentSize = fullscreen ? layerSize : size;
456
+ const sizeStyle = isHorizontal ? { width: currentSize } : { height: currentSize };
457
+ const handleResize = (next) => {
458
+ let nextSize = next;
459
+ if (typeof panel.factory.maxSize === "number" && nextSize > panel.factory.maxSize) {
460
+ nextSize = panel.factory.maxSize;
461
+ } else if (typeof panel.factory.minSize === "number" && nextSize < panel.factory.minSize) {
462
+ nextSize = panel.factory.minSize;
463
+ }
464
+ panel.store.setState({ size: nextSize });
465
+ };
466
+ (0, import_react5.useEffect)(() => {
467
+ if (ref.current && !fullscreen) {
468
+ const { width, height } = ref.current.getBoundingClientRect();
469
+ const realSize = isHorizontal ? width : height;
470
+ panel.store.setState({ size: realSize });
471
+ }
472
+ }, [fullscreen]);
473
+ (0, import_react5.useEffect)(() => {
474
+ if (!fullscreen) {
475
+ return;
476
+ }
477
+ const layer = panel.layer;
478
+ if (!layer) {
479
+ return;
480
+ }
481
+ const observer = new ResizeObserver(([entry]) => {
482
+ const { width, height } = entry.contentRect;
483
+ setLayerSize(isHorizontal ? width : height);
322
484
  });
323
- return () => dispose.dispose();
324
- }, [panel]);
325
- const onResize = (0, import_react2.useCallback)((newSize) => panel.current.updateSize(newSize), []);
326
- const size = panel.current.currentSize;
327
- const sizeStyle = area === "right" ? { width: size, height: "100%" } : { height: size, width: "100%" };
485
+ observer.observe(layer);
486
+ return () => observer.disconnect();
487
+ }, [fullscreen]);
488
+ (0, import_react5.useEffect)(() => {
489
+ if (panel.keepDOM) {
490
+ setDisplayStyle({ display: visible ? "block" : "none" });
491
+ }
492
+ }, [visible]);
328
493
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
329
494
  "div",
330
495
  {
331
- className: "gedit-flow-panel",
332
- style: {
333
- position: "relative",
334
- display: panel.current.visible ? "block" : "none",
335
- ...sizeStyle
336
- },
496
+ className: (0, import_clsx.clsx)(
497
+ "gedit-flow-panel-wrap",
498
+ isHorizontal ? "panel-horizontal" : "panel-vertical"
499
+ ),
500
+ ref,
501
+ style: { ...displayStyle, ...panel.factory.style, ...panel.config.style, ...sizeStyle },
337
502
  children: [
338
- panelManager.config.autoResize && panel.current.elements.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ResizeBar, { size, isVertical: area === "right", onResize }),
339
- node.current
503
+ panel.resizable && panelManager.config.resizeBarRender({
504
+ size,
505
+ direction: isHorizontal ? "vertical" : "horizontal",
506
+ onResize: handleResize
507
+ }),
508
+ panel.renderer
340
509
  ]
341
- }
510
+ },
511
+ panel.id
342
512
  );
343
513
  };
514
+ var PanelArea = ({ area }) => {
515
+ const panelManager = usePanelManager();
516
+ const [panels, setPanels] = (0, import_react5.useState)(panelManager.getPanels(area));
517
+ (0, import_react5.useEffect)(() => {
518
+ const dispose = panelManager.onPanelsChange(() => {
519
+ (0, import_react5.startTransition)(() => {
520
+ setPanels(panelManager.getPanels(area));
521
+ });
522
+ });
523
+ return () => dispose.dispose();
524
+ }, []);
525
+ 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)) });
526
+ };
527
+
528
+ // src/components/panel-layer/css.ts
529
+ var globalCSS = `
530
+ .gedit-flow-panel-layer-wrap * {
531
+ box-sizing: border-box;
532
+ }
533
+ .gedit-flow-panel-layer-wrap {
534
+ position: absolute;
535
+ top: 0;
536
+ left: 0;
537
+ display: flex;
538
+ width: 100%;
539
+ height: 100%;
540
+ overflow: hidden;
541
+ }
542
+ .gedit-flow-panel-layer-wrap-docked {
543
+
544
+ }
545
+ .gedit-flow-panel-layer-wrap-floating {
546
+ pointer-events: none;
547
+ }
548
+
549
+ .gedit-flow-panel-left-area {
550
+ width: 100%;
551
+ min-width: 0;
552
+ flex-grow: 0;
553
+ flex-shrink: 1;
554
+ display: flex;
555
+ flex-direction: column;
556
+ }
557
+ .gedit-flow-panel-right-area {
558
+ height: 100%;
559
+ flex-grow: 1;
560
+ flex-shrink: 0;
561
+ min-width: 0;
562
+ display: flex;
563
+ max-width: 100%;
564
+ }
565
+
566
+ .gedit-flow-panel-main-area {
567
+ position: relative;
568
+ overflow: hidden;
569
+ flex-grow: 0;
570
+ flex-shrink: 1;
571
+ width: 100%;
572
+ height: 100%;
573
+ }
574
+ .gedit-flow-panel-bottom-area {
575
+ flex-grow: 1;
576
+ flex-shrink: 0;
577
+ width: 100%;
578
+ min-height: 0;
579
+ }
580
+ .gedit-flow-panel-wrap {
581
+ pointer-events: auto;
582
+ overflow: auto;
583
+ position: relative;
584
+ }
585
+ .gedit-flow-panel-wrap.panel-horizontal {
586
+ height: 100%;
587
+ }
588
+ .gedit-flow-panel-wrap.panel-vertical {
589
+ width: 100%;
590
+ }
591
+ `;
344
592
 
345
593
  // src/components/panel-layer/panel-layer.tsx
346
594
  var import_jsx_runtime3 = require("react/jsx-runtime");
347
- var PanelLayer = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: panelLayer, children: [
348
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { dangerouslySetInnerHTML: { __html: globalCSS } }),
349
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gedit-flow-panel-left-area", style: leftArea, children: [
350
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-main-area", style: mainArea, children }),
351
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-bottom-area", style: bottomArea, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloatPanel2, { area: "bottom" }) })
352
- ] }),
353
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-right-area", style: rightArea, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloatPanel2, { area: "right" }) })
354
- ] });
595
+ var PanelLayer = ({
596
+ mode = "floating",
597
+ className,
598
+ style,
599
+ children
600
+ }) => {
601
+ useGlobalCSS({
602
+ cssText: globalCSS,
603
+ id: "flow-panel-layer-css"
604
+ });
605
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
606
+ "div",
607
+ {
608
+ className: (0, import_clsx2.default)(
609
+ "gedit-flow-panel-layer-wrap",
610
+ mode === "docked" && "gedit-flow-panel-layer-wrap-docked",
611
+ mode === "floating" && "gedit-flow-panel-layer-wrap-floating",
612
+ className
613
+ ),
614
+ style,
615
+ children: [
616
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gedit-flow-panel-left-area", children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-main-area", children }),
618
+ /* @__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" }) })
619
+ ] }),
620
+ /* @__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" }) })
621
+ ]
622
+ }
623
+ );
624
+ };
625
+
626
+ // src/components/panel-layer/docked-panel-layer.tsx
627
+ var import_jsx_runtime4 = require("react/jsx-runtime");
628
+ var DockedPanelLayer = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PanelLayer, { mode: "docked", ...props });
355
629
 
356
630
  // src/services/panel-layer.ts
357
631
  var PanelLayer2 = class extends import_core2.Layer {
358
632
  constructor() {
359
633
  super(...arguments);
360
- this.panelRoot = import_utils2.domUtils.createDivWithClass("gedit-flow-panel-layer");
634
+ this.panelRoot = import_utils3.domUtils.createDivWithClass("gedit-flow-panel-layer");
361
635
  this.layout = null;
362
636
  }
363
637
  onReady() {
364
638
  this.panelConfig.getPopupContainer(this.pluginContext).appendChild(this.panelRoot);
365
639
  this.toDispose.push(
366
- import_utils2.Disposable.create(() => {
640
+ import_utils3.Disposable.create(() => {
367
641
  this.panelRoot.remove();
368
642
  })
369
643
  );
@@ -376,32 +650,47 @@ var PanelLayer2 = class extends import_core2.Layer {
376
650
  top: 0,
377
651
  zIndex: 100
378
652
  };
379
- import_utils2.domUtils.setStyle(this.panelRoot, commonStyle);
653
+ import_utils3.domUtils.setStyle(this.panelRoot, commonStyle);
380
654
  }
381
655
  render() {
382
656
  if (!this.layout) {
383
- this.layout = (0, import_react3.createElement)(PanelLayer);
657
+ const { children, ...layoutProps } = this.panelConfig.layerProps;
658
+ this.layout = (0, import_react6.createElement)(PanelLayer, layoutProps, children);
384
659
  }
385
660
  return import_react_dom.default.createPortal(this.layout, this.panelRoot);
386
661
  }
387
662
  };
388
663
  __decorateClass([
389
- (0, import_inversify2.inject)(PanelManagerConfig)
664
+ (0, import_inversify4.inject)(PanelManagerConfig)
390
665
  ], PanelLayer2.prototype, "panelConfig", 2);
391
666
  __decorateClass([
392
- (0, import_inversify2.inject)(import_core2.PluginContext)
667
+ (0, import_inversify4.inject)(import_core2.PluginContext)
393
668
  ], PanelLayer2.prototype, "pluginContext", 2);
394
669
  PanelLayer2 = __decorateClass([
395
- (0, import_inversify2.injectable)()
670
+ (0, import_inversify4.injectable)()
396
671
  ], PanelLayer2);
397
672
 
398
673
  // src/create-panel-manager-plugin.ts
399
674
  var createPanelManagerPlugin = (0, import_core3.definePluginCreator)({
400
675
  onBind: ({ bind }, opt) => {
401
676
  bind(PanelManager).to(PanelManager).inSingletonScope();
677
+ bind(PanelRestore).to(PanelRestoreImpl).inSingletonScope();
402
678
  bind(PanelManagerConfig).toConstantValue(defineConfig(opt));
679
+ bind(PanelEntityFactory).toFactory(
680
+ (context) => ({
681
+ factory,
682
+ config
683
+ }) => {
684
+ const container = context.container.createChild();
685
+ container.bind(PanelEntityFactoryConstant).toConstantValue(factory);
686
+ container.bind(PanelEntityConfigConstant).toConstantValue(config);
687
+ const panel = container.resolve(PanelEntity);
688
+ panel.init();
689
+ return panel;
690
+ }
691
+ );
403
692
  },
404
- onInit(ctx, opt) {
693
+ onInit(ctx) {
405
694
  ctx.playground.registerLayer(PanelLayer2);
406
695
  const panelManager = ctx.container.get(PanelManager);
407
696
  panelManager.init();
@@ -409,9 +698,12 @@ var createPanelManagerPlugin = (0, import_core3.definePluginCreator)({
409
698
  });
410
699
  // Annotate the CommonJS export names for ESM import in node:
411
700
  0 && (module.exports = {
701
+ DockedPanelLayer,
412
702
  PanelManager,
703
+ PanelRestore,
413
704
  ResizeBar,
414
705
  createPanelManagerPlugin,
706
+ usePanel,
415
707
  usePanelManager
416
708
  });
417
709
  //# sourceMappingURL=index.js.map