xmlui 0.10.20 → 0.10.21

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.
@@ -15,14 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.TreeComponent = exports.defaultProps = void 0;
16
16
  const jsx_runtime_1 = require("react/jsx-runtime");
17
17
  const react_1 = require("react");
18
- const react_window_1 = require("react-window");
19
- const react_virtualized_auto_sizer_1 = __importDefault(require("react-virtualized-auto-sizer"));
18
+ const virtua_1 = require("virtua");
20
19
  const classnames_1 = __importDefault(require("classnames"));
21
20
  const IconNative_1 = __importDefault(require("../Icon/IconNative"));
22
21
  const SpinnerNative_1 = require("../Spinner/SpinnerNative");
23
22
  const TreeComponent_module_scss_1 = __importDefault(require("./TreeComponent.module.scss"));
24
23
  const treeUtils_1 = require("../../components-core/utils/treeUtils");
25
- const TreeRow = (0, react_1.memo)(({ index, style, data }) => {
24
+ const TreeRow = (0, react_1.memo)(({ index, data }) => {
26
25
  const { nodes, toggleNode, selectedId, itemRenderer, itemClickExpands, onItemClick, onSelection, focusedIndex, treeContainerRef, iconCollapsed, iconExpanded, iconSize, animateExpand, expandRotation, } = data;
27
26
  const treeItem = nodes[index];
28
27
  const isFocused = focusedIndex === index && focusedIndex >= 0;
@@ -64,7 +63,7 @@ const TreeRow = (0, react_1.memo)(({ index, style, data }) => {
64
63
  // Get loading state for styling and interaction
65
64
  const nodeWithState = treeItem;
66
65
  const isLoading = nodeWithState.loadingState === "loading";
67
- return ((0, jsx_runtime_1.jsx)("div", { style: Object.assign(Object.assign({}, style), { width: "auto", minWidth: "100%", display: "flex" }), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(TreeComponent_module_scss_1.default.rowWrapper, {
66
+ return ((0, jsx_runtime_1.jsx)("div", { style: { width: "100%", display: "flex" }, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(TreeComponent_module_scss_1.default.rowWrapper, {
68
67
  [TreeComponent_module_scss_1.default.selected]: isSelected,
69
68
  [TreeComponent_module_scss_1.default.focused]: isFocused,
70
69
  }), role: "treeitem", "aria-level": treeItem.depth + 1, "aria-expanded": treeItem.hasChildren ? treeItem.isExpanded : undefined, "aria-selected": isSelected, "aria-label": treeItem.displayName, "aria-busy": isLoading, tabIndex: isFocused ? 0 : -1, children: [(0, jsx_runtime_1.jsxs)("div", { onClick: onToggleNode, className: TreeComponent_module_scss_1.default.gutter, style: { cursor: isLoading ? "default" : "pointer" }, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: treeItem.depth * 10 }, className: TreeComponent_module_scss_1.default.depthPlaceholder }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(TreeComponent_module_scss_1.default.toggleWrapper, {
@@ -614,10 +613,6 @@ exports.TreeComponent = (0, react_1.memo)((props) => {
614
613
  animateExpand,
615
614
  expandRotation,
616
615
  ]);
617
- const getItemKey = (0, react_1.useCallback)((index, data) => {
618
- const node = data.nodes[index];
619
- return (node === null || node === void 0 ? void 0 : node.key) || (node === null || node === void 0 ? void 0 : node.id) || `fallback-${index}`;
620
- }, []);
621
616
  // Shared API implementation to avoid duplication between ref and component APIs
622
617
  const treeApiMethods = (0, react_1.useMemo)(() => {
623
618
  return {
@@ -790,8 +785,8 @@ exports.TreeComponent = (0, react_1.memo)((props) => {
790
785
  const updatedFlatTreeData = (0, treeUtils_1.toFlatTree)(treeData, newExpandedIds, fieldConfig.dynamicField, nodeStates);
791
786
  const nodeIndex = updatedFlatTreeData.findIndex((item) => String(item.key) === String(nodeId));
792
787
  if (nodeIndex >= 0 && listRef.current) {
793
- // Scroll to the item using the FixedSizeList's scrollToItem method
794
- listRef.current.scrollToItem(nodeIndex, "center");
788
+ // Scroll to the item using virtua's scrollToIndex method
789
+ listRef.current.scrollToIndex(nodeIndex, { align: "center" });
795
790
  }
796
791
  }, 0);
797
792
  },
@@ -799,7 +794,7 @@ exports.TreeComponent = (0, react_1.memo)((props) => {
799
794
  // Simple scroll without expanding - just scroll to the item if it's visible
800
795
  const nodeIndex = findNodeIndexById(nodeId);
801
796
  if (nodeIndex >= 0 && listRef.current) {
802
- listRef.current.scrollToItem(nodeIndex, "center");
797
+ listRef.current.scrollToIndex(nodeIndex, { align: "center" });
803
798
  }
804
799
  },
805
800
  appendNode: (parentNodeId, nodeData) => {
@@ -1130,5 +1125,5 @@ exports.TreeComponent = (0, react_1.memo)((props) => {
1130
1125
  setFocusedIndex(-1);
1131
1126
  }
1132
1127
  }, []);
1133
- return ((0, jsx_runtime_1.jsx)("div", { ref: treeContainerRef, className: (0, classnames_1.default)(TreeComponent_module_scss_1.default.wrapper, className), role: "tree", "aria-label": "Tree navigation", "aria-multiselectable": "false", tabIndex: 0, onFocus: handleTreeFocus, onBlur: handleTreeBlur, onKeyDown: handleKeyDown, children: (0, jsx_runtime_1.jsx)(react_virtualized_auto_sizer_1.default, { children: ({ width, height }) => ((0, jsx_runtime_1.jsx)(react_window_1.FixedSizeList, { ref: listRef, height: height, itemCount: itemData.nodes.length, itemData: itemData, itemSize: itemHeight, itemKey: getItemKey, width: width, children: TreeRow })) }) }));
1128
+ return ((0, jsx_runtime_1.jsx)("div", { ref: treeContainerRef, className: (0, classnames_1.default)(TreeComponent_module_scss_1.default.wrapper, className), role: "tree", "aria-label": "Tree navigation", "aria-multiselectable": "false", tabIndex: 0, onFocus: handleTreeFocus, onBlur: handleTreeBlur, onKeyDown: handleKeyDown, style: { height: "100%", overflow: "auto" }, children: (0, jsx_runtime_1.jsx)(virtua_1.Virtualizer, { ref: listRef, children: flatTreeData.map((node, index) => ((0, jsx_runtime_1.jsx)(TreeRow, { index: index, data: itemData }, node.key))) }) }));
1134
1129
  });