2017-04-17 17:14:17 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-05-22 20:08:47 +03:00
|
|
|
import { themr } from 'react-css-themr';
|
2017-01-26 20:05:32 +03:00
|
|
|
import { LIST } from '../identifiers';
|
|
|
|
import InjectListItemAction from './ListItemAction';
|
2016-01-26 16:59:57 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
const factory = (ListItemAction) => {
|
2017-01-26 20:05:32 +03:00
|
|
|
const ListItemActions = ({ type, children, theme }) => {
|
2016-05-29 21:59:54 +03:00
|
|
|
const validChildren = React.Children.toArray(children).filter(c => (
|
|
|
|
React.isValidElement(c)
|
|
|
|
));
|
2016-01-26 16:59:57 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
return (
|
|
|
|
<span className={theme[type]}>
|
2017-01-26 20:05:32 +03:00
|
|
|
{validChildren.map((action, i) => (
|
|
|
|
<ListItemAction key={i} theme={theme} action={action} /> // eslint-disable-line
|
|
|
|
))}
|
2016-05-29 21:59:54 +03:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ListItemActions.propTypes = {
|
2017-01-26 20:05:32 +03:00
|
|
|
children: PropTypes.node,
|
2016-05-29 22:11:04 +03:00
|
|
|
theme: PropTypes.shape({
|
2016-06-04 00:44:33 +03:00
|
|
|
left: PropTypes.string,
|
2017-01-26 20:05:32 +03:00
|
|
|
right: PropTypes.string,
|
2016-05-29 21:59:54 +03:00
|
|
|
}),
|
2017-01-26 20:05:32 +03:00
|
|
|
type: PropTypes.oneOf(['left', 'right']),
|
2016-05-29 21:59:54 +03:00
|
|
|
};
|
2016-01-26 16:59:57 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
return ListItemActions;
|
2016-01-26 16:59:57 +03:00
|
|
|
};
|
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
const ListItemActions = factory(InjectListItemAction);
|
|
|
|
export default themr(LIST)(ListItemActions);
|
|
|
|
export { factory as listItemActionsFactory };
|
|
|
|
export { ListItemActions };
|