@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/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,90 @@ 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();
61
+ var PanelRestore = Symbol("PanelRestore");
62
+ var PanelRestoreImpl = class {
63
+ constructor() {
64
+ this.map = /* @__PURE__ */ new Map();
109
65
  }
110
- get visible() {
111
- return this.elements.length > 0;
66
+ store(k, v) {
67
+ this.map.set(k, v);
112
68
  }
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();
69
+ restore(k) {
70
+ return this.map.get(k);
124
71
  }
125
72
  };
73
+ PanelRestoreImpl = __decorateClass([
74
+ (0, import_inversify.injectable)()
75
+ ], PanelRestoreImpl);
126
76
 
127
- // src/services/panel-manager.ts
128
- var PanelManager = class {
77
+ // src/services/panel-factory.ts
78
+ var PanelEntityFactory = Symbol("PanelEntityFactory");
79
+ var PanelEntityFactoryConstant = Symbol("PanelEntityFactoryConstant");
80
+ var PanelEntityConfigConstant = Symbol("PanelEntityConfigConstant");
81
+ var PANEL_SIZE_DEFAULT = 400;
82
+ var PanelEntity = class {
129
83
  constructor() {
130
- this.panelRegistry = /* @__PURE__ */ new Map();
84
+ this.initialized = false;
85
+ /** 实例唯一标识 */
86
+ this.id = (0, import_nanoid.nanoid)();
87
+ /** 渲染缓存 */
88
+ this.node = null;
131
89
  }
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);
90
+ get area() {
91
+ return this.config.area;
136
92
  }
137
- register(factory) {
138
- this.panelRegistry.set(factory.key, factory);
93
+ get key() {
94
+ return this.factory.key;
139
95
  }
140
- open(key, area = "right", options) {
141
- const factory = this.panelRegistry.get(key);
142
- if (!factory) {
143
- return;
96
+ get renderer() {
97
+ if (!this.node) {
98
+ this.node = this.factory.render(this.config.props);
144
99
  }
145
- const panel = this.getPanel(area);
146
- panel.open(factory, options);
100
+ return this.node;
147
101
  }
148
- close(key) {
149
- this.right.close(key);
150
- this.bottom.close(key);
151
- }
152
- getPanel(area) {
153
- return area === "right" ? this.right : this.bottom;
102
+ init() {
103
+ if (this.initialized) {
104
+ return;
105
+ }
106
+ this.initialized = true;
107
+ const cache = this.restore.restore(this.key);
108
+ this.store = (0, import_vanilla.createStore)(() => ({
109
+ size: this.config.defaultSize || this.factory.defaultSize || PANEL_SIZE_DEFAULT,
110
+ ...cache ?? {}
111
+ }));
154
112
  }
155
113
  dispose() {
156
- this.right.dispose();
157
- this.bottom.dispose();
114
+ this.restore.store(this.key, this.store.getState());
158
115
  }
159
116
  };
160
117
  __decorateClass([
161
- (0, import_inversify.inject)(PanelManagerConfig)
162
- ], PanelManager.prototype, "config", 2);
163
- PanelManager = __decorateClass([
164
- (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
- };
118
+ (0, import_inversify2.inject)(PanelRestore)
119
+ ], PanelEntity.prototype, "restore", 2);
120
+ __decorateClass([
121
+ (0, import_inversify2.inject)(PanelEntityFactoryConstant)
122
+ ], PanelEntity.prototype, "factory", 2);
123
+ __decorateClass([
124
+ (0, import_inversify2.inject)(PanelEntityConfigConstant)
125
+ ], PanelEntity.prototype, "config", 2);
126
+ PanelEntity = __decorateClass([
127
+ (0, import_inversify2.injectable)()
128
+ ], PanelEntity);
237
129
 
238
130
  // src/components/resize-bar/index.tsx
239
131
  var import_react = require("react");
240
132
  var import_jsx_runtime = require("react/jsx-runtime");
241
- var ResizeBar = ({ onResize, size, isVertical }) => {
133
+ var ResizeBar = ({ onResize, size, direction }) => {
242
134
  const currentPoint = (0, import_react.useRef)(null);
243
135
  const [isDragging, setIsDragging] = (0, import_react.useState)(false);
244
136
  const [isHovered, setIsHovered] = (0, import_react.useState)(false);
137
+ const isVertical = direction === "vertical";
245
138
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246
139
  "div",
247
140
  {
@@ -305,53 +198,342 @@ var ResizeBar = ({ onResize, size, isVertical }) => {
305
198
  );
306
199
  };
307
200
 
308
- // src/components/panel-layer/float-panel.tsx
201
+ // src/services/panel-config.ts
202
+ var PanelManagerConfig = Symbol("PanelManagerConfig");
203
+ var defineConfig = (config) => {
204
+ const defaultConfig = {
205
+ right: {
206
+ max: 1
207
+ },
208
+ bottom: {
209
+ max: 1
210
+ },
211
+ dockedRight: {
212
+ max: 1
213
+ },
214
+ dockedBottom: {
215
+ max: 1
216
+ },
217
+ factories: [],
218
+ autoResize: true,
219
+ layerProps: {},
220
+ resizeBarRender: ResizeBar,
221
+ getPopupContainer: (ctx) => ctx.playground.node.parentNode
222
+ };
223
+ return {
224
+ ...defaultConfig,
225
+ ...config
226
+ };
227
+ };
228
+
229
+ // src/services/panel-manager.ts
230
+ var import_inversify3 = require("inversify");
231
+ var import_utils = require("@flowgram.ai/utils");
232
+ var PanelManager = class {
233
+ constructor() {
234
+ this.panelRegistry = /* @__PURE__ */ new Map();
235
+ this.panels = /* @__PURE__ */ new Map();
236
+ this.onPanelsChangeEvent = new import_utils.Emitter();
237
+ this.onPanelsChange = this.onPanelsChangeEvent.event;
238
+ }
239
+ init() {
240
+ this.config.factories.forEach((factory) => this.register(factory));
241
+ }
242
+ /** registry panel factory */
243
+ register(factory) {
244
+ this.panelRegistry.set(factory.key, factory);
245
+ }
246
+ /** open panel */
247
+ open(key, area = "right", options) {
248
+ const factory = this.panelRegistry.get(key);
249
+ if (!factory) {
250
+ return;
251
+ }
252
+ const sameKeyPanels = this.getPanels(area).filter((p) => p.key === key);
253
+ if (!factory.allowDuplicates && sameKeyPanels.length) {
254
+ sameKeyPanels.forEach((p) => this.remove(p.id));
255
+ }
256
+ const panel = this.createPanel({
257
+ factory,
258
+ config: {
259
+ area,
260
+ ...options
261
+ }
262
+ });
263
+ this.panels.set(panel.id, panel);
264
+ this.trim(area);
265
+ this.onPanelsChangeEvent.fire();
266
+ console.log("jxj", this.panels);
267
+ }
268
+ /** close panel */
269
+ close(key) {
270
+ const panels = this.getPanels();
271
+ const closedPanels = key ? panels.filter((p) => p.key === key) : panels;
272
+ closedPanels.forEach((p) => this.remove(p.id));
273
+ this.onPanelsChangeEvent.fire();
274
+ }
275
+ trim(area) {
276
+ const panels = this.getPanels(area);
277
+ const areaConfig = this.getAreaConfig(area);
278
+ console.log("jxj", areaConfig.max, panels.length);
279
+ while (panels.length > areaConfig.max) {
280
+ const removed = panels.shift();
281
+ if (removed) {
282
+ this.remove(removed.id);
283
+ }
284
+ }
285
+ }
286
+ remove(id) {
287
+ const panel = this.panels.get(id);
288
+ if (panel) {
289
+ panel.dispose();
290
+ this.panels.delete(id);
291
+ }
292
+ }
293
+ getPanels(area) {
294
+ const panels = [];
295
+ this.panels.forEach((panel) => {
296
+ if (!area || panel.area === area) {
297
+ panels.push(panel);
298
+ }
299
+ });
300
+ return panels;
301
+ }
302
+ getAreaConfig(area) {
303
+ switch (area) {
304
+ case "docked-bottom":
305
+ return this.config.dockedBottom;
306
+ case "docked-right":
307
+ return this.config.dockedRight;
308
+ case "bottom":
309
+ return this.config.bottom;
310
+ case "right":
311
+ default:
312
+ return this.config.right;
313
+ }
314
+ }
315
+ dispose() {
316
+ this.onPanelsChangeEvent.dispose();
317
+ }
318
+ };
319
+ __decorateClass([
320
+ (0, import_inversify3.inject)(PanelManagerConfig)
321
+ ], PanelManager.prototype, "config", 2);
322
+ __decorateClass([
323
+ (0, import_inversify3.inject)(PanelEntityFactory)
324
+ ], PanelManager.prototype, "createPanel", 2);
325
+ PanelManager = __decorateClass([
326
+ (0, import_inversify3.injectable)()
327
+ ], PanelManager);
328
+
329
+ // src/services/panel-layer.ts
330
+ var import_react_dom = __toESM(require("react-dom"));
331
+ var import_react5 = require("react");
332
+ var import_inversify4 = require("inversify");
333
+ var import_utils2 = require("@flowgram.ai/utils");
334
+ var import_core2 = require("@flowgram.ai/core");
335
+
336
+ // src/components/panel-layer/panel-layer.tsx
337
+ var import_clsx2 = __toESM(require("clsx"));
338
+
339
+ // src/hooks/use-global-css.ts
340
+ var import_react2 = require("react");
341
+ var useGlobalCSS = ({ cssText, id, cleanup }) => {
342
+ (0, import_react2.useEffect)(() => {
343
+ if (typeof document === "undefined") return;
344
+ if (document.getElementById(id)) return;
345
+ const style = document.createElement("style");
346
+ style.id = id;
347
+ style.textContent = cssText;
348
+ document.head.appendChild(style);
349
+ return () => {
350
+ const existing = document.getElementById(id);
351
+ if (existing && cleanup) existing.remove();
352
+ };
353
+ }, [id]);
354
+ };
355
+
356
+ // src/components/panel-layer/panel.tsx
357
+ var import_react4 = require("react");
358
+ var import_traditional = require("zustand/traditional");
359
+ var import_shallow = require("zustand/shallow");
360
+ var import_clsx = __toESM(require("clsx"));
361
+
362
+ // src/hooks/use-panel-manager.ts
363
+ var import_core = require("@flowgram.ai/core");
364
+ var usePanelManager = () => (0, import_core.useService)(PanelManager);
365
+
366
+ // src/contexts.ts
367
+ var import_react3 = require("react");
368
+ var PanelContext = (0, import_react3.createContext)({});
369
+
370
+ // src/components/panel-layer/panel.tsx
309
371
  var import_jsx_runtime2 = require("react/jsx-runtime");
310
- var FloatPanel2 = ({ area }) => {
311
- const [, setVersion] = (0, import_react2.useState)(0);
372
+ var PanelItem = ({ panel }) => {
312
373
  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);
374
+ const ref = (0, import_react4.useRef)(null);
375
+ const resize = panel.factory.resize !== void 0 ? panel.factory.resize : panelManager.config.autoResize;
376
+ const isHorizontal = ["right", "docked-right"].includes(panel.area);
377
+ const size = (0, import_traditional.useStoreWithEqualityFn)(panel.store, (s) => s.size, import_shallow.shallow);
378
+ const sizeStyle = isHorizontal ? { width: size } : { height: size };
379
+ const handleResize = (next) => {
380
+ let nextSize = next;
381
+ if (typeof panel.factory.maxSize === "number" && nextSize > panel.factory.maxSize) {
382
+ nextSize = panel.factory.maxSize;
383
+ } else if (typeof panel.factory.minSize === "number" && nextSize < panel.factory.minSize) {
384
+ nextSize = panel.factory.minSize;
385
+ }
386
+ panel.store.setState({ size: nextSize });
387
+ };
388
+ (0, import_react4.useEffect)(() => {
389
+ if (ref.current) {
390
+ const { width, height } = ref.current.getBoundingClientRect();
391
+ const realSize = isHorizontal ? width : height;
392
+ panel.store.setState({ size: realSize });
393
+ }
394
+ }, []);
395
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
396
+ "div",
397
+ {
398
+ className: (0, import_clsx.default)(
399
+ "gedit-flow-panel-wrap",
400
+ isHorizontal ? "panel-horizontal" : "panel-vertical"
401
+ ),
402
+ ref,
403
+ style: { ...panel.factory.style, ...panel.config.style, ...sizeStyle },
404
+ children: [
405
+ resize && panelManager.config.resizeBarRender({
406
+ size,
407
+ direction: isHorizontal ? "vertical" : "horizontal",
408
+ onResize: handleResize
409
+ }),
410
+ panel.renderer
411
+ ]
412
+ },
413
+ panel.id
414
+ );
415
+ };
416
+ var PanelArea = ({ area }) => {
417
+ const panelManager = usePanelManager();
418
+ const [panels, setPanels] = (0, import_react4.useState)(panelManager.getPanels(area));
419
+ (0, import_react4.useEffect)(() => {
420
+ const dispose = panelManager.onPanelsChange(() => {
421
+ (0, import_react4.startTransition)(() => {
422
+ setPanels(panelManager.getPanels(area));
321
423
  });
322
424
  });
323
425
  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%" };
328
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
426
+ }, []);
427
+ 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)) });
428
+ };
429
+
430
+ // src/components/panel-layer/css.ts
431
+ var globalCSS = `
432
+ .gedit-flow-panel-layer-wrap * {
433
+ box-sizing: border-box;
434
+ }
435
+ .gedit-flow-panel-layer-wrap {
436
+ position: absolute;
437
+ top: 0;
438
+ left: 0;
439
+ display: flex;
440
+ width: 100%;
441
+ height: 100%;
442
+ overflow: hidden;
443
+ }
444
+ .gedit-flow-panel-layer-wrap-docked {
445
+
446
+ }
447
+ .gedit-flow-panel-layer-wrap-floating {
448
+ column-gap: 4px;
449
+ padding: 4px;
450
+ pointer-events: none;
451
+ }
452
+
453
+ .gedit-flow-panel-left-area {
454
+ width: 100%;
455
+ min-width: 0;
456
+ flex-grow: 0;
457
+ flex-shrink: 1;
458
+ display: flex;
459
+ flex-direction: column;
460
+ }
461
+ .gedit-flow-panel-layer-wrap-floating .gedit-flow-panel-left-area {
462
+ row-gap: 4px;
463
+ }
464
+ .gedit-flow-panel-right-area {
465
+ height: 100%;
466
+ flex-grow: 1;
467
+ flex-shrink: 0;
468
+ min-width: 0;
469
+ display: flex;
470
+ column-gap: 4px;
471
+ max-width: 100%;
472
+ }
473
+
474
+ .gedit-flow-panel-main-area {
475
+ position: relative;
476
+ overflow: hidden;
477
+ flex-grow: 0;
478
+ flex-shrink: 1;
479
+ width: 100%;
480
+ height: 100%;
481
+ }
482
+ .gedit-flow-panel-bottom-area {
483
+ flex-grow: 1;
484
+ flex-shrink: 0;
485
+ width: 100%;
486
+ min-height: 0;
487
+ }
488
+ .gedit-flow-panel-wrap {
489
+ pointer-events: auto;
490
+ overflow: auto;
491
+ position: relative;
492
+ }
493
+ .gedit-flow-panel-wrap.panel-horizontal {
494
+ height: 100%;
495
+ }
496
+ .gedit-flow-panel-wrap.panel-vertical {
497
+ width: 100%;
498
+ }
499
+ `;
500
+
501
+ // src/components/panel-layer/panel-layer.tsx
502
+ var import_jsx_runtime3 = require("react/jsx-runtime");
503
+ var PanelLayer = ({
504
+ mode = "floating",
505
+ className,
506
+ style,
507
+ children
508
+ }) => {
509
+ useGlobalCSS({
510
+ cssText: globalCSS,
511
+ id: "flow-panel-layer-css"
512
+ });
513
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
329
514
  "div",
330
515
  {
331
- className: "gedit-flow-panel",
332
- style: {
333
- position: "relative",
334
- display: panel.current.visible ? "block" : "none",
335
- ...sizeStyle
336
- },
516
+ className: (0, import_clsx2.default)(
517
+ "gedit-flow-panel-layer-wrap",
518
+ mode === "docked" && "gedit-flow-panel-layer-wrap-docked",
519
+ mode === "floating" && "gedit-flow-panel-layer-wrap-floating",
520
+ className
521
+ ),
522
+ style,
337
523
  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
524
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gedit-flow-panel-left-area", children: [
525
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gedit-flow-panel-main-area", children }),
526
+ /* @__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" }) })
527
+ ] }),
528
+ /* @__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" }) })
340
529
  ]
341
530
  }
342
531
  );
343
532
  };
344
533
 
345
- // src/components/panel-layer/panel-layer.tsx
346
- 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
- ] });
534
+ // src/components/panel-layer/docked-panel-layer.tsx
535
+ var import_jsx_runtime4 = require("react/jsx-runtime");
536
+ var DockedPanelLayer = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PanelLayer, { mode: "docked", ...props });
355
537
 
356
538
  // src/services/panel-layer.ts
357
539
  var PanelLayer2 = class extends import_core2.Layer {
@@ -380,38 +562,60 @@ var PanelLayer2 = class extends import_core2.Layer {
380
562
  }
381
563
  render() {
382
564
  if (!this.layout) {
383
- this.layout = (0, import_react3.createElement)(PanelLayer);
565
+ const { children, ...layoutProps } = this.panelConfig.layerProps;
566
+ this.layout = (0, import_react5.createElement)(PanelLayer, layoutProps, children);
384
567
  }
385
568
  return import_react_dom.default.createPortal(this.layout, this.panelRoot);
386
569
  }
387
570
  };
388
571
  __decorateClass([
389
- (0, import_inversify2.inject)(PanelManagerConfig)
572
+ (0, import_inversify4.inject)(PanelManagerConfig)
390
573
  ], PanelLayer2.prototype, "panelConfig", 2);
391
574
  __decorateClass([
392
- (0, import_inversify2.inject)(import_core2.PluginContext)
575
+ (0, import_inversify4.inject)(import_core2.PluginContext)
393
576
  ], PanelLayer2.prototype, "pluginContext", 2);
394
577
  PanelLayer2 = __decorateClass([
395
- (0, import_inversify2.injectable)()
578
+ (0, import_inversify4.injectable)()
396
579
  ], PanelLayer2);
397
580
 
398
581
  // src/create-panel-manager-plugin.ts
399
582
  var createPanelManagerPlugin = (0, import_core3.definePluginCreator)({
400
583
  onBind: ({ bind }, opt) => {
401
584
  bind(PanelManager).to(PanelManager).inSingletonScope();
585
+ bind(PanelRestore).to(PanelRestoreImpl).inSingletonScope();
402
586
  bind(PanelManagerConfig).toConstantValue(defineConfig(opt));
587
+ bind(PanelEntityFactory).toFactory(
588
+ (context) => ({
589
+ factory,
590
+ config
591
+ }) => {
592
+ const container = context.container.createChild();
593
+ container.bind(PanelEntityFactoryConstant).toConstantValue(factory);
594
+ container.bind(PanelEntityConfigConstant).toConstantValue(config);
595
+ const panel = container.resolve(PanelEntity);
596
+ panel.init();
597
+ return panel;
598
+ }
599
+ );
403
600
  },
404
- onInit(ctx, opt) {
601
+ onInit(ctx) {
405
602
  ctx.playground.registerLayer(PanelLayer2);
406
603
  const panelManager = ctx.container.get(PanelManager);
407
604
  panelManager.init();
408
605
  }
409
606
  });
607
+
608
+ // src/hooks/use-panel.ts
609
+ var import_react6 = require("react");
610
+ var usePanel = () => (0, import_react6.useContext)(PanelContext);
410
611
  // Annotate the CommonJS export names for ESM import in node:
411
612
  0 && (module.exports = {
613
+ DockedPanelLayer,
412
614
  PanelManager,
615
+ PanelRestore,
413
616
  ResizeBar,
414
617
  createPanelManagerPlugin,
618
+ usePanel,
415
619
  usePanelManager
416
620
  });
417
621
  //# sourceMappingURL=index.js.map