@topconsultnpm/sdkui-react 6.20.0-dev1.65 → 6.20.0-dev1.66
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useImperativeHandle } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { ContextMenu as TMContextMenu } from '../NewComponents/ContextMenu';
|
|
5
5
|
import { TMColors } from '../../utils/theme';
|
|
6
|
-
import { genUniqueId } from '../../helper';
|
|
7
6
|
const StyledContent = styled.div `
|
|
8
7
|
cursor: pointer;
|
|
9
8
|
border-radius: ${props => props.$borderRadius};
|
|
@@ -23,9 +22,7 @@ const StyledContent = styled.div `
|
|
|
23
22
|
}
|
|
24
23
|
`;
|
|
25
24
|
const TMDropDownMenu = forwardRef(({ content, items, disabled = false, color = TMColors.text_normal, backgroundColor = TMColors.default_background, borderRadius, onMenuShown }, ref) => {
|
|
26
|
-
const
|
|
27
|
-
const dropDownMenuElementRef = useRef(null); // Ref all'elemento DOM div principale
|
|
28
|
-
useEffect(() => { setID(genUniqueId()); }, [content]);
|
|
25
|
+
const dropDownMenuElementRef = useRef(null);
|
|
29
26
|
useImperativeHandle(ref, () => ({
|
|
30
27
|
focus: () => {
|
|
31
28
|
dropDownMenuElementRef.current?.focus();
|
|
@@ -44,19 +41,6 @@ const TMDropDownMenu = forwardRef(({ content, items, disabled = false, color = T
|
|
|
44
41
|
submenu: item.items ? convertToContextMenuItems(item.items) : undefined,
|
|
45
42
|
}));
|
|
46
43
|
};
|
|
47
|
-
|
|
48
|
-
const handleMenuOpen = () => {
|
|
49
|
-
setMenuVisible(true);
|
|
50
|
-
onMenuShown?.();
|
|
51
|
-
};
|
|
52
|
-
const handleMenuClose = () => {
|
|
53
|
-
setMenuVisible(false);
|
|
54
|
-
dropDownMenuElementRef.current?.focus();
|
|
55
|
-
};
|
|
56
|
-
return (_jsxs(_Fragment, { children: [_jsx(StyledContent, { id: `idContainer${id}`, ref: dropDownMenuElementRef, tabIndex: disabled ? -1 : 0, "$disabled": disabled, "$color": color, "$backgroundColor": backgroundColor, "$borderRadius": borderRadius, onClick: !disabled ? handleMenuOpen : undefined, children: content }), _jsx(TMContextMenu, { items: convertToContextMenuItems(items), target: `#idContainer${id}`, trigger: "left", externalControl: {
|
|
57
|
-
visible: menuVisible,
|
|
58
|
-
position: { x: 0, y: 0 },
|
|
59
|
-
onClose: handleMenuClose,
|
|
60
|
-
} })] }));
|
|
44
|
+
return (_jsx(TMContextMenu, { items: convertToContextMenuItems(items), trigger: "left", children: _jsx(StyledContent, { ref: dropDownMenuElementRef, tabIndex: disabled ? -1 : 0, "$disabled": disabled, "$color": color, "$backgroundColor": backgroundColor, "$borderRadius": borderRadius, children: content }) }));
|
|
61
45
|
});
|
|
62
46
|
export default TMDropDownMenu;
|