@elastic/eui
Version:
Elastic UI Component Library
52 lines (51 loc) • 1.87 kB
JavaScript
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import classNames from 'classnames';
import { DefaultItemAction } from './default_item_action';
import { CustomItemAction } from './custom_item_action';
import { isCustomItemAction } from './action_types';
import { jsx as ___EmotionJSX } from "@emotion/react";
export var ExpandedItemActions = function ExpandedItemActions(_ref) {
var actions = _ref.actions,
itemId = _ref.itemId,
item = _ref.item,
actionsDisabled = _ref.actionsDisabled,
className = _ref.className;
return ___EmotionJSX(React.Fragment, null, actions.reduce(function (tools, action, index) {
var available = action.available ? action.available(item) : true;
if (!available) {
return tools;
}
var enabled = action.enabled == null || action.enabled(item);
var key = "item_action_".concat(itemId, "_").concat(index);
var classes = classNames(className, {
'euiBasicTableAction-showOnHover': action.showOnHover
});
if (isCustomItemAction(action)) {
// custom action has a render function
tools.push(___EmotionJSX(CustomItemAction, {
key: key,
className: classes,
index: index,
action: action,
enabled: enabled && !actionsDisabled,
item: item
}));
} else {
tools.push(___EmotionJSX(DefaultItemAction, {
key: key,
className: classes,
action: action,
enabled: enabled && !actionsDisabled,
item: item
}));
}
return tools;
}, []));
};