@aptre/flex-layout 0.5.3 → 0.5.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +22 -4
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -5946,6 +5946,7 @@ function createTabInfo(node) {
5946
5946
  }
5947
5947
  function TabRef({
5948
5948
  node,
5949
+ selected,
5949
5950
  onTabMount,
5950
5951
  onRectChange,
5951
5952
  onVisibilityChange
@@ -5967,12 +5968,15 @@ function TabRef({
5967
5968
  onRectChange(node.getId(), contentRect);
5968
5969
  }
5969
5970
  }
5970
- onVisibilityChange(node.getId(), node.isSelected());
5971
5971
  return () => {
5972
5972
  node.removeEventListener("resize");
5973
5973
  node.removeEventListener("visibility");
5974
+ node.setVisible(false);
5974
5975
  };
5975
5976
  }, [node, onTabMount, onRectChange, onVisibilityChange]);
5977
+ useEffect6(() => {
5978
+ node.setVisible(selected);
5979
+ }, [node, selected]);
5976
5980
  return null;
5977
5981
  }
5978
5982
  function TabContainer({
@@ -6123,18 +6127,32 @@ function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange,
6123
6127
  );
6124
6128
  const handleModelChange = useCallback(
6125
6129
  (changedModel, action) => {
6126
- setTabs((prevTabs) => syncTabsWithModel(prevTabs));
6130
+ setTabs((prevTabs) => {
6131
+ const synced = syncTabsWithModel(prevTabs);
6132
+ let hasVisibilityChange = false;
6133
+ const updated = /* @__PURE__ */ new Map();
6134
+ for (const [nodeId, tabInfo] of synced) {
6135
+ const shouldBeVisible = tabInfo.node.isSelected();
6136
+ if (tabInfo.visible !== shouldBeVisible) {
6137
+ hasVisibilityChange = true;
6138
+ updated.set(nodeId, { ...tabInfo, visible: shouldBeVisible });
6139
+ } else {
6140
+ updated.set(nodeId, tabInfo);
6141
+ }
6142
+ }
6143
+ return hasVisibilityChange ? updated : synced;
6144
+ });
6127
6145
  userOnModelChange?.(changedModel, action);
6128
6146
  },
6129
6147
  [syncTabsWithModel, userOnModelChange]
6130
6148
  );
6131
6149
  const factory = useCallback(
6132
6150
  (node) => {
6133
- return /* @__PURE__ */ React20.createElement(TabRef, { key: node.getId(), node, onTabMount: handleTabMount, onRectChange: handleRectChange, onVisibilityChange: handleVisibilityChange });
6151
+ return /* @__PURE__ */ React20.createElement(TabRef, { key: node.getId(), node, selected: node.isSelected(), onTabMount: handleTabMount, onRectChange: handleRectChange, onVisibilityChange: handleVisibilityChange });
6134
6152
  },
6135
6153
  [handleTabMount, handleRectChange, handleVisibilityChange]
6136
6154
  );
6137
- return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Layout, { model, factory, classNameMapper, onDragStateChange: handleDragStateChange, onModelChange: handleModelChange, ...layoutProps }), /* @__PURE__ */ React20.createElement(TabContainer, { tabs, renderTab, isDragging, classNameMapper, model }));
6155
+ return /* @__PURE__ */ React20.createElement("div", { className: "flexlayout__optimized_layout", style: { position: "absolute", inset: 0, overflow: "hidden" } }, /* @__PURE__ */ React20.createElement(Layout, { model, factory, classNameMapper, onDragStateChange: handleDragStateChange, onModelChange: handleModelChange, ...layoutProps }), /* @__PURE__ */ React20.createElement(TabContainer, { tabs, renderTab, isDragging, classNameMapper, model }));
6138
6156
  }
6139
6157
 
6140
6158
  // src/model/walk.ts
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aptre/flex-layout",
3
3
  "author": "Caplin Systems Ltd",
4
4
  "description": "A multi-tab docking layout manager",
5
- "version": "0.5.3",
5
+ "version": "0.5.4",
6
6
  "license": "ISC",
7
7
  "repository": {
8
8
  "type": "git",