@aptre/flex-layout 0.5.4 → 0.5.5
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.mjs +52 -34
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5934,7 +5934,7 @@ var DragState = class {
|
|
|
5934
5934
|
|
|
5935
5935
|
// src/view/OptimizedLayout.tsx
|
|
5936
5936
|
import * as React20 from "react";
|
|
5937
|
-
import { useCallback, useEffect as useEffect6, useState as useState4 } from "react";
|
|
5937
|
+
import { memo as memo2, useCallback, useEffect as useEffect6, useMemo, useState as useState4 } from "react";
|
|
5938
5938
|
function createTabInfo(node) {
|
|
5939
5939
|
const parent = node.getParent();
|
|
5940
5940
|
const contentRect = parent?.getContentRect() ?? Rect.empty();
|
|
@@ -5979,6 +5979,41 @@ function TabRef({
|
|
|
5979
5979
|
}, [node, selected]);
|
|
5980
5980
|
return null;
|
|
5981
5981
|
}
|
|
5982
|
+
var TabPanel = memo2(function TabPanel2({
|
|
5983
|
+
nodeId,
|
|
5984
|
+
node,
|
|
5985
|
+
rect,
|
|
5986
|
+
visible,
|
|
5987
|
+
isDragging,
|
|
5988
|
+
contentClassName,
|
|
5989
|
+
className,
|
|
5990
|
+
renderTab,
|
|
5991
|
+
onPointerDown
|
|
5992
|
+
}) {
|
|
5993
|
+
const hasValidDimensions = rect.width > 0 && rect.height > 0;
|
|
5994
|
+
const content = useMemo(() => renderTab(node), [renderTab, node]);
|
|
5995
|
+
return /* @__PURE__ */ React20.createElement(
|
|
5996
|
+
"div",
|
|
5997
|
+
{
|
|
5998
|
+
role: "tabpanel",
|
|
5999
|
+
"data-tab-id": nodeId,
|
|
6000
|
+
className: className + (contentClassName ? " " + contentClassName : ""),
|
|
6001
|
+
style: {
|
|
6002
|
+
position: "absolute",
|
|
6003
|
+
display: visible ? "flex" : "none",
|
|
6004
|
+
left: hasValidDimensions ? rect.x : 0,
|
|
6005
|
+
top: hasValidDimensions ? rect.y : 0,
|
|
6006
|
+
width: hasValidDimensions ? rect.width : "100%",
|
|
6007
|
+
height: hasValidDimensions ? rect.height : "100%",
|
|
6008
|
+
overflow: "auto",
|
|
6009
|
+
// Tab panels receive pointer events when visible and not dragging
|
|
6010
|
+
pointerEvents: visible && !isDragging ? "auto" : "none"
|
|
6011
|
+
},
|
|
6012
|
+
onPointerDown
|
|
6013
|
+
},
|
|
6014
|
+
content
|
|
6015
|
+
);
|
|
6016
|
+
});
|
|
5982
6017
|
function TabContainer({
|
|
5983
6018
|
tabs,
|
|
5984
6019
|
renderTab,
|
|
@@ -5986,12 +6021,7 @@ function TabContainer({
|
|
|
5986
6021
|
classNameMapper,
|
|
5987
6022
|
model
|
|
5988
6023
|
}) {
|
|
5989
|
-
const
|
|
5990
|
-
(defaultClassName) => {
|
|
5991
|
-
return classNameMapper ? classNameMapper(defaultClassName) : defaultClassName;
|
|
5992
|
-
},
|
|
5993
|
-
[classNameMapper]
|
|
5994
|
-
);
|
|
6024
|
+
const className = classNameMapper ? classNameMapper("flexlayout__tab") : "flexlayout__tab";
|
|
5995
6025
|
const handlePointerDown = useCallback(
|
|
5996
6026
|
(node) => {
|
|
5997
6027
|
const parent = node.getParent();
|
|
@@ -6020,33 +6050,21 @@ function TabContainer({
|
|
|
6020
6050
|
},
|
|
6021
6051
|
"data-layout-path": "/tab-container"
|
|
6022
6052
|
},
|
|
6023
|
-
Array.from(tabs.entries()).map(([nodeId, tabInfo]) =>
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
top: hasValidDimensions ? rect.y : 0,
|
|
6039
|
-
width: hasValidDimensions ? rect.width : "100%",
|
|
6040
|
-
height: hasValidDimensions ? rect.height : "100%",
|
|
6041
|
-
overflow: "auto",
|
|
6042
|
-
// Tab panels receive pointer events when visible and not dragging
|
|
6043
|
-
pointerEvents: visible && !isDragging ? "auto" : "none"
|
|
6044
|
-
},
|
|
6045
|
-
onPointerDown: () => handlePointerDown(node)
|
|
6046
|
-
},
|
|
6047
|
-
renderTab(node)
|
|
6048
|
-
);
|
|
6049
|
-
})
|
|
6053
|
+
Array.from(tabs.entries()).map(([nodeId, tabInfo]) => /* @__PURE__ */ React20.createElement(
|
|
6054
|
+
TabPanel,
|
|
6055
|
+
{
|
|
6056
|
+
key: nodeId,
|
|
6057
|
+
nodeId,
|
|
6058
|
+
node: tabInfo.node,
|
|
6059
|
+
rect: tabInfo.rect,
|
|
6060
|
+
visible: tabInfo.visible,
|
|
6061
|
+
isDragging,
|
|
6062
|
+
contentClassName: tabInfo.node.getContentClassName(),
|
|
6063
|
+
className,
|
|
6064
|
+
renderTab,
|
|
6065
|
+
onPointerDown: () => handlePointerDown(tabInfo.node)
|
|
6066
|
+
}
|
|
6067
|
+
))
|
|
6050
6068
|
);
|
|
6051
6069
|
}
|
|
6052
6070
|
function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange, onModelChange: userOnModelChange, ...layoutProps }) {
|