@tap-payments/os-micro-frontend-shared 0.1.391-test.2 → 0.1.391-test.3
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.
|
@@ -6,13 +6,10 @@ import { initializeTreeMapper, promoteSingleChild, TreeManager, updateSelection
|
|
|
6
6
|
import TreeDropdownProvider from './context/TreeDropdownProvider';
|
|
7
7
|
const TreeDropdown = forwardRef((props, ref) => {
|
|
8
8
|
const { anchorEl, placement = 'bottom-start', treeDefinition, sx, onChange, multiple = true, exposeOnlySelectedTree = false, IconComponent, onMounted, } = props;
|
|
9
|
-
const { header, footer, children:
|
|
10
|
-
/**
|
|
11
|
-
* Only keep the initial menu items in a ref to avoid re-rendering the component when the menu items change.
|
|
12
|
-
*/
|
|
13
|
-
const menuItems = useRef(initialMenuItems).current;
|
|
9
|
+
const { header, footer, children: menuItems = [], searchProps, levelKey } = treeDefinition;
|
|
14
10
|
const [treeMapper, setTreeMapper] = useState({});
|
|
15
|
-
const
|
|
11
|
+
const onMountedRef = useRef(onMounted);
|
|
12
|
+
onMountedRef.current = onMounted;
|
|
16
13
|
const formattedMenuItems = useMemo(() => promoteSingleChild(menuItems || []), [menuItems]);
|
|
17
14
|
const getFullTree = useCallback(() => TreeManager.denormalizeTree(menuItems, treeMapper), [menuItems, treeMapper]);
|
|
18
15
|
const getSelectedTree = useCallback(() => TreeManager.extractSelectedBranches(getFullTree()), [getFullTree]);
|
|
@@ -48,19 +45,18 @@ const TreeDropdown = forwardRef((props, ref) => {
|
|
|
48
45
|
}
|
|
49
46
|
}, [treeMapper, onChange, menuItems, exposeOnlySelectedTree]);
|
|
50
47
|
useEffect(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
initialized.current = true;
|
|
48
|
+
var _a;
|
|
49
|
+
console.log('TreeDropdown mounted');
|
|
54
50
|
const intitialMapper = initializeTreeMapper(menuItems || [], multiple);
|
|
55
51
|
setTreeMapper(intitialMapper);
|
|
56
52
|
const tree = TreeManager.denormalizeTree(menuItems, intitialMapper);
|
|
57
53
|
const selectedTree = TreeManager.extractSelectedBranches(tree);
|
|
58
|
-
|
|
54
|
+
(_a = onMountedRef.current) === null || _a === void 0 ? void 0 : _a.call(onMountedRef, {
|
|
59
55
|
state: intitialMapper,
|
|
60
56
|
tree,
|
|
61
57
|
selectedTree,
|
|
62
58
|
});
|
|
63
|
-
}, [menuItems, multiple
|
|
59
|
+
}, [menuItems, multiple]);
|
|
64
60
|
useImperativeHandle(ref, () => ({
|
|
65
61
|
treeMapper,
|
|
66
62
|
getFullTree,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.391-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.391-test.3",
|
|
5
|
+
"testVersion": 3,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|