All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.components.table.DropDown.js Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import {ClayButtonWithIcon} from '@clayui/button';
import ClayDropDown, {Align} from '@clayui/drop-down';
import React, {cloneElement, useState} from 'react';

const DropDownAction = ({action: {action, name}, item, setActive}) => {
	if (name === 'divider') {
		return ;
	}

	return (
		 {
				event.preventDefault();
				setActive(false);

				if (action) {
					action(item);
				}
			}}
		>
			{typeof name === 'function' ? name(item) : name}
		
	);
};

export default function DropDown({actions, item, noActionsMessage}) {
	const [active, setActive] = useState(false);

	const DropdownButton = (
		
	);

	actions = actions.filter((action) =>
		action.show ? action.show(item) : true
	);

	if (!actions.length) {
		return cloneElement(DropdownButton, {
			'data-tooltip-align': 'bottom',
			'data-tooltip-delay': '200',
			'disabled': true,
			'title': noActionsMessage,
		});
	}

	return (
		 setActive(newVal)}
			trigger={DropdownButton}
		>
			
				{actions.map((action, index) => (
					
				))}
			
		
	);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy