flexlayout-react 0.6.3 → 0.6.7
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/ChangeLog.txt +13 -0
- package/declarations/Types.d.ts +2 -0
- package/declarations/model/Model.d.ts +1 -2
- package/declarations/model/RowNode.d.ts +0 -2
- package/dist/flexlayout.js +193 -319
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +1 -1
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +21 -12
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +6 -6
- package/lib/DockLocation.js.map +1 -1
- package/lib/DragDrop.js +24 -22
- package/lib/DragDrop.js.map +1 -1
- package/lib/Orientation.js +1 -1
- package/lib/Orientation.js.map +1 -1
- package/lib/PopupMenu.js +6 -6
- package/lib/PopupMenu.js.map +1 -1
- package/lib/Rect.js +1 -1
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +2 -0
- package/lib/Types.js.map +1 -1
- package/lib/model/BorderNode.js +31 -31
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +18 -14
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/Model.js +40 -35
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +29 -28
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +53 -50
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/SplitterNode.js +11 -11
- package/lib/model/SplitterNode.js.map +1 -1
- package/lib/model/TabNode.js +17 -17
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +52 -51
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +3 -3
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +52 -12
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTabSet.js +5 -4
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js +1 -1
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/FloatingWindow.js +27 -16
- package/lib/view/FloatingWindow.js.map +1 -1
- package/lib/view/FloatingWindowTab.js +1 -1
- package/lib/view/FloatingWindowTab.js.map +1 -1
- package/lib/view/Layout.js +80 -75
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Splitter.js +1 -1
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +5 -5
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +10 -15
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +2 -2
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabFloating.js +8 -2
- package/lib/view/TabFloating.js.map +1 -1
- package/lib/view/TabOverflowHook.js +1 -1
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +17 -12
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +3 -3
- package/lib/view/Utils.js.map +1 -1
- package/package.json +22 -16
- package/src/Attribute.ts +1 -1
- package/src/AttributeDefinitions.ts +16 -12
- package/src/DockLocation.ts +9 -9
- package/src/DragDrop.ts +42 -38
- package/src/Orientation.ts +2 -2
- package/src/PopupMenu.tsx +4 -4
- package/src/Rect.ts +1 -1
- package/src/Types.ts +2 -0
- package/src/model/BorderNode.ts +29 -28
- package/src/model/BorderSet.ts +16 -16
- package/src/model/IDraggable.ts +2 -2
- package/src/model/IDropTarget.ts +3 -3
- package/src/model/Model.ts +41 -41
- package/src/model/Node.ts +38 -38
- package/src/model/RowNode.ts +46 -44
- package/src/model/SplitterNode.ts +11 -11
- package/src/model/TabNode.ts +21 -21
- package/src/model/TabSetNode.ts +46 -44
- package/src/model/Utils.ts +3 -3
- package/src/view/BorderButton.tsx +82 -14
- package/src/view/BorderTabSet.tsx +6 -2
- package/src/view/ErrorBoundary.tsx +3 -3
- package/src/view/FloatingWindow.tsx +8 -6
- package/src/view/FloatingWindowTab.tsx +2 -2
- package/src/view/Layout.tsx +93 -93
- package/src/view/Splitter.tsx +2 -2
- package/src/view/Tab.tsx +3 -3
- package/src/view/TabButton.tsx +11 -15
- package/src/view/TabButtonStamp.tsx +2 -2
- package/src/view/TabFloating.tsx +11 -2
- package/src/view/TabOverflowHook.tsx +1 -1
- package/src/view/TabSet.tsx +6 -5
- package/src/view/Utils.tsx +3 -3
- package/style/_base.scss +55 -43
- package/style/dark.css +86 -45
- package/style/dark.css.map +1 -1
- package/style/dark.scss +70 -25
- package/style/gray.css +84 -60
- package/style/gray.css.map +1 -1
- package/style/gray.scss +70 -24
- package/style/light.css +84 -45
- package/style/light.css.map +1 -1
- package/style/light.scss +68 -19
- package/style/underline.css +557 -0
- package/style/underline.css.map +1 -0
- package/style/underline.scss +172 -0
package/src/view/Layout.tsx
CHANGED
|
@@ -25,7 +25,7 @@ import { FloatingWindow } from "./FloatingWindow";
|
|
|
25
25
|
import { FloatingWindowTab } from "./FloatingWindowTab";
|
|
26
26
|
import { TabFloating } from "./TabFloating";
|
|
27
27
|
import { IJsonTabNode } from "../model/IJsonModel";
|
|
28
|
-
import { Orientation } from "
|
|
28
|
+
import { Orientation } from "../Orientation";
|
|
29
29
|
import { CloseIcon, MaximizeIcon, OverflowIcon, PopoutIcon, RestoreIcon } from "./Icons";
|
|
30
30
|
import { TabButtonStamp } from "./TabButtonStamp";
|
|
31
31
|
|
|
@@ -150,7 +150,7 @@ export interface ICustomDropDestination {
|
|
|
150
150
|
cursor: string | undefined;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/** @
|
|
153
|
+
/** @internal */
|
|
154
154
|
export interface ILayoutCallbacks {
|
|
155
155
|
i18nName(id: I18nLabel, param?: string): string;
|
|
156
156
|
maximize(tabsetNode: TabSetNode): void;
|
|
@@ -192,12 +192,12 @@ export interface ILayoutCallbacks {
|
|
|
192
192
|
// Popout windows work in latest browsers based on webkit (Chrome, Opera, Safari, latest Edge) and Firefox. They do
|
|
193
193
|
// not work on any version if IE or the original Edge browser
|
|
194
194
|
// Assume any recent desktop browser not IE or original Edge will work
|
|
195
|
-
/** @
|
|
195
|
+
/** @internal */
|
|
196
196
|
// @ts-ignore
|
|
197
197
|
const isIEorEdge = typeof window !== "undefined" && (window.document.documentMode || /Edge\//.test(window.navigator.userAgent));
|
|
198
|
-
/** @
|
|
198
|
+
/** @internal */
|
|
199
199
|
const isDesktop = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
|
|
200
|
-
/** @
|
|
200
|
+
/** @internal */
|
|
201
201
|
const defaultSupportsPopout: boolean = isDesktop && !isIEorEdge;
|
|
202
202
|
|
|
203
203
|
/**
|
|
@@ -205,74 +205,74 @@ const defaultSupportsPopout: boolean = isDesktop && !isIEorEdge;
|
|
|
205
205
|
*/
|
|
206
206
|
export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
207
207
|
|
|
208
|
-
/** @
|
|
208
|
+
/** @internal */
|
|
209
209
|
private selfRef: React.RefObject<HTMLDivElement>;
|
|
210
|
-
/** @
|
|
210
|
+
/** @internal */
|
|
211
211
|
private findHeaderBarSizeRef: React.RefObject<HTMLDivElement>;
|
|
212
|
-
/** @
|
|
212
|
+
/** @internal */
|
|
213
213
|
private findTabBarSizeRef: React.RefObject<HTMLDivElement>;
|
|
214
|
-
/** @
|
|
214
|
+
/** @internal */
|
|
215
215
|
private findBorderBarSizeRef: React.RefObject<HTMLDivElement>;
|
|
216
|
-
/** @
|
|
216
|
+
/** @internal */
|
|
217
217
|
private previousModel?: Model;
|
|
218
|
-
/** @
|
|
218
|
+
/** @internal */
|
|
219
219
|
private centerRect?: Rect;
|
|
220
220
|
|
|
221
|
-
/** @
|
|
221
|
+
/** @internal */
|
|
222
222
|
// private start: number = 0;
|
|
223
|
-
/** @
|
|
223
|
+
/** @internal */
|
|
224
224
|
// private layoutTime: number = 0;
|
|
225
225
|
|
|
226
|
-
/** @
|
|
226
|
+
/** @internal */
|
|
227
227
|
private tabIds: string[];
|
|
228
|
-
/** @
|
|
228
|
+
/** @internal */
|
|
229
229
|
private newTabJson: IJsonTabNode | undefined;
|
|
230
|
-
/** @
|
|
230
|
+
/** @internal */
|
|
231
231
|
private firstMove: boolean = false;
|
|
232
|
-
/** @
|
|
232
|
+
/** @internal */
|
|
233
233
|
private dragNode?: Node & IDraggable;
|
|
234
|
-
/** @
|
|
234
|
+
/** @internal */
|
|
235
235
|
private dragDiv?: HTMLDivElement;
|
|
236
|
-
/** @
|
|
236
|
+
/** @internal */
|
|
237
237
|
private dragRectRendered: boolean = true;
|
|
238
|
-
/** @
|
|
238
|
+
/** @internal */
|
|
239
239
|
private dragDivText: string | undefined = undefined;
|
|
240
|
-
/** @
|
|
240
|
+
/** @internal */
|
|
241
241
|
private dropInfo: DropInfo | undefined;
|
|
242
|
-
/** @
|
|
242
|
+
/** @internal */
|
|
243
243
|
private customDrop: ICustomDropDestination | undefined;
|
|
244
|
-
/** @
|
|
244
|
+
/** @internal */
|
|
245
245
|
private outlineDiv?: HTMLDivElement;
|
|
246
246
|
|
|
247
|
-
/** @
|
|
247
|
+
/** @internal */
|
|
248
248
|
private edgeRectLength = 100;
|
|
249
|
-
/** @
|
|
249
|
+
/** @internal */
|
|
250
250
|
private edgeRectWidth = 10;
|
|
251
|
-
/** @
|
|
251
|
+
/** @internal */
|
|
252
252
|
private edgesShown = false;
|
|
253
|
-
/** @
|
|
253
|
+
/** @internal */
|
|
254
254
|
private edgeRightDiv?: HTMLDivElement;
|
|
255
|
-
/** @
|
|
255
|
+
/** @internal */
|
|
256
256
|
private edgeBottomDiv?: HTMLDivElement;
|
|
257
|
-
/** @
|
|
257
|
+
/** @internal */
|
|
258
258
|
private edgeLeftDiv?: HTMLDivElement;
|
|
259
|
-
/** @
|
|
259
|
+
/** @internal */
|
|
260
260
|
private edgeTopDiv?: HTMLDivElement;
|
|
261
|
-
/** @
|
|
261
|
+
/** @internal */
|
|
262
262
|
private fnNewNodeDropped?: (node?: Node, event?: Event) => void;
|
|
263
|
-
/** @
|
|
263
|
+
/** @internal */
|
|
264
264
|
private currentDocument?: HTMLDocument;
|
|
265
|
-
/** @
|
|
265
|
+
/** @internal */
|
|
266
266
|
private currentWindow?: Window;
|
|
267
|
-
/** @
|
|
267
|
+
/** @internal */
|
|
268
268
|
private supportsPopout: boolean;
|
|
269
|
-
/** @
|
|
269
|
+
/** @internal */
|
|
270
270
|
private popoutURL: string;
|
|
271
|
-
/** @
|
|
271
|
+
/** @internal */
|
|
272
272
|
private icons: IIcons;
|
|
273
|
-
/** @
|
|
273
|
+
/** @internal */
|
|
274
274
|
private firstRender: boolean;
|
|
275
|
-
/** @
|
|
275
|
+
/** @internal */
|
|
276
276
|
private resizeObserver?: ResizeObserver;
|
|
277
277
|
|
|
278
278
|
constructor(props: ILayoutProps) {
|
|
@@ -300,7 +300,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
300
300
|
this.onDragEnter = this.onDragEnter.bind(this);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
/** @
|
|
303
|
+
/** @internal */
|
|
304
304
|
styleFont(style: Record<string, string>): Record<string, string> {
|
|
305
305
|
if (this.props.font) {
|
|
306
306
|
if (this.selfRef.current) {
|
|
@@ -321,7 +321,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
321
321
|
return style;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
/** @
|
|
324
|
+
/** @internal */
|
|
325
325
|
onModelChange = () => {
|
|
326
326
|
this.forceUpdate();
|
|
327
327
|
if (this.props.onModelChange) {
|
|
@@ -329,7 +329,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
329
329
|
}
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
/** @
|
|
332
|
+
/** @internal */
|
|
333
333
|
doAction(action: Action): Node | undefined {
|
|
334
334
|
if (this.props.onAction !== undefined) {
|
|
335
335
|
const outcome = this.props.onAction(action);
|
|
@@ -342,7 +342,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
/** @
|
|
345
|
+
/** @internal */
|
|
346
346
|
componentDidMount() {
|
|
347
347
|
this.updateRect();
|
|
348
348
|
this.updateLayoutMetrics();
|
|
@@ -356,7 +356,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
356
356
|
this.resizeObserver.observe(this.selfRef.current!);
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
/** @
|
|
359
|
+
/** @internal */
|
|
360
360
|
componentDidUpdate() {
|
|
361
361
|
this.updateLayoutMetrics();
|
|
362
362
|
if (this.props.model !== this.previousModel) {
|
|
@@ -369,7 +369,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
369
369
|
// console.log("Layout time: " + this.layoutTime + "ms Render time: " + (Date.now() - this.start) + "ms");
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
/** @
|
|
372
|
+
/** @internal */
|
|
373
373
|
updateRect = (domRect: DOMRectReadOnly = this.getDomRect()) => {
|
|
374
374
|
const rect = new Rect(0, 0, domRect.width, domRect.height);
|
|
375
375
|
if (!rect.equals(this.state.rect) && rect.width !== 0 && rect.height !== 0) {
|
|
@@ -377,7 +377,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
-
/** @
|
|
380
|
+
/** @internal */
|
|
381
381
|
updateLayoutMetrics = () => {
|
|
382
382
|
if (this.findHeaderBarSizeRef.current) {
|
|
383
383
|
const headerBarSize = this.findHeaderBarSizeRef.current.getBoundingClientRect().height;
|
|
@@ -399,7 +399,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
|
|
402
|
-
/** @
|
|
402
|
+
/** @internal */
|
|
403
403
|
getClassName = (defaultClassName: string) => {
|
|
404
404
|
if (this.props.classNameMapper === undefined) {
|
|
405
405
|
return defaultClassName;
|
|
@@ -408,57 +408,57 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
408
408
|
}
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
-
/** @
|
|
411
|
+
/** @internal */
|
|
412
412
|
getCurrentDocument() {
|
|
413
413
|
return this.currentDocument;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
/** @
|
|
416
|
+
/** @internal */
|
|
417
417
|
getDomRect() {
|
|
418
418
|
return this.selfRef.current!.getBoundingClientRect();
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
/** @
|
|
421
|
+
/** @internal */
|
|
422
422
|
getRootDiv() {
|
|
423
423
|
return this.selfRef.current!;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
/** @
|
|
426
|
+
/** @internal */
|
|
427
427
|
isSupportsPopout() {
|
|
428
428
|
return this.supportsPopout;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
-
/** @
|
|
431
|
+
/** @internal */
|
|
432
432
|
isRealtimeResize() {
|
|
433
433
|
return this.props.realtimeResize ?? false;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
/** @
|
|
436
|
+
/** @internal */
|
|
437
437
|
onTabDrag(...args: Parameters<Required<ILayoutProps>['onTabDrag']>) {
|
|
438
438
|
return this.props.onTabDrag?.(...args);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
/** @
|
|
441
|
+
/** @internal */
|
|
442
442
|
getPopoutURL() {
|
|
443
443
|
return this.popoutURL;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
/** @
|
|
446
|
+
/** @internal */
|
|
447
447
|
componentWillUnmount() {
|
|
448
448
|
this.resizeObserver?.unobserve(this.selfRef.current!)
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
/** @
|
|
451
|
+
/** @internal */
|
|
452
452
|
setEditingTab(tabNode?: TabNode) {
|
|
453
453
|
this.setState({ editingTab: tabNode });
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
/** @
|
|
456
|
+
/** @internal */
|
|
457
457
|
getEditingTab() {
|
|
458
458
|
return this.state.editingTab;
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
/** @
|
|
461
|
+
/** @internal */
|
|
462
462
|
render() {
|
|
463
463
|
// first render will be used to find the size (via selfRef)
|
|
464
464
|
if (this.firstRender) {
|
|
@@ -498,20 +498,20 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
498
498
|
const nextTopIdsMap: Record<string, string> = {};
|
|
499
499
|
|
|
500
500
|
// Keep any previous tabs in the same DOM order as before, removing any that have been deleted
|
|
501
|
-
this.tabIds
|
|
501
|
+
for (const t of this.tabIds) {
|
|
502
502
|
if (tabComponents[t]) {
|
|
503
503
|
nextTopIds.push(t);
|
|
504
504
|
nextTopIdsMap[t] = t;
|
|
505
505
|
}
|
|
506
|
-
}
|
|
506
|
+
}
|
|
507
507
|
this.tabIds = nextTopIds;
|
|
508
508
|
|
|
509
509
|
// Add tabs that have been added to the DOM
|
|
510
|
-
Object.keys(tabComponents)
|
|
510
|
+
for (const t of Object.keys(tabComponents)) {
|
|
511
511
|
if (!nextTopIdsMap[t]) {
|
|
512
512
|
this.tabIds.push(t);
|
|
513
513
|
}
|
|
514
|
-
}
|
|
514
|
+
}
|
|
515
515
|
|
|
516
516
|
// this.layoutTime = (Date.now() - this.start);
|
|
517
517
|
|
|
@@ -530,7 +530,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
/** @
|
|
533
|
+
/** @internal */
|
|
534
534
|
metricsElements() {
|
|
535
535
|
// used to measure the tab and border tab sizes
|
|
536
536
|
const fontStyle = this.styleFont({ visibility: "hidden" });
|
|
@@ -549,7 +549,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
549
549
|
);
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
-
/** @
|
|
552
|
+
/** @internal */
|
|
553
553
|
onCloseWindow = (id: string) => {
|
|
554
554
|
this.doAction(Actions.unFloatTab(id));
|
|
555
555
|
try {
|
|
@@ -559,12 +559,12 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
561
|
|
|
562
|
-
/** @
|
|
562
|
+
/** @internal */
|
|
563
563
|
onSetWindow = (id: string, window: Window) => {
|
|
564
564
|
(this.props.model.getNodeById(id) as TabNode)._setWindow(window);
|
|
565
565
|
};
|
|
566
566
|
|
|
567
|
-
/** @
|
|
567
|
+
/** @internal */
|
|
568
568
|
renderBorder(borderSet: BorderSet, borderComponents: React.ReactNode[], tabComponents: Record<string, React.ReactNode>, floatingWindows: React.ReactNode[], splitterComponents: React.ReactNode[]) {
|
|
569
569
|
for (const border of borderSet.getBorders()) {
|
|
570
570
|
const borderPath = `/border/${border.getLocation().getName()}`;
|
|
@@ -625,7 +625,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
/** @
|
|
628
|
+
/** @internal */
|
|
629
629
|
renderChildren(path: string, node: RowNode | TabSetNode, tabSetComponents: React.ReactNode[], tabComponents: Record<string, React.ReactNode>, floatingWindows: React.ReactNode[], splitterComponents: React.ReactNode[]) {
|
|
630
630
|
const drawChildren = node._getDrawChildren();
|
|
631
631
|
let splitterCount = 0;
|
|
@@ -674,7 +674,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
/** @
|
|
677
|
+
/** @internal */
|
|
678
678
|
_getScreenRect(node: TabNode) {
|
|
679
679
|
const rect = node!.getRect()!.clone();
|
|
680
680
|
const bodyRect: DOMRect = this.selfRef.current!.getBoundingClientRect();
|
|
@@ -757,7 +757,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
757
757
|
rootdiv!.appendChild(this.dragDiv);
|
|
758
758
|
}
|
|
759
759
|
|
|
760
|
-
/** @
|
|
760
|
+
/** @internal */
|
|
761
761
|
onCancelAdd = () => {
|
|
762
762
|
const rootdiv = this.selfRef.current;
|
|
763
763
|
rootdiv!.removeChild(this.dragDiv!);
|
|
@@ -779,7 +779,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
779
779
|
this.customDrop = undefined;
|
|
780
780
|
};
|
|
781
781
|
|
|
782
|
-
/** @
|
|
782
|
+
/** @internal */
|
|
783
783
|
onCancelDrag = (wasDragging: boolean) => {
|
|
784
784
|
if (wasDragging) {
|
|
785
785
|
const rootdiv = this.selfRef.current!;
|
|
@@ -814,13 +814,13 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
814
814
|
|
|
815
815
|
};
|
|
816
816
|
|
|
817
|
-
/** @
|
|
817
|
+
/** @internal */
|
|
818
818
|
onDragDivMouseDown = (event: Event) => {
|
|
819
819
|
event.preventDefault();
|
|
820
820
|
this.dragStart(event, this.dragDivText, TabNode._fromJson(this.newTabJson, this.props.model, false), true, undefined, undefined);
|
|
821
821
|
};
|
|
822
822
|
|
|
823
|
-
/** @
|
|
823
|
+
/** @internal */
|
|
824
824
|
dragStart = (
|
|
825
825
|
event: Event | React.MouseEvent<HTMLDivElement, MouseEvent> | React.TouchEvent<HTMLDivElement> | React.DragEvent<HTMLDivElement> | undefined,
|
|
826
826
|
dragDivText: string | undefined,
|
|
@@ -838,7 +838,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
838
838
|
}
|
|
839
839
|
};
|
|
840
840
|
|
|
841
|
-
/** @
|
|
841
|
+
/** @internal */
|
|
842
842
|
dragRectRender = (text: String | undefined, node?: Node, json?: IJsonTabNode, onRendered?: () => void) => {
|
|
843
843
|
let content: React.ReactElement | undefined;
|
|
844
844
|
|
|
@@ -877,18 +877,18 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
877
877
|
this.dragDiv!);
|
|
878
878
|
};
|
|
879
879
|
|
|
880
|
-
/** @
|
|
880
|
+
/** @internal */
|
|
881
881
|
showPortal = (control: React.ReactNode, element: HTMLElement) => {
|
|
882
882
|
const portal = ReactDOM.createPortal(control, element);
|
|
883
883
|
this.setState({ portal });
|
|
884
884
|
};
|
|
885
885
|
|
|
886
|
-
/** @
|
|
886
|
+
/** @internal */
|
|
887
887
|
hidePortal = () => {
|
|
888
888
|
this.setState({ portal: undefined });
|
|
889
889
|
};
|
|
890
890
|
|
|
891
|
-
/** @
|
|
891
|
+
/** @internal */
|
|
892
892
|
onDragStart = () => {
|
|
893
893
|
this.dropInfo = undefined;
|
|
894
894
|
this.customDrop = undefined;
|
|
@@ -917,7 +917,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
917
917
|
return true;
|
|
918
918
|
};
|
|
919
919
|
|
|
920
|
-
/** @
|
|
920
|
+
/** @internal */
|
|
921
921
|
onDragMove = (event: React.MouseEvent<Element>) => {
|
|
922
922
|
if (this.firstMove === false) {
|
|
923
923
|
const speed = this.props.model._getAttribute("tabDragSpeed") as number;
|
|
@@ -960,7 +960,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
960
960
|
}
|
|
961
961
|
};
|
|
962
962
|
|
|
963
|
-
/** @
|
|
963
|
+
/** @internal */
|
|
964
964
|
onDragEnd = (event: Event) => {
|
|
965
965
|
const rootdiv = this.selfRef.current!;
|
|
966
966
|
rootdiv.removeChild(this.outlineDiv!);
|
|
@@ -1000,7 +1000,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1000
1000
|
this.setState({ showHiddenBorder: DockLocation.CENTER });
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
|
-
/** @
|
|
1003
|
+
/** @internal */
|
|
1004
1004
|
private handleCustomTabDrag(dropInfo: DropInfo, pos: { x: number; y: number; }, event: React.MouseEvent<Element, MouseEvent>) {
|
|
1005
1005
|
let invalidated = this.customDrop?.invalidated;
|
|
1006
1006
|
const currentCallback = this.customDrop?.callback;
|
|
@@ -1061,7 +1061,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
|
-
/** @
|
|
1064
|
+
/** @internal */
|
|
1065
1065
|
onDragEnter(event: React.DragEvent<HTMLDivElement>) {
|
|
1066
1066
|
// DragDrop keeps track of number of dragenters minus the number of
|
|
1067
1067
|
// dragleaves. Only start a new drag if there isn't one already.
|
|
@@ -1077,7 +1077,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
|
|
1079
1079
|
|
|
1080
|
-
/** @
|
|
1080
|
+
/** @internal */
|
|
1081
1081
|
checkForBorderToShow(x: number, y: number) {
|
|
1082
1082
|
const r = this.props.model._getOuterInnerRects().outer;
|
|
1083
1083
|
const c = r.getCenter();
|
|
@@ -1110,7 +1110,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
1112
|
|
|
1113
|
-
/** @
|
|
1113
|
+
/** @internal */
|
|
1114
1114
|
showEdges(rootdiv: HTMLElement) {
|
|
1115
1115
|
if (this.props.model.isEnableEdgeDock()) {
|
|
1116
1116
|
const length = this.edgeRectLength + "px";
|
|
@@ -1156,7 +1156,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
1159
|
-
/** @
|
|
1159
|
+
/** @internal */
|
|
1160
1160
|
repositionEdges(domRect: Rect) {
|
|
1161
1161
|
if (this.props.model.isEnableEdgeDock()) {
|
|
1162
1162
|
const r = this.centerRect!;
|
|
@@ -1175,7 +1175,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
|
-
/** @
|
|
1178
|
+
/** @internal */
|
|
1179
1179
|
hideEdges(rootdiv: HTMLElement) {
|
|
1180
1180
|
if (this.props.model.isEnableEdgeDock()) {
|
|
1181
1181
|
try {
|
|
@@ -1189,12 +1189,12 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1189
1189
|
this.edgesShown = false;
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
|
-
/** @
|
|
1192
|
+
/** @internal */
|
|
1193
1193
|
maximize(tabsetNode: TabSetNode) {
|
|
1194
1194
|
this.doAction(Actions.maximizeToggle(tabsetNode.getId()));
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
|
-
/** @
|
|
1197
|
+
/** @internal */
|
|
1198
1198
|
customizeTab(
|
|
1199
1199
|
tabNode: TabNode,
|
|
1200
1200
|
renderValues: ITabRenderValues,
|
|
@@ -1204,7 +1204,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
1206
1206
|
|
|
1207
|
-
/** @
|
|
1207
|
+
/** @internal */
|
|
1208
1208
|
customizeTabSet(
|
|
1209
1209
|
tabSetNode: TabSetNode | BorderNode,
|
|
1210
1210
|
renderValues: ITabSetRenderValues,
|
|
@@ -1214,7 +1214,7 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
}
|
|
1216
1216
|
|
|
1217
|
-
/** @
|
|
1217
|
+
/** @internal */
|
|
1218
1218
|
i18nName(id: I18nLabel, param?: string) {
|
|
1219
1219
|
let message;
|
|
1220
1220
|
if (this.props.i18nMapper) {
|
|
@@ -1226,23 +1226,23 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1226
1226
|
return message;
|
|
1227
1227
|
}
|
|
1228
1228
|
|
|
1229
|
-
/** @
|
|
1229
|
+
/** @internal */
|
|
1230
1230
|
getOnRenderFloatingTabPlaceholder() {
|
|
1231
1231
|
return this.props.onRenderFloatingTabPlaceholder;
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
|
-
/** @
|
|
1234
|
+
/** @internal */
|
|
1235
1235
|
getShowOverflowMenu() {
|
|
1236
1236
|
return this.props.onShowOverflowMenu;
|
|
1237
1237
|
}
|
|
1238
|
-
/** @
|
|
1238
|
+
/** @internal */
|
|
1239
1239
|
showContextMenu(node: TabNode | TabSetNode | BorderNode, event: React.MouseEvent<HTMLElement, MouseEvent>) {
|
|
1240
1240
|
if (this.props.onContextMenu) {
|
|
1241
1241
|
this.props.onContextMenu(node, event);
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
|
-
/** @
|
|
1245
|
+
/** @internal */
|
|
1246
1246
|
auxMouseClick(node: TabNode | TabSetNode | BorderNode, event: React.MouseEvent<HTMLElement, MouseEvent>) {
|
|
1247
1247
|
if (this.props.onAuxMouseClick) {
|
|
1248
1248
|
this.props.onAuxMouseClick(node, event);
|
|
@@ -1253,13 +1253,13 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
|
|
|
1253
1253
|
// wrapper round the drag rect renderer that can call
|
|
1254
1254
|
// a method once the rendering is written to the dom
|
|
1255
1255
|
|
|
1256
|
-
/** @
|
|
1256
|
+
/** @internal */
|
|
1257
1257
|
interface IDragRectRenderWrapper {
|
|
1258
1258
|
onRendered?: () => void;
|
|
1259
1259
|
children: React.ReactNode;
|
|
1260
1260
|
}
|
|
1261
1261
|
|
|
1262
|
-
/** @
|
|
1262
|
+
/** @internal */
|
|
1263
1263
|
const DragRectRenderWrapper = (props: IDragRectRenderWrapper) => {
|
|
1264
1264
|
React.useEffect(() => {
|
|
1265
1265
|
props.onRendered?.();
|
package/src/view/Splitter.tsx
CHANGED
|
@@ -9,14 +9,14 @@ import { Orientation } from "../Orientation";
|
|
|
9
9
|
import { CLASSES } from "../Types";
|
|
10
10
|
import { ILayoutCallbacks } from "./Layout";
|
|
11
11
|
|
|
12
|
-
/** @
|
|
12
|
+
/** @internal */
|
|
13
13
|
export interface ISplitterProps {
|
|
14
14
|
layout: ILayoutCallbacks;
|
|
15
15
|
node: SplitterNode;
|
|
16
16
|
path: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/** @
|
|
19
|
+
/** @internal */
|
|
20
20
|
export const Splitter = (props: ISplitterProps) => {
|
|
21
21
|
const { layout, node, path } = props;
|
|
22
22
|
|
package/src/view/Tab.tsx
CHANGED
|
@@ -7,10 +7,10 @@ import { CLASSES } from "../Types";
|
|
|
7
7
|
import { ILayoutCallbacks } from "./Layout";
|
|
8
8
|
import { ErrorBoundary } from "./ErrorBoundary";
|
|
9
9
|
import { I18nLabel } from "../I18nLabel";
|
|
10
|
-
import { BorderNode } from "
|
|
10
|
+
import { BorderNode } from "../model/BorderNode";
|
|
11
11
|
import { hideElement } from "./Utils";
|
|
12
12
|
|
|
13
|
-
/** @
|
|
13
|
+
/** @internal */
|
|
14
14
|
export interface ITabProps {
|
|
15
15
|
layout: ILayoutCallbacks;
|
|
16
16
|
selected: boolean;
|
|
@@ -19,7 +19,7 @@ export interface ITabProps {
|
|
|
19
19
|
path: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/** @
|
|
22
|
+
/** @internal */
|
|
23
23
|
export const Tab = (props: ITabProps) => {
|
|
24
24
|
const { layout, selected, node, factory, path } = props;
|
|
25
25
|
const [renderComponent, setRenderComponent] = React.useState<boolean>(!props.node.isEnableRenderOnDemand() || props.selected);
|
package/src/view/TabButton.tsx
CHANGED
|
@@ -9,24 +9,22 @@ import { ICloseType } from "../model/ICloseType";
|
|
|
9
9
|
import { CLASSES } from "../Types";
|
|
10
10
|
import { getRenderStateEx, isAuxMouseEvent } from "./Utils";
|
|
11
11
|
|
|
12
|
-
/** @
|
|
12
|
+
/** @internal */
|
|
13
13
|
export interface ITabButtonProps {
|
|
14
14
|
layout: ILayoutCallbacks;
|
|
15
15
|
node: TabNode;
|
|
16
16
|
selected: boolean;
|
|
17
|
-
height: number;
|
|
18
17
|
iconFactory?: (node: TabNode) => React.ReactNode | undefined;
|
|
19
18
|
titleFactory?: (node: TabNode) => React.ReactNode | undefined;
|
|
20
19
|
icons: IIcons;
|
|
21
20
|
path: string;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
/** @
|
|
23
|
+
/** @internal */
|
|
25
24
|
export const TabButton = (props: ITabButtonProps) => {
|
|
26
25
|
const { layout, node, selected, iconFactory, titleFactory, icons, path } = props;
|
|
27
26
|
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
28
27
|
const contentRef = React.useRef<HTMLInputElement | null>(null);
|
|
29
|
-
const contentWidth = React.useRef<number>(0);
|
|
30
28
|
|
|
31
29
|
const onMouseDown = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | React.TouchEvent<HTMLDivElement>) => {
|
|
32
30
|
|
|
@@ -51,16 +49,14 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
51
49
|
|
|
52
50
|
const onDoubleClick = (event: Event) => {
|
|
53
51
|
if (node.isEnableRename()) {
|
|
54
|
-
|
|
55
|
-
layout.getCurrentDocument()!.body.addEventListener("mousedown", onEndEdit);
|
|
56
|
-
layout.getCurrentDocument()!.body.addEventListener("touchstart", onEndEdit);
|
|
52
|
+
onRename();
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onRename = () => {
|
|
57
|
+
layout.setEditingTab(node);
|
|
58
|
+
layout.getCurrentDocument()!.body.addEventListener("mousedown", onEndEdit);
|
|
59
|
+
layout.getCurrentDocument()!.body.addEventListener("touchstart", onEndEdit);
|
|
64
60
|
};
|
|
65
61
|
|
|
66
62
|
const onEndEdit = (event: Event) => {
|
|
@@ -109,7 +105,6 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
109
105
|
const layoutRect = layout.getDomRect();
|
|
110
106
|
const r = selfRef.current!.getBoundingClientRect();
|
|
111
107
|
node._setTabRect(new Rect(r.left - layoutRect.left, r.top - layoutRect.top, r.width, r.height));
|
|
112
|
-
contentWidth.current = selfRef.current!.getBoundingClientRect().width;
|
|
113
108
|
};
|
|
114
109
|
|
|
115
110
|
const onTextBoxMouseDown = (event: React.MouseEvent<HTMLInputElement> | React.TouchEvent<HTMLInputElement>) => {
|
|
@@ -182,7 +177,8 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
182
177
|
data-layout-path={path + "/button/close"}
|
|
183
178
|
title={closeTitle}
|
|
184
179
|
className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_TRAILING)}
|
|
185
|
-
onMouseDown={onCloseMouseDown}
|
|
180
|
+
onMouseDown={onCloseMouseDown}
|
|
181
|
+
onClick={onClose}
|
|
186
182
|
onTouchStart={onCloseMouseDown}>
|
|
187
183
|
{(typeof icons.close === "function") ? icons.close(node) : icons.close}
|
|
188
184
|
</div>
|