@flowgram.ai/panel-manager-plugin 0.1.0-alpha.24 → 0.1.0-alpha.26
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 +8 -7
- package/dist/esm/index.js +184 -90
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +199 -105
- package/dist/index.js.map +1 -1
- package/{.eslintrc.cjs → eslint.config.js} +2 -2
- package/package.json +5 -5
- package/rush-logs/panel-manager-plugin.build.log +9 -9
- package/src/components/panel-layer/css.ts +0 -6
- package/src/components/panel-layer/panel.tsx +38 -13
- package/src/hooks/use-panel.ts +9 -0
- package/src/services/panel-factory.ts +61 -5
- package/src/services/panel-manager.ts +31 -16
- package/src/types.ts +3 -0
- package/src/utils.ts +22 -0
package/dist/index.d.mts
CHANGED
|
@@ -17,16 +17,19 @@ interface PanelConfig {
|
|
|
17
17
|
interface PanelFactory<T extends any> {
|
|
18
18
|
key: string;
|
|
19
19
|
defaultSize: number;
|
|
20
|
+
fullscreen?: boolean;
|
|
20
21
|
maxSize?: number;
|
|
21
22
|
minSize?: number;
|
|
22
23
|
style?: React.CSSProperties;
|
|
23
24
|
/** Allows multiple panels with the same key to be rendered simultaneously */
|
|
24
25
|
allowDuplicates?: boolean;
|
|
25
26
|
resize?: boolean;
|
|
27
|
+
keepDOM?: boolean;
|
|
26
28
|
render: (props: T) => React.ReactNode;
|
|
27
29
|
}
|
|
28
30
|
interface PanelEntityConfig<T extends any = any> {
|
|
29
31
|
defaultSize?: number;
|
|
32
|
+
fullscreen?: boolean;
|
|
30
33
|
style?: React.CSSProperties;
|
|
31
34
|
props?: T;
|
|
32
35
|
}
|
|
@@ -96,12 +99,15 @@ type PanelEntityConfigConstant = PanelEntityConfig<any> & {
|
|
|
96
99
|
};
|
|
97
100
|
interface PanelEntityState {
|
|
98
101
|
size: number;
|
|
102
|
+
fullscreen: boolean;
|
|
103
|
+
visible: boolean;
|
|
99
104
|
}
|
|
100
105
|
declare class PanelEntity {
|
|
101
106
|
restore: PanelRestore;
|
|
102
107
|
/** 面板工厂 */
|
|
103
108
|
factory: PanelEntityFactoryConstant;
|
|
104
109
|
config: PanelEntityConfigConstant;
|
|
110
|
+
readonly globalConfig: PanelManagerConfig;
|
|
105
111
|
private initialized;
|
|
106
112
|
/** 实例唯一标识 */
|
|
107
113
|
id: string;
|
|
@@ -109,9 +115,18 @@ declare class PanelEntity {
|
|
|
109
115
|
node: React.ReactNode;
|
|
110
116
|
store: StoreApi<PanelEntityState>;
|
|
111
117
|
get area(): Area;
|
|
118
|
+
get mode(): "docked" | "floating";
|
|
112
119
|
get key(): string;
|
|
113
120
|
get renderer(): react.ReactNode;
|
|
121
|
+
get fullscreen(): boolean;
|
|
122
|
+
set fullscreen(next: boolean);
|
|
123
|
+
get resizable(): boolean;
|
|
124
|
+
get keepDOM(): boolean | undefined;
|
|
125
|
+
get visible(): boolean;
|
|
126
|
+
set visible(next: boolean);
|
|
127
|
+
get layer(): Element | null;
|
|
114
128
|
init(): void;
|
|
129
|
+
mergeState(): void;
|
|
115
130
|
dispose(): void;
|
|
116
131
|
}
|
|
117
132
|
|
|
@@ -145,10 +160,6 @@ declare const createPanelManagerPlugin: _flowgram_ai_core.PluginCreator<Partial<
|
|
|
145
160
|
|
|
146
161
|
declare const usePanelManager: () => PanelManager;
|
|
147
162
|
|
|
148
|
-
/**
|
|
149
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
150
|
-
* SPDX-License-Identifier: MIT
|
|
151
|
-
*/
|
|
152
163
|
declare const usePanel: () => PanelEntity;
|
|
153
164
|
|
|
154
165
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -17,16 +17,19 @@ interface PanelConfig {
|
|
|
17
17
|
interface PanelFactory<T extends any> {
|
|
18
18
|
key: string;
|
|
19
19
|
defaultSize: number;
|
|
20
|
+
fullscreen?: boolean;
|
|
20
21
|
maxSize?: number;
|
|
21
22
|
minSize?: number;
|
|
22
23
|
style?: React.CSSProperties;
|
|
23
24
|
/** Allows multiple panels with the same key to be rendered simultaneously */
|
|
24
25
|
allowDuplicates?: boolean;
|
|
25
26
|
resize?: boolean;
|
|
27
|
+
keepDOM?: boolean;
|
|
26
28
|
render: (props: T) => React.ReactNode;
|
|
27
29
|
}
|
|
28
30
|
interface PanelEntityConfig<T extends any = any> {
|
|
29
31
|
defaultSize?: number;
|
|
32
|
+
fullscreen?: boolean;
|
|
30
33
|
style?: React.CSSProperties;
|
|
31
34
|
props?: T;
|
|
32
35
|
}
|
|
@@ -96,12 +99,15 @@ type PanelEntityConfigConstant = PanelEntityConfig<any> & {
|
|
|
96
99
|
};
|
|
97
100
|
interface PanelEntityState {
|
|
98
101
|
size: number;
|
|
102
|
+
fullscreen: boolean;
|
|
103
|
+
visible: boolean;
|
|
99
104
|
}
|
|
100
105
|
declare class PanelEntity {
|
|
101
106
|
restore: PanelRestore;
|
|
102
107
|
/** 面板工厂 */
|
|
103
108
|
factory: PanelEntityFactoryConstant;
|
|
104
109
|
config: PanelEntityConfigConstant;
|
|
110
|
+
readonly globalConfig: PanelManagerConfig;
|
|
105
111
|
private initialized;
|
|
106
112
|
/** 实例唯一标识 */
|
|
107
113
|
id: string;
|
|
@@ -109,9 +115,18 @@ declare class PanelEntity {
|
|
|
109
115
|
node: React.ReactNode;
|
|
110
116
|
store: StoreApi<PanelEntityState>;
|
|
111
117
|
get area(): Area;
|
|
118
|
+
get mode(): "docked" | "floating";
|
|
112
119
|
get key(): string;
|
|
113
120
|
get renderer(): react.ReactNode;
|
|
121
|
+
get fullscreen(): boolean;
|
|
122
|
+
set fullscreen(next: boolean);
|
|
123
|
+
get resizable(): boolean;
|
|
124
|
+
get keepDOM(): boolean | undefined;
|
|
125
|
+
get visible(): boolean;
|
|
126
|
+
set visible(next: boolean);
|
|
127
|
+
get layer(): Element | null;
|
|
114
128
|
init(): void;
|
|
129
|
+
mergeState(): void;
|
|
115
130
|
dispose(): void;
|
|
116
131
|
}
|
|
117
132
|
|
|
@@ -145,10 +160,6 @@ declare const createPanelManagerPlugin: _flowgram_ai_core.PluginCreator<Partial<
|
|
|
145
160
|
|
|
146
161
|
declare const usePanelManager: () => PanelManager;
|
|
147
162
|
|
|
148
|
-
/**
|
|
149
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
150
|
-
* SPDX-License-Identifier: MIT
|
|
151
|
-
*/
|
|
152
163
|
declare const usePanel: () => PanelEntity;
|
|
153
164
|
|
|
154
165
|
/**
|
package/dist/index.js
CHANGED
|
@@ -74,59 +74,6 @@ PanelRestoreImpl = __decorateClass([
|
|
|
74
74
|
(0, import_inversify.injectable)()
|
|
75
75
|
], PanelRestoreImpl);
|
|
76
76
|
|
|
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 {
|
|
83
|
-
constructor() {
|
|
84
|
-
this.initialized = false;
|
|
85
|
-
/** 实例唯一标识 */
|
|
86
|
-
this.id = (0, import_nanoid.nanoid)();
|
|
87
|
-
/** 渲染缓存 */
|
|
88
|
-
this.node = null;
|
|
89
|
-
}
|
|
90
|
-
get area() {
|
|
91
|
-
return this.config.area;
|
|
92
|
-
}
|
|
93
|
-
get key() {
|
|
94
|
-
return this.factory.key;
|
|
95
|
-
}
|
|
96
|
-
get renderer() {
|
|
97
|
-
if (!this.node) {
|
|
98
|
-
this.node = this.factory.render(this.config.props);
|
|
99
|
-
}
|
|
100
|
-
return this.node;
|
|
101
|
-
}
|
|
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
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
dispose() {
|
|
114
|
-
this.restore.store(this.key, this.store.getState());
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
__decorateClass([
|
|
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);
|
|
129
|
-
|
|
130
77
|
// src/components/resize-bar/index.tsx
|
|
131
78
|
var import_react = require("react");
|
|
132
79
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -226,14 +173,125 @@ var defineConfig = (config) => {
|
|
|
226
173
|
};
|
|
227
174
|
};
|
|
228
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
|
+
|
|
229
287
|
// src/services/panel-manager.ts
|
|
230
288
|
var import_inversify3 = require("inversify");
|
|
231
|
-
var
|
|
289
|
+
var import_utils2 = require("@flowgram.ai/utils");
|
|
232
290
|
var PanelManager = class {
|
|
233
291
|
constructor() {
|
|
234
292
|
this.panelRegistry = /* @__PURE__ */ new Map();
|
|
235
293
|
this.panels = /* @__PURE__ */ new Map();
|
|
236
|
-
this.onPanelsChangeEvent = new
|
|
294
|
+
this.onPanelsChangeEvent = new import_utils2.Emitter();
|
|
237
295
|
this.onPanelsChange = this.onPanelsChangeEvent.event;
|
|
238
296
|
}
|
|
239
297
|
init() {
|
|
@@ -250,32 +308,39 @@ var PanelManager = class {
|
|
|
250
308
|
return;
|
|
251
309
|
}
|
|
252
310
|
const sameKeyPanels = this.getPanels(area).filter((p) => p.key === key);
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
311
|
+
if (factory.keepDOM && sameKeyPanels.length) {
|
|
312
|
+
const [panel] = sameKeyPanels;
|
|
313
|
+
this.panels.delete(panel.id);
|
|
314
|
+
this.panels.set(panel.id, panel);
|
|
315
|
+
panel.visible = true;
|
|
316
|
+
} else {
|
|
317
|
+
if (!factory.allowDuplicates && sameKeyPanels.length) {
|
|
318
|
+
sameKeyPanels.forEach((p) => this.remove(p.id));
|
|
261
319
|
}
|
|
262
|
-
|
|
263
|
-
|
|
320
|
+
const panel = this.createPanel({
|
|
321
|
+
factory,
|
|
322
|
+
config: {
|
|
323
|
+
area,
|
|
324
|
+
...options
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
this.panels.set(panel.id, panel);
|
|
328
|
+
}
|
|
264
329
|
this.trim(area);
|
|
265
330
|
this.onPanelsChangeEvent.fire();
|
|
266
|
-
console.log("jxj", this.panels);
|
|
267
331
|
}
|
|
268
332
|
/** close panel */
|
|
269
333
|
close(key) {
|
|
270
334
|
const panels = this.getPanels();
|
|
271
335
|
const closedPanels = key ? panels.filter((p) => p.key === key) : panels;
|
|
272
|
-
closedPanels.forEach((
|
|
336
|
+
closedPanels.forEach((panel) => {
|
|
337
|
+
this.remove(panel.id);
|
|
338
|
+
});
|
|
273
339
|
this.onPanelsChangeEvent.fire();
|
|
274
340
|
}
|
|
275
341
|
trim(area) {
|
|
276
|
-
const panels = this.getPanels(area);
|
|
342
|
+
const panels = this.getPanels(area).filter((p) => !p.keepDOM || p.visible);
|
|
277
343
|
const areaConfig = this.getAreaConfig(area);
|
|
278
|
-
console.log("jxj", areaConfig.max, panels.length);
|
|
279
344
|
while (panels.length > areaConfig.max) {
|
|
280
345
|
const removed = panels.shift();
|
|
281
346
|
if (removed) {
|
|
@@ -285,7 +350,12 @@ var PanelManager = class {
|
|
|
285
350
|
}
|
|
286
351
|
remove(id) {
|
|
287
352
|
const panel = this.panels.get(id);
|
|
288
|
-
if (panel) {
|
|
353
|
+
if (!panel) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (panel.keepDOM) {
|
|
357
|
+
panel.visible = false;
|
|
358
|
+
} else {
|
|
289
359
|
panel.dispose();
|
|
290
360
|
this.panels.delete(id);
|
|
291
361
|
}
|
|
@@ -328,9 +398,9 @@ PanelManager = __decorateClass([
|
|
|
328
398
|
|
|
329
399
|
// src/services/panel-layer.ts
|
|
330
400
|
var import_react_dom = __toESM(require("react-dom"));
|
|
331
|
-
var
|
|
401
|
+
var import_react6 = require("react");
|
|
332
402
|
var import_inversify4 = require("inversify");
|
|
333
|
-
var
|
|
403
|
+
var import_utils3 = require("@flowgram.ai/utils");
|
|
334
404
|
var import_core2 = require("@flowgram.ai/core");
|
|
335
405
|
|
|
336
406
|
// src/components/panel-layer/panel-layer.tsx
|
|
@@ -354,28 +424,42 @@ var useGlobalCSS = ({ cssText, id, cleanup }) => {
|
|
|
354
424
|
};
|
|
355
425
|
|
|
356
426
|
// src/components/panel-layer/panel.tsx
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
var import_shallow = require("zustand/shallow");
|
|
360
|
-
var import_clsx = __toESM(require("clsx"));
|
|
427
|
+
var import_react5 = require("react");
|
|
428
|
+
var import_clsx = require("clsx");
|
|
361
429
|
|
|
362
430
|
// src/hooks/use-panel-manager.ts
|
|
363
431
|
var import_core = require("@flowgram.ai/core");
|
|
364
432
|
var usePanelManager = () => (0, import_core.useService)(PanelManager);
|
|
365
433
|
|
|
434
|
+
// src/hooks/use-panel.ts
|
|
435
|
+
var import_react4 = require("react");
|
|
436
|
+
var import_traditional = require("zustand/traditional");
|
|
437
|
+
var import_shallow = require("zustand/shallow");
|
|
438
|
+
|
|
366
439
|
// src/contexts.ts
|
|
367
440
|
var import_react3 = require("react");
|
|
368
441
|
var PanelContext = (0, import_react3.createContext)({});
|
|
369
442
|
|
|
443
|
+
// src/hooks/use-panel.ts
|
|
444
|
+
var usePanel = () => (0, import_react4.useContext)(PanelContext);
|
|
445
|
+
var usePanelStore = (selector) => {
|
|
446
|
+
const panel = usePanel();
|
|
447
|
+
return (0, import_traditional.useStoreWithEqualityFn)(panel.store, selector, import_shallow.shallow);
|
|
448
|
+
};
|
|
449
|
+
|
|
370
450
|
// src/components/panel-layer/panel.tsx
|
|
371
451
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
372
|
-
var PanelItem = ({ panel }) => {
|
|
452
|
+
var PanelItem = ({ panel, hidden }) => {
|
|
373
453
|
const panelManager = usePanelManager();
|
|
374
|
-
const ref = (0,
|
|
375
|
-
const resize = panel.factory.resize !== void 0 ? panel.factory.resize : panelManager.config.autoResize;
|
|
454
|
+
const ref = (0, import_react5.useRef)(null);
|
|
376
455
|
const isHorizontal = ["right", "docked-right"].includes(panel.area);
|
|
377
|
-
const size = (
|
|
378
|
-
|
|
456
|
+
const { size, fullscreen } = usePanelStore((s) => ({
|
|
457
|
+
size: s.size,
|
|
458
|
+
fullscreen: s.fullscreen
|
|
459
|
+
}));
|
|
460
|
+
const [layerSize, setLayerSize] = (0, import_react5.useState)(size);
|
|
461
|
+
const currentSize = fullscreen ? layerSize : size;
|
|
462
|
+
const sizeStyle = isHorizontal ? { width: currentSize } : { height: currentSize };
|
|
379
463
|
const handleResize = (next) => {
|
|
380
464
|
let nextSize = next;
|
|
381
465
|
if (typeof panel.factory.maxSize === "number" && nextSize > panel.factory.maxSize) {
|
|
@@ -385,24 +469,44 @@ var PanelItem = ({ panel }) => {
|
|
|
385
469
|
}
|
|
386
470
|
panel.store.setState({ size: nextSize });
|
|
387
471
|
};
|
|
388
|
-
(0,
|
|
389
|
-
if (ref.current) {
|
|
472
|
+
(0, import_react5.useEffect)(() => {
|
|
473
|
+
if (ref.current && !fullscreen) {
|
|
390
474
|
const { width, height } = ref.current.getBoundingClientRect();
|
|
391
475
|
const realSize = isHorizontal ? width : height;
|
|
392
476
|
panel.store.setState({ size: realSize });
|
|
393
477
|
}
|
|
394
|
-
}, []);
|
|
478
|
+
}, [fullscreen]);
|
|
479
|
+
(0, import_react5.useEffect)(() => {
|
|
480
|
+
if (!fullscreen) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const layer = panel.layer;
|
|
484
|
+
if (!layer) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
488
|
+
const { width, height } = entry.contentRect;
|
|
489
|
+
setLayerSize(isHorizontal ? width : height);
|
|
490
|
+
});
|
|
491
|
+
observer.observe(layer);
|
|
492
|
+
return () => observer.disconnect();
|
|
493
|
+
}, [fullscreen]);
|
|
395
494
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
396
495
|
"div",
|
|
397
496
|
{
|
|
398
|
-
className: (0, import_clsx.
|
|
497
|
+
className: (0, import_clsx.clsx)(
|
|
399
498
|
"gedit-flow-panel-wrap",
|
|
400
499
|
isHorizontal ? "panel-horizontal" : "panel-vertical"
|
|
401
500
|
),
|
|
402
501
|
ref,
|
|
403
|
-
style: {
|
|
502
|
+
style: {
|
|
503
|
+
display: hidden ? "none" : "block",
|
|
504
|
+
...panel.factory.style,
|
|
505
|
+
...panel.config.style,
|
|
506
|
+
...sizeStyle
|
|
507
|
+
},
|
|
404
508
|
children: [
|
|
405
|
-
|
|
509
|
+
panel.resizable && panelManager.config.resizeBarRender({
|
|
406
510
|
size,
|
|
407
511
|
direction: isHorizontal ? "vertical" : "horizontal",
|
|
408
512
|
onResize: handleResize
|
|
@@ -415,16 +519,16 @@ var PanelItem = ({ panel }) => {
|
|
|
415
519
|
};
|
|
416
520
|
var PanelArea = ({ area }) => {
|
|
417
521
|
const panelManager = usePanelManager();
|
|
418
|
-
const [panels, setPanels] = (0,
|
|
419
|
-
(0,
|
|
522
|
+
const [panels, setPanels] = (0, import_react5.useState)(panelManager.getPanels(area));
|
|
523
|
+
(0, import_react5.useEffect)(() => {
|
|
420
524
|
const dispose = panelManager.onPanelsChange(() => {
|
|
421
|
-
(0,
|
|
525
|
+
(0, import_react5.startTransition)(() => {
|
|
422
526
|
setPanels(panelManager.getPanels(area));
|
|
423
527
|
});
|
|
424
528
|
});
|
|
425
529
|
return () => dispose.dispose();
|
|
426
530
|
}, []);
|
|
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)) });
|
|
531
|
+
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, hidden: panel.keepDOM && !panel.visible }) }, panel.id)) });
|
|
428
532
|
};
|
|
429
533
|
|
|
430
534
|
// src/components/panel-layer/css.ts
|
|
@@ -445,8 +549,6 @@ var globalCSS = `
|
|
|
445
549
|
|
|
446
550
|
}
|
|
447
551
|
.gedit-flow-panel-layer-wrap-floating {
|
|
448
|
-
column-gap: 4px;
|
|
449
|
-
padding: 4px;
|
|
450
552
|
pointer-events: none;
|
|
451
553
|
}
|
|
452
554
|
|
|
@@ -458,16 +560,12 @@ var globalCSS = `
|
|
|
458
560
|
display: flex;
|
|
459
561
|
flex-direction: column;
|
|
460
562
|
}
|
|
461
|
-
.gedit-flow-panel-layer-wrap-floating .gedit-flow-panel-left-area {
|
|
462
|
-
row-gap: 4px;
|
|
463
|
-
}
|
|
464
563
|
.gedit-flow-panel-right-area {
|
|
465
564
|
height: 100%;
|
|
466
565
|
flex-grow: 1;
|
|
467
566
|
flex-shrink: 0;
|
|
468
567
|
min-width: 0;
|
|
469
568
|
display: flex;
|
|
470
|
-
column-gap: 4px;
|
|
471
569
|
max-width: 100%;
|
|
472
570
|
}
|
|
473
571
|
|
|
@@ -539,13 +637,13 @@ var DockedPanelLayer = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(P
|
|
|
539
637
|
var PanelLayer2 = class extends import_core2.Layer {
|
|
540
638
|
constructor() {
|
|
541
639
|
super(...arguments);
|
|
542
|
-
this.panelRoot =
|
|
640
|
+
this.panelRoot = import_utils3.domUtils.createDivWithClass("gedit-flow-panel-layer");
|
|
543
641
|
this.layout = null;
|
|
544
642
|
}
|
|
545
643
|
onReady() {
|
|
546
644
|
this.panelConfig.getPopupContainer(this.pluginContext).appendChild(this.panelRoot);
|
|
547
645
|
this.toDispose.push(
|
|
548
|
-
|
|
646
|
+
import_utils3.Disposable.create(() => {
|
|
549
647
|
this.panelRoot.remove();
|
|
550
648
|
})
|
|
551
649
|
);
|
|
@@ -558,12 +656,12 @@ var PanelLayer2 = class extends import_core2.Layer {
|
|
|
558
656
|
top: 0,
|
|
559
657
|
zIndex: 100
|
|
560
658
|
};
|
|
561
|
-
|
|
659
|
+
import_utils3.domUtils.setStyle(this.panelRoot, commonStyle);
|
|
562
660
|
}
|
|
563
661
|
render() {
|
|
564
662
|
if (!this.layout) {
|
|
565
663
|
const { children, ...layoutProps } = this.panelConfig.layerProps;
|
|
566
|
-
this.layout = (0,
|
|
664
|
+
this.layout = (0, import_react6.createElement)(PanelLayer, layoutProps, children);
|
|
567
665
|
}
|
|
568
666
|
return import_react_dom.default.createPortal(this.layout, this.panelRoot);
|
|
569
667
|
}
|
|
@@ -604,10 +702,6 @@ var createPanelManagerPlugin = (0, import_core3.definePluginCreator)({
|
|
|
604
702
|
panelManager.init();
|
|
605
703
|
}
|
|
606
704
|
});
|
|
607
|
-
|
|
608
|
-
// src/hooks/use-panel.ts
|
|
609
|
-
var import_react6 = require("react");
|
|
610
|
-
var usePanel = () => (0, import_react6.useContext)(PanelContext);
|
|
611
705
|
// Annotate the CommonJS export names for ESM import in node:
|
|
612
706
|
0 && (module.exports = {
|
|
613
707
|
DockedPanelLayer,
|