import React__default, { useCallback } from 'react';
import { IconButtonMenu } from './IconButtonMenu.mjs';
import styled from '../../../../../node_modules/@mui/material/styles/styled.mjs';
import MoreVert from '../../../../../node_modules/@mui/icons-material/esm/MoreVert.mjs';

const StyledDiv = styled('div')({
    display: 'flex',
    width: '100%',
    justifyContent: 'center'
});
const ActionMenu = ({ actions, item, idPrefix })=>{
    return /*#__PURE__*/ React__default.createElement(IconButtonMenu, {
        actions: actions,
        item: item,
        idPrefix: idPrefix,
        icon: /*#__PURE__*/ React__default.createElement(MoreVert, {
            fontSize: "large"
        })
    });
};
const useActionMenu = ({ actions, idPrefix, getId })=>{
    const getItemActionProps = useCallback((item)=>{
        const hasVisibleActions = actions.some(({ isVisible = true })=>typeof isVisible === 'function' ? isVisible(item) : isVisible);
        if (!hasVisibleActions) {
            return {};
        }
        return {
            customAction: /*#__PURE__*/ React__default.createElement(StyledDiv, null, /*#__PURE__*/ React__default.createElement(ActionMenu, {
                actions: actions,
                item: item,
                idPrefix: `${idPrefix}-action-menu-${getId(item)}`
            }))
        };
    }, [
        actions,
        getId,
        idPrefix
    ]);
    return {
        getItemActionProps
    };
};

export { ActionMenu, useActionMenu };
//# sourceMappingURL=ActionMenu.mjs.map
